Jump to content
  • Advertisement
Sign in to follow this  
Antrim

Fullscreen Mode and Boost smart pointers

This topic is 4895 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

I decided to try and learn to use some things out of boost while I was working on my DirectX app, and came across a problem with the scoped_ptr. Since I've never used them before, it could just be that I was using the wrong type, or possibly I'm just using it somewhere that a smart pointer doesn't belong. Anyway, my problem is this...I decided to use a global scoped_ptr for my Game class (the one that inits, runs, logic, etc....everything). I coded enough to get my window, Direct3D, and DirectInput working and have the window printing out some stats for me (fps and such). Once this was all working, I tried to test the fullscreen mode, and the program crashed out before fullscreen even toggled. After testing out different things, I found that the crash was occuring in my call to create the D3DDevice. I tested a few other things, to make sure that the Windowed parameter was the only thing causing the crash. After narrowing it down to that, and being completly stumped, I switched from the scoped_ptr to a regular pointer, and all of a sudden, it worked just fine. So what I'm wondering is, does something happen when direct3d transitions to fullscreen mode that is causing the scoped_ptr to be removed? Or is there something else that I'm overlooking? Thanks for any insight, Antrim

Share this post


Link to post
Share on other sites
Advertisement
You've been doing something wrong. A global scoped_ptr will be destroyed when your application's shutting down, not when switching fullscreen. Where exactly was the crash occuring when you were using scoped_ptr's? In the CreateDevice/Reset call?

Share this post


Link to post
Share on other sites
Most likely your pointer is going out of scope, which causes things to get deleted, and then *boom*. Without more information, all I can say is try using a boost::shared_ptr instead and see if things still blow up.

Share this post


Link to post
Share on other sites
Coder, yeah, the crash was happening when the Create call was being made. I'll have to try a shared_ptr as Si suggested tomorrow and see if that was the case.

I was under the impression, the same as you said, that the scoped shouldn't go away until the app shut down. The only thing I could think of was that the fullscreen transition was doing something that made it think that it was going out of scope...but I couldn't think of what that *something* could be.

Thanks for the input, I'll post back when I get a chance to try the shared_ptr.


Antrim

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!