Archived

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

shakazed

What the #%(%"/%/(¤%

Recommended Posts

I´m soooo depressed.....or maybe not but man this progrblem is giving me headaches. After I pass my IDirect3DDevice9 object to my mesh handling class I get an error every time i try to use it outside the class when setting a new texture. I tried putting everything into one big class and then it worked fine, but that code was kinda hard to maintain. Here´s the code for loading my mesh.
bool CPlayer::LoadTankMesh(IDirect3DDevice9 *p_D3DDev9, char* cTankTexture)
{

	LPD3DXBUFFER p_D3DXMtrlBuffer = NULL;

	if(FAILED(D3DXLoadMeshFromX("Meshes\\tank.x",
		D3DXMESH_SYSTEMMEM,p_D3DDev9, NULL,
		&p_D3DXMtrlBuffer,NULL, &lNumMtrls, &p_D3DXMesh)))
	{
		MessageBox(NULL, "Failed to load mesh (tank)", "Error", MB_OK);
		return false;
	}

	D3DXMATERIAL *p_D3DXMaterialBufferPtr = (D3DXMATERIAL*)p_D3DXMtrlBuffer->GetBufferPointer();

	p_D3DMaterials = new D3DMATERIAL9[lNumMtrls];
	p_D3DTextures  = new LPDIRECT3DTEXTURE9[lNumMtrls];

	for(unsigned long i = 0; i < lNumMtrls;i++)
	{
		p_D3DMaterials[i] = p_D3DXMaterialBufferPtr[i].MatD3D;
		p_D3DMaterials[i].Ambient = p_D3DMaterials[i].Diffuse;

		if(FAILED(D3DXCreateTextureFromFile(p_D3DDev9,cTankTexture,
			&p_D3DTextures[i])))
		{
			MessageBox(NULL, "Failed to load texture subset (tank)", "Error",MB_OK);
			return 0;
		}
	}

	p_D3DXMtrlBuffer->Release();

	return true;
}
The error that I get is an unhandled exception in D3D9.DLL (acces violation).
Bad Monkey Productions

Share this post


Link to post
Share on other sites