Sign in to follow this  
Dom_152

Exception Errors

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
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)))

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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