SDL Fullscreen

Started by
3 comments, last by rotalever 17 years, 7 months ago
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?
It is not god who created us. But us who created god, for we are the ones with the power to create and destroy entire universes, we are the ones with the power to imagine and forget.
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!
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
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.
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.

This topic is closed to new replies.

Advertisement