Exception Errors
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.
Try this:
This way you KNOW d3d is initalized.
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.
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.
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)))
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement