Skip to main content
gamedev.net
🔒 Locked

Error loading texture

Started by shakazed Jul 22, 2003 at 10:29 AM 2 replies 400+ views
Original Post
shakazed
shakazed
Hi! Hmm, I dunno why I always get stuck on thses stupid things but I could really use some help. I´m trying to laod a mesh, but it fails when trying to load each individual texture for the subsets. Heres the code I use for loading.
bool CPlayer::LoadTankMesh(IDirect3DDevice9 *p_D3DDev9)
{

	if(FAILED(D3DXLoadMeshFromX("Meshes\\tiger.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;

		p_D3DTextures[i] = NULL;
		if(FAILED(D3DXCreateTextureFromFile(p_D3DDev9,p_D3DXMaterialBufferPtr[i].pTextureFilename,
			&p_D3DTextures[i])))
		{
			MessageBox(NULL, "Failed to load texture (tank)", "Error",MB_OK);
			return false;
		}
	}

	p_D3DXMtrlBuffer->Release();

	return true;
}
And here are the member variables I set.
	D3DMATERIAL9 *p_D3DMaterials;
	LPDIRECT3DTEXTURE9 *p_D3DTextures;
	LPD3DXBUFFER p_D3DXMtrlBuffer;
	LPD3DXMESH p_D3DXMesh;

	unsigned long lNumMtrls;
It´s really annoying getting stuck like this, and if anyone has the time, please check it out.
Bad Monkey Productions
Dave Hunt
Dave Hunt
Check the return value from the DX functions you are calling. Then look up the value in the DX Error tool. That should tell you why it''s failing.
shakazed
shakazed
Man! I can´t pinpoint where the error occurs. Debug doen´t show squat. GAH! I need to see my tank!!!

[edited by - shakazed on July 22, 2003 4:04:05 PM]
Dave Hunt
Dave Hunt
You say it's failing when loading the individual textures. If that's the case then you HAVE pinpointed where the error occurs.

Does the .x file have an explicit path to the texture files, or is it relative? You're loading the mesh from a relative path (Meshes/tiger.x).

Where are the texture files? Does p_D3DXMaterialBufferPtr[\i].pTextureFilename give the correct path to a texture file?

What is the return value from D3DXCreateTextureFromFile()?

Etc., etc., etc...


[edited by - Dave Hunt on July 22, 2003 4:16:42 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.