Exception Errors

Started by
5 comments, last by Bimble Bob 18 years ago
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.
It's not a bug... it's a feature!
Advertisement
Is it possible that the "d3d" object might be a NULL pointer?
:==-_ Why don't the voices just leave me alone?! _-==:
Are you certain that d3d is valid? Did you create the device?


jfl.
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.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

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.
It's not a bug... it's a feature!
Quote:Original post by Dom_152
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.


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)))

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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!
It's not a bug... it's a feature!

This topic is closed to new replies.

Advertisement