Jump to content
  • Advertisement

Archived

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

shakazed

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

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

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
Advertisement
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

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!