Sign in to follow this  

Device-CreateImageSurface Problem

This topic is 4352 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

Ok, so I'm trying to get a simple surface drawn in Direct3D8 (I know, latest is 9, but for now I'm working with 8), and everything compiles fine, but when I run it, I get an error: "Unhandled exception at 0x6d9ee684 in Direct3DProject1.exe: 0xC0000005: Access violation reading location 0x00000000." This is the line that causes the error: m_pD3DDevice->CopyRects(m_pD3DSurface, NULL, 0, pBackBuffer, NULL); After investigating, I came to the realization that my call to CreateImageSurface is failing for some reason, and assigning a value of 0x00000000 to m_pD3DSurface. Here's that code: if(FAILED(m_pD3DDevice->CreateImageSurface(256, 256, (D3DFORMAT) m_iD3DFormat, &m_pD3DSurface))) { return E_FAIL; } Before that function is called, m_pD3DSurface has a value, but afterwards, it becomes 0x00000000. Help? EDIT: Ok, so I did a little more debugging, and it's telling me that the format("mrUInt32 m_iD3DFormat", which "mrUInt32" being more or less an unsigned long) is incorrect: "Direct3D8: (ERROR) :This format is not supported for CreateImageSurface" I don't understand what the problem there is. =/ [Edited by - Osiris990 on January 14, 2006 9:32:18 PM]

Share this post


Link to post
Share on other sites
0x00000000 is a null pointer, C/C++ programs have a tendency to explode when you try to access/use/dereference one [smile]

If you haven't used m_pD3DSurface before you create it, you should declare it as NULL -

LPDIRECT3DSURFACE8 m_pD3DSurface = NULL;

Minor thing really, but doing it that way makes it easier to detect some bugs.

Anyway, have you ramped up your debug level? usually when D3D/D3DX calls fail they will output a debug message indicating why.

The only other thing I can think of is that your m_iD3DFormat value is invalid - this should be checked against what your device does (or does not) support.

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by Osiris990
EDIT: Ok, so I did a little more debugging, and it's telling me that the format("mrUInt32 m_iD3DFormat", witch "mrUInt32" being more or less an unsigned long) is incorrect:
"Direct3D8: (ERROR) :This format is not supported for CreateImageSurface"

I don't understand what the problem there is. =/

This means that your graphics card doesn't support that particular format. If you check the CAPS Viewer, you will see all of the different surface formats that your hardware supports. Nowadays, you can pretty much rely on having:
D3DFMT_R8G8B8
D3DFMT_A8R8G8B8
D3DFMT_X8R8G8B8

among other general-purpose formats.

Share this post


Link to post
Share on other sites
Quote:
Original post by circlesoft
Quote:
Original post by Osiris990
EDIT: Ok, so I did a little more debugging, and it's telling me that the format("mrUInt32 m_iD3DFormat", witch "mrUInt32" being more or less an unsigned long) is incorrect:
"Direct3D8: (ERROR) :This format is not supported for CreateImageSurface"

I don't understand what the problem there is. =/

This means that your graphics card doesn't support that particular format. If you check the CAPS Viewer, you will see all of the different surface formats that your hardware supports. Nowadays, you can pretty much rely on having:
D3DFMT_R8G8B8
D3DFMT_A8R8G8B8
D3DFMT_X8R8G8B8

among other general-purpose formats.


Ok, well that fixed that error, but now I have another access violation error, and this time the debugger is saying that it can't direct me to any source code, but instead only assembly.

First-chance exception at 0x7c91b3fb in Direct3DProject1.exe: 0xC0000005: Access violation reading location 0xffa0a0a0.
First-chance exception at 0x00931041 in Direct3DProject1.exe: 0xC0000005: Access violation reading location 0xffc6c6f6.
Unhandled exception at 0x00931041 in Direct3DProject1.exe: 0xC0000005: Access violation reading location 0xffc6c6f6.


*sigh* :(

Edit: I have it using D3DFMT_X8R8G8B8, by the way... I tried a few others, but none of them worked either.

Share this post


Link to post
Share on other sites
Quote:
Original post by Osiris990
Ok, well that fixed that error, but now I have another access violation error, and this time the debugger is saying that it can't direct me to any source code, but instead only assembly.

Okay, what you need to do is step in the debugger to the spot right before the access violation occurs. You can always use the Call Stack to do this. Then, find what object you are using is causing the problem. This can easily be done by looking it up in the Watch or Locals window.

Share this post


Link to post
Share on other sites
Well see, I know *WHERE* the error occurs... It's at the CopyRects() call referenced above. Here is the error it throws to me:

Unhandled exception at 0x6d9b0381 in Direct3DProject1.exe: 0xC0000005: Access violation reading location 0xffb1b1e1.


See, the thing is, I can't find what's at 0xffb1b1e1 at all. I have no clue what the problem might be. The debug output from D3D is just as unhelpful:

First-chance exception at 0x6d9b0381 in Direct3DProject1.exe: 0xC0000005: Access violation reading location 0xffb1b1e1.
Unhandled exception at 0x6d9b0381 in Direct3DProject1.exe: 0xC0000005: Access violation reading location 0xffb1b1e1.


Grrrr... >:(

Share this post


Link to post
Share on other sites
Quote:
Original post by Osiris990
Well see, I know *WHERE* the error occurs... It's at the CopyRects() call referenced above.

Here is that code again:

m_pD3DDevice->CopyRects(m_pD3DSurface, NULL, 0, pBackBuffer, NULL);

The first thing you should do is to check all of the parameters of this function to make sure they are valid. For example, make sure m_pD3DSurface and pBackBuffer are okay to use.

Also, you should make sure that you can indeed supply NULL for those other parameters.

Share this post


Link to post
Share on other sites

This topic is 4352 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.

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