Jump to content
  • Advertisement
Sign in to follow this  
crshinjin

DXUT calls OnDestroyDevice after WinMain finishes

This topic is 3962 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 started to make a program based on EmptyProject, with a class to handle the events like render frame, lost device, etc. After some debugging I've found out, that DXUT calls the event in this order if I simply start and exit the app: -OnCreateDevice -OnResetDevice -...stuff... -WinMain after DXUTMainLoop -WinMain terminates -OnLostDevice -OnDestroyDevice What really surprises me is that OnLostDevice and OnDestroyDevice called after WinMain terminates. Is there a way to force these event to fire before the end of WinMain? I want my myFramework object to handle lost device events, so its myFramework::OnLostDevice method is called from the DXUT event handler, but either I delete the object after the main loop and can't handle the final lost and destroy device, or I can handle the events, but can't delete the object. Or is it okay to put the clean-up part to OnDestroyDevice, since there won't be "recovering" after that? Thanks, shinjin

Share this post


Link to post
Share on other sites
Advertisement
What does the call stack tell you? my guess is that a global is being destroyed and calling those functions as part of its destructor chain.

Share this post


Link to post
Share on other sites
Quote:
Original post by crshinjin
This is the call stack:
call stack

Didn't get me any further.

"GetDXUTState dynamic atexit destructor" shows that it's a global that's being destroyed. What object is being destroyed there? Is it a global in DXUT, or one you created? Can you clean it up before exiting WinMain() (By calling a Cleanup() or Release() function or something)?

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
"GetDXUTState dynamic atexit destructor" shows that it's a global that's being destroyed. What object is being destroyed there? Is it a global in DXUT, or one you created? Can you clean it up before exiting WinMain() (By calling a Cleanup() or Release() function or something)?


It's part of the DXUT framework.

In the meantime I've realized that DXUTShutdown doesn't actually terminate the program, as the documentation implies, just preform DXUT clean-up. Exactly what I was looking for.

So calling DXUTShutdown after the main loop solved my problem.

(But it raises the question, if there is a "nice way" to quit from an event hanlder and avoiding stuff like SendMessage( hWnd, WM_CLOSE, 0, 0 );)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!