Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Sending LPDIRECT3DDEVICE9 to a class func.

This topic is 5415 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

Hi! I have a class in my project that takes care of loading and rendering .x files. The problem is that after I pass my LPDIRECT3DDEVICE interface ptr to the first load function it collapses, with that I mean that I can´t use the ptr cuz then I get an error. The func. looks like this.
HRESULT CXModel::LoadXFile(char* p_strPathModelname, char* p_strPathTexturename, LPDIRECT3DDEVICE9 lpD3DDev9)

	if(FAILED(D3DXLoadMeshFromX(p_strPathModelname, D3DXMESH_SYSTEMMEM, lpD3DDev9, NULL,
		&lpD3DXMtrlBuffer, NULL, &lNumMtrls, &lpD3DXMesh)))
		MessageBox(NULL, "Failed to load .x file", "DX_02.exe", MB_OK);

	d3dxMtrl = (D3DXMATERIAL*)lpD3DXMtrlBuffer->GetBufferPointer();
	d3dMaterials = new D3DMATERIAL9[lNumMtrls];
	lpD3DTexture = new LPDIRECT3DTEXTURE9[lNumMtrls];

	for(unsigned long i = 0; i<lNumMtrls; i++)
		d3dMaterials[i] = d3dxMtrl[i].MatD3D;
		d3dMaterials[i].Ambient = d3dMaterials[i].Diffuse;

		if(FAILED(D3DXCreateTextureFromFile(lpD3DDev9, p_strPathTexturename,
			MessageBox(NULL, "Failed to load texture", "DX_02.exe", MB_OK);

	return S_OK;
And this is how I call the function, passing my LPDIRECT3DDEVICE ptr.
CXModel cMap;
Oh, the class is in a seperate file.
Bad Monkey Productions

Share this post

Link to post
Share on other sites
What kind of error are you getting? Is there any output to the debug spew? Could the pointer be getting passed in as NULL? Have you tried stepping into this function with the debugger?


Share this post

Link to post
Share on other sites

  • 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!