TestCooperativeLevel causing exception

Started by
6 comments, last by george7378 11 years ago

Hi everyone,

I've got a problem when I try to debug my program using the VS2012 debugger. I've got the following issue when I try to run TestCooperativeLevel():

[attachment=14629:exception.jpg]

Note that soundState() simply changes the pause state of some sounds (using functions in the irrKlang library). Even if I remove the soundState() line, the same exception is thrown. The problem doesn't prevent my game from running on my Win7 laptop, but it causes an outright crash when I run it on my XP computer. Any ideas what could be causing the exception?

Thanks!

Advertisement

Check if d3ddev is null. Your sound engine might be initiated before the graphics part.

A WM_ACTIVATE or WM_ACTIVATEAPP message can be sent when your window is first created, which is probably what is happening here.

This, by the way, is one of the reasons why you should NEVER check for lost devices from WM_ACTIVATE or WM_ACTIVATEAPP (the other one is that there are conditions other than Alt-Tabbing which can cause a lost device; one example might be another program taking exclusive ownership of the display while you're running in a windowed mode). Do it the documented way and check your HRESULT from Present instead.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Is you d3ddev valid?

d3ddev is a null pointer

OK, I changed it so that the lost device checking is done every frame instead, and yes, it now works fine. Thanks!

By the way mhagain, how do you mean check the HRESULT from Present? Does it return a specific result if there's a lost device?

By the way mhagain, how do you mean check the HRESULT from Present? Does it return a specific result if there's a lost device?

For some weird reason this is not included in the MSDN documentation at http://msdn.microsoft.com/en-us/library/windows/desktop/bb174423%28v=vs.85%29.aspx but yes - Present will return D3DERR_DEVICELOST if there was a lost device. The procedure is documented at http://msdn.microsoft.com/en-us/library/windows/desktop/bb174714%28v=vs.85%29.aspx (which is linked to from the MSDN page).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Hmm, yeah, that's strange! I changed it to respond to a lost device if the Present() returns D3DERR_DEVICELOST rather than on WM_ACTIVATEAPP. Thanks!

This topic is closed to new replies.

Advertisement