Jump to content
  • Advertisement
Sign in to follow this  

Access violation reading

This topic is 4088 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 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
Sign in to follow this  

  • 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!