Sign in to follow this  

Access violation reading

Recommended Posts

I have a class for my objects in my game engine. This class is:
class AStaticObject {
	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;
	bool fx;
	//select tech result
	HRESULT effect;

	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.

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this