Jump to content
  • Advertisement
Sign in to follow this  
lost_wolf

OpenGL SDL Fullscreen

This topic is 4327 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 was just wondering, is it possible to switch between fullscreen and windowed mode in SDL and reinitialize OpenGL without having to reload all the textures?

Share this post


Link to post
Share on other sites
Advertisement
Don't think so!

When you swap fullscreen/windowed mode you get a whole new OpenGL context. So the old one (which had all your texture info in it) is lost. If there is a way todo it then I for one have never found it!

Share this post


Link to post
Share on other sites
If I want to switch between fullscreen and window, or if I want to change resolution I just call something like this.

/* use one of them */
flags = SDL_OPENGL | SDL_FULLSCREEN;
flags = SDL_OPENGL;
if( SDL_SetVideoMode( width, height, bpp, flags ) == 0 ) {

fprintf( stderr, "Video mode set failed: %s\n",SDL_GetError( ) );

return 0;

}
glViewport(0, 0, width, height);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();


gluPerspective(angle, 1.0f*width/height, 1.0f, 1000.0f);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();


It works perfectly for me. I wonder if the textures are copied again to the video memory when doing a SDL_SetVideoMode. Anything I can say is that the textures are not lost. So I think they are left in Video Memory. But I am not a SDL-expert.

rotalever

Share this post


Link to post
Share on other sites
OpenGL textures are destroyed when you destroy and recreate the OpenGL context (which you must do to switch between windowed and fullscreen). A particular implementation may not "erase" the texture data from VRAM so you'll probably have something left there but it'll be unsafe to use. It'll eventually be overwritten by something else.

Share this post


Link to post
Share on other sites
Really? I thought SDL just changes the window dimensions, but as I said I am not an expert. If this is true, I should use another method... Anyway it never causes error.

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!