Jump to content
  • Advertisement

Archived

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

Sending LPDIRECT3DDEVICE9 to a class func.

This topic is 5231 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)
{
	LPD3DXBUFFER lpD3DXMtrlBuffer;

	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,
			&lpD3DTexture[i])))
		{
			MessageBox(NULL, "Failed to load texture", "DX_02.exe", MB_OK);
		}
		
	}

	lpD3DXMtrlBuffer->Release();
	
	return S_OK;
}
And this is how I call the function, passing my LPDIRECT3DDEVICE ptr.
CXModel cMap;
cMap.RenderXFile(lpD3DDev9);
Oh, the class is in a seperate file.
Bad Monkey Productions

Share this post


Link to post
Share on other sites
Advertisement
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?

neneboricua

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!