Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5287 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I implemented a Device-Lost-protection using Testcooperativelevel; when device is lost the applications enters a loop until the device is available again. The problem is that, even If I switch to my fullscreen-window again, the loop isn''t left - for some reason the device is still lost... How can I detect when the user reenters the apllication, so that I can reset the device??? Thx

Share this post

Link to post
Share on other sites
I don''t think you should rely on WM_ACTIVATE *alone*. You should always TestCooperativeLevel() until you get a D3DERR_DEVICENOTRESET. Only then you should restore.

What does your loop look like?

Muhammad Haggag,

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Well, unfortunately, I''m using VB .NET, but I think you''ll be able to understand this:

Engine.TestStatus returns FALSE when TestCooperativeLevel failed, otherwise TRUE.

Engine.Reset (which is never called because the application is stuck in the loop) resets the device.

Application.DoEvents lets the app "breathe", i.e. reveive events.

If Not Engine.TestStatus Then
Catch ex As Exception
End Try
Loop Until Engine.TestStatus
End If

This is Engine.TestStatus:

Public Function TestStatus() As Boolean
Return True
Catch ex As Exception
Return False
End Try
End Function

Share this post

Link to post
Share on other sites
Check for Success/Fail of TestCooperativeLevel is not sufficient. You have to check the exception that gets thrown.

//Device is lost, free all non-MANAGED resources
//Sleep for a bit to not waste resources
//Device can be reset now

Both of those are a failure, but DeviceNotResetException is what you''re waiting for. If TestCooperativeLevel succeeds it means that everything is fine and no Reseting is needed.

Stay Casual,

Drunken Hyena

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!