Sign in to follow this  
Followers 0
george7378

TestCooperativeLevel causing exception

7 posts in this topic

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!

0

Share this post


Link to post
Share on other sites

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

Edited by Dawoodoz
1

Share this post


Link to post
Share on other sites

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.

Edited by mhagain
1

Share this post


Link to post
Share on other sites

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?

0

Share this post


Link to post
Share on other sites

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

1

Share this post


Link to post
Share on other sites

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!

0

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  
Followers 0