Exception Errors

This topic is 4496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Well I have started making this game and I have written code to check the graphics devices capabilities (Like you should) but when I run it I get Exception errors and the debug information shows it is these two bits that are playing up: //Both of the below checks cause Exception errors //Check to see if the device supports 32 bit mode if(FAILED(d3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8 , D3DFMT_A8R8G8B8, TRUE))) { MessageBox(NULL, "Error, 32 bit mode not supported", "Initialization Error", MB_OK); LoADone(); return 0; } //Now get information on the device and what it can support if(FAILED(d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dcaps))) { MessageBox(NULL, "Error, Could not get the device capabilities", "Initilization Error", MB_OK); LoADone(); return 0; } So anyone got any ideas on whats going wrong here? BTW The Error message I get is: Unhandled Exception in LoA.exe: 0xC0000005: Access Violation. I'm obviously doing something wrong but I dunno what.

Share on other sites
Is it possible that the "d3d" object might be a NULL pointer?

Share on other sites
Are you certain that d3d is valid? Did you create the device?

jfl.

Share on other sites
Try this:
if (d3d) {    if(FAILED(d3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8 , D3DFMT_A8R8G8B8, TRUE)))    {         MessageBox(NULL, "Error, 32 bit mode not supported", "Initialization Error", MB_OK);         LoADone();         return 0;    }    //Now get information on the device and what it can support    if(FAILED(d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dcaps)))    {         MessageBox(NULL, "Error, Could not get the device capabilities",   "Initilization Error", MB_OK);         LoADone();         return 0;    }} else{    MessageBox(NULL, "d3d not initialized", "Error:", MB_OK);    LoADone();    return 0;}

This way you KNOW d3d is initalized.

Share on other sites
Thanks, it works now only it's telling me that I can't support 32bit mode even though I'm running my Desktop at 32 bit :S.

Share on other sites
Quote:
 Original post by Dom_152Thanks, it works now only it's telling me that I can't support 32bit mode even though I'm running my Desktop at 32 bit :S.

Your CheckDeviceType() call failing tells you one of the *formats* isn't supported for the use you've specified (display format or back buffer format), not that 32-bit mode isn't supported.

If you look at the documentation for D3DFORMAT, you'll see a little table under the "BackBuffer or Display Formats" sub-heading. You'll notice in that table that D3DFMT_A8R8G8B8 is not supported as a **Display** format. It is however supported as a backbuffer format (assuming your display hardware supports destination-alpha in the frame buffer - current hardware does).

Try changing it to:
if(FAILED(d3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8, TRUE)))

Share on other sites
Thanks all for the help. Thanks to my trusty error messages I can see that I'm not initializing Direct3D correctly. Now I must fix it. Aha no more errors so I assume everything's running smoothly. Thanks again for the help!

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 29
• 40
• 23
• 13
• 13
• Forum Statistics

• Total Topics
631740
• Total Posts
3001962
×