Original Post
First, I know this should be in the Directx Forum, but I think the problem has to do with pointers, not directx. I have a class Mesh. It can load, render, and dispose of meshes. Here is the code: mesh.h mesh.cpp so those two lines near the bottom, right below where it says "ERROR", this is where I am getting it. error C2227: left of '->SetMaterial' must point to class/struct/union error C2227: left of '->SetMaterial' must point to class/struct/union I think I am doing it right, but i guess not. Anyone got any idea what is going on?
#pragma once
#include <d3dx9.h>
class Mesh
{
public:
Mesh(string FileName, LPDIRECT3DDEVICE9* pDevice);
~Mesh(void);
// Loads a mesh from an X File
bool LoadMeshFromFile(LPCTSTR fileName);
// Render's this mesh
void Render(void);
private:
LPD3DXMESH pMesh; // Our mesh object in sysmem
D3DMATERIAL9* pMeshMaterials; // Materials for our mesh
LPDIRECT3DTEXTURE9* pMeshTextures; // Textures for our mesh
DWORD dwNumMaterials; // Number of mesh materials
LPDIRECT3DDEVICE9* Device;
};
#include "StdAfx.h"
#include "mesh.h"
#include <strsafe.h>
#include <string>
using namespace std;
Mesh::Mesh(string FileName, LPDIRECT3DDEVICE9* pDevice) : pd3dDevice(NULL)
{
if(Device != NULL)
{
Device = pDevice;
LoadMeshFromFile(LPCTSTR(FileName.c_str()));
}
}
Mesh::~Mesh(void)
{
}
// Loads a mesh from an X File
bool Mesh::LoadMeshFromFile(LPCTSTR fileName)
{
//Ommited, because it works, and is not source of error
}
// Render's this mesh
void Mesh::Render(void)
{
// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i = 0; i < dwNumMaterials; i++ )
{
// Set the material and texture for this subset
// ERROR ERROR ERROR ERROR ERROR ERROR
Device->SetMaterial( &pMeshMaterials );
pd3dDevice->SetTexture( 0, pMeshTextures );
// Draw the mesh subset
pMesh->DrawSubset( i );
}
}