Jump to content
  • Advertisement
Sign in to follow this  
tentoes

openGL + SDL_SetVideoMode Fullscreen problem

This topic is 3250 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 all, I'm using SDL for window handling (and most other things) but openGL for rendering. I'm getting a problem when I set the window to go fullscreen; half of my textures seem to get lost (the quads just display as solid colour), and the textures that do display seem to lose all of their alpha information. I found various messasges on the sdl mailing list which mentioned that once you go into fullscreen mode with SDL it loses all of the openGL context info so you have to rebuild all your textures every time you change modes. I implemented this and it helped things a tiny bit, but the problem still exists. Strangley, the problem remains once I return to windowed mode (even after a full rebuild of all textures). Does anyone know what I might be doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Are you restoring all states, include things like the blend mode, whether alpha blending is enabled or disabled etc?

I have a feeling that you are only partially recontructing your context, which is causing the issues.

Share this post


Link to post
Share on other sites
:S that was embarrassingly simple!

thanks a lot, it would have taken me a long time to think of that (if indeed I would have thought of it at all).

I'm still having a problem with textures turning to white blocks after fullscreen, but that might may be a separate problem which was getting mixed in with the loss of context.

thanks again.

Share this post


Link to post
Share on other sites
How are you going about reloading your textures? When you reload them they are going to get an entirely new ID and need to be re associated with the quad. Bottom line is you may be heading in the right direction just not be doing it just right. So lets have a look if you don't mind.

Share this post


Link to post
Share on other sites
I managed to fix it.

Here's what was happening:
On video mode change I was rebuilding all textures my main game loop knew about.
Sometime ago I created a little graphical effect to create a trail behind the player, however I am yet to get around to formalising the design for this and currently it's just hacked into the player class and all the textures are kept track of in there, so the main game loop never has any reference to them.

When the textures were getting rebuilt these were left behind.

Now, here's what I *think* may have been the cause, but I am obviously not an openGL expert so I may be quite off:

The trail is built of objects which have their own texture, the objects have a relatively short life time (about 2 seconds), and at the end of their life time they are deleted, and in there destructor, there's a call to glDeleteTextures.
It seems like some of these textures were pointing to IDs which openGL (after the loss of context and recreation of some textures) has now handed over to the new textures, so when glDeleteTextures gets called, it's deleting the new textures.

At one stage I was also rendering some text which also wasn't having it's texture deleted/recreated upon video mode and after the switch some objects would gain the text's texture, which seems to maybe agree with my theory. Really this should have been the big clue for me :)

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.

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!