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

Started by
4 comments, last by shakazed 20 years, 9 months ago
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
Advertisement
The cause of your problem is so blatantly obvious that I almost feel stupid pointing it out.

God hates you
Yeah he called me last night and told me in person.
IDirect3DDevice9 *device

should be

IDirect3DDevice9 **device
or
LPDIRECT3DDEVICE9 *device

.lick
General notes:

- Please choose meaningful titles for your topics
- Develop with the debug runtime.
- Always check the debug output.
- Check all HRESULTs

Peace,
Muhammad Haggag

Yeah, but meaninglessly titled posts always get the most responses. Sad but true.

bpopp (bpopp.net)

This topic is closed to new replies.

Advertisement