Skip to main content
gamedev.net
🔒 Locked

Runtime Error, DirectX Suspect

Started by Osiris990 Oct 25, 2005 at 6:33 PM 5 replies 750+ views
Original Post
Osiris990
Osiris990
Hi again, me once again with a possible DirectX problem. I made a program in D3D that makes a simple design, but when I did, it threw a runtime error at me: "Unhandled exception at 0x6d9ee684 in game_prog_2.exe: 0xC0000005: Access violation reading location 0x00000000." Put simply, I have no clue what this means or how to fix it. Here's the code it broke off at when debugging (which also, according to VC++ has the variable [pBackBuffer] which holds the memory address of the error [0x6d9ee684]): ----- mrBool32 D3DWindow::Frame(void) { m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); LPDIRECT3DSURFACE8 pBackBuffer; m_pD3DDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer); m_pD3DDevice->BeginScene(); m_pD3DDevice->CopyRects(m_pD3DSurface, NULL, 0, pBackBuffer, NULL); m_pD3DDevice->EndScene(); pBackBuffer->Release(); m_pD3DDevice->Present(NULL, NULL, NULL, NULL); return mrTrue; } ----- The actual line it points me to is the one containing CopyRects(), but I figured it'd be wise for me to put the whole function in. Any help, please?
JohnBolton
JohnBolton
That usually means that you are trying to access data through a pointer that has the value 0 (or NULL). Check the values m_pD3DSurface and pBackBuffer. If one of them has the value of 0, then check the return code of the function that set its value. It is likely that the function failed.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Osiris990
Osiris990
How am I supposed to check that though? I can't cout it out, and I can't MessageBox() it, so what am I supposed to do to check the value?

Addendum: I tried using the VC++ FAILED() macro to make it return if GetBackBuffer() failed (thus causing the code in question to never be executed), and it still threw me the error... That should mean that it's not a problem with the function failing, right?
TerrySz
TerrySz
Try writing out the value to a text file.
Osiris990
Osiris990
Ok, so I narrowed it down to the problematic function:

m_pD3DDevice->CreateImageSurface(256, 256, (D3DFORMAT) m_iD3DFormat, &m_pD3DSurface)


It assigns a memory value of 00000000 to m_pD3DSurface and the function fails... Any ideas as to how to fix it?
neneboricua19
neneboricua19
All DirectX functions return error codes. If you're not checking the error codes, there is no way for you to know why something failed. This is just standard software practice.

Make sure you're using the Debug Runtime. When any DirectX function fails while using the Debug Runtime, it will always print a text string to the debug spew saying exactly WHY it failed. This is invaluable when developing DX applications. If you don't know what the Debug Runtime or the debug spew is, check the Forum FAQ.

neneboricua
JohnBolton
JohnBolton
Quote:
Original post by Osiris990
How am I supposed to check that though? I can't cout it out, and I can't MessageBox() it, so what am I supposed to do to check the value?

You DESPERATELY need to learn how to use the debugger.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

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

Sign in to reply to this topic.