Access violation reading

Started by
0 comments, last by StephenTC 16 years, 10 months ago
I have a class for my objects in my game engine. This class is:
class AStaticObject {
protected:
	//Mesh
	ID3DXMesh *g_pD3DXMesh;
	//Material buffer
	ID3DXBuffer *pD3DXMaterials;
	//Number of materials
	DWORD g_dwNumMaterials;
	//Material list and texture list
	D3DXMATERIAL *pMaterials;
	D3DMATERIAL9 *g_pMaterialList;
	IDirect3DTexture9 **g_pTextureList;
	//An effect to go
	ID3DXEffect* g_pEffect;
	//Normal map
	IDirect3DTexture9 *g_pNormal;
	//Position
	D3DXVECTOR4 pos;
	//fx
	bool fx;
	//select tech result
	HRESULT effect;
public:
	AStaticObject();
	~AStaticObject();

	BOOL Load(const char *Filename, AGraphics &graphics);
	BOOL LoadNM(const char *Filename, AGraphics &graphics);
	BOOL Render(AGraphics &graphics);
	BOOL LoadEffect(const char *Filename, AGraphics &graphics);
	BOOL SetTransform(float x, float y, float z);
};
Everything works fine except for when I do anything with IDirect3DTexture9 *g_pNormal;. When I call LoadNM() it works just fine and the texture loads as follows:
BOOL AStaticObject::LoadNM(const char *Filename, AGraphics &graphics)
{
	if(FAILED(D3DXCreateTextureFromFile(graphics.GetDevice(), Filename, &g_pNormal)))
		return FALSE;

	return TRUE;
}
which produces a texture with the normal map. The error comes when I exit the program. It says "Unhandled exception at 0x00401770 in armageddon.exe: 0xC0000005: Access violation reading location 0x00000008." whether I try to release the texture or not. The directx debug does not give me any information on this and I have gotten this problem before but it has always been easy to fix. Can anyone tell me what the issue may be? Thanks.
Advertisement
Some quick advice (and since debug isn't telling you WHAT you're trying to access) I'd guess it has something to do with the device. Make sure that you are sending your device through all the SUCCEEDED/FAILED checks. I mean, not much advice but something might not be properly loading beforehand. Also, maybe your normal map file format isn't a format that the loader is prepared for. Sometimes, image applications throw crap in that shouldn't be there though I wouldn't stress more than 10 minutes on this possibility.

Hope this helps, but otherwise I dunno off the top of my head.
Stephen Timothy Cooney

This topic is closed to new replies.

Advertisement