Jump to content
  • Advertisement
Sign in to follow this  
Etane

Null problem?

This topic is 3788 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 = tempMaterials.MatD3D; material.Ambient = material.Diffuse; USES_CONVERSION; if(FAILED(D3DXCreateTextureFromFile((*m_pDevice), A2W(tempMaterials.pTextureFilename), &texture))) texture = NULL; } return; }

Share this post


Link to post
Share on other sites
Advertisement
In your LoadMeshFromX call, you need a pointer to the pointer to the materials buffer. Change "bufMaterials" to "&bufMaterials."

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!