Sign in to follow this  

Null problem?

Recommended Posts

Im having a little trouble with null values and such, heres my code for s simple Planet class , which is intended to assign a name and load a 3d planet. I'm coming across the error in my Load function in Planet.cpp when it gets to the (D3DXMATERIAL*)bufMaterials->GetBufferPointer(); i think bufmaterials is turning up null..... could anyone possibly tell me what I'm doing wrong? ====================Planet.h==================================================== #ifndef _planet #define _planet #include <d3dx9.h> #include <vector> class Planet { public: std::string Name; Planet(); Planet(char fName[], LPDIRECT3DDEVICE9* Dev); ~Planet(); void Load(char fName[], LPDIRECT3DDEVICE9* Dev); void Render(); void Release(); void SetPosition(D3DXVECTOR3 p) {m_pos = p;} void SetRotation(D3DXVECTOR3 r) {m_rot = r;} void SetScale(D3DXVECTOR3 s) {m_sca = s;} private: D3DXVECTOR3 m_pos, m_rot, m_sca; LPDIRECT3DDEVICE9 *m_pDevice; LPD3DXBUFFER bufMaterials; LPD3DXMESH mesh; // define the mesh pointer D3DMATERIAL9* material; // define the material object DWORD numMaterials; LPDIRECT3DTEXTURE9* texture; }; #endif ===============================Planet.cpp======================================= void Planet::Load(char fName[], LPDIRECT3DDEVICE9* Dev) { m_pDevice = Dev; D3DXLoadMeshFromX((LPCWSTR)fName, D3DXMESH_SYSTEMMEM, (*m_pDevice), NULL, bufMaterials, NULL, &numMaterials, &mesh); D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)bufMaterials->GetBufferPointer(); texture = new LPDIRECT3DTEXTURE9[numMaterials]; material = new D3DMATERIAL9[numMaterials]; for(DWORD i = 0; i < numMaterials; i++) { material[i] = tempMaterials[i].MatD3D; material[i].Ambient = material[i].Diffuse; USES_CONVERSION; if(FAILED(D3DXCreateTextureFromFile((*m_pDevice), A2W(tempMaterials[i].pTextureFilename), &texture[i]))) texture[i] = NULL; } return; }

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this