Sign in to follow this  
GlassBil

OpenGL SDL fullscreen toggle turns blank

Recommended Posts

I have problems with toggeling to fullscreen. I've read that SDL_WM_ToggleFullScreen doesn't work on Windows, so I made that into a special case. I have no problems entering fullscreen in my init of the window by using the code: flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_RESIZABLE | SDL_HWSURFACE; int tmpFlags = flags; if(fs) { tmpFlags ^= SDL_FULLSCREEN; } // Create the window screen = SDL_SetVideoMode(w, h, wbpp, tmpFlags); If fs is set it enters fullscreen and renders properly. However, when I toggle the fullscreen with: if(!SDL_WM_ToggleFullScreen(screen)) { // SDL_WM_ToggleFullScreen not supported. Set SDL_SetVideoMode again. int tmpFlags = flags | SDL_FULLSCREEN; if(fullscreen) { tmpFlags ^= SDL_FULLSCREEN; } // Create the window screen = SDL_SetVideoMode(width, height, bpp, tmpFlags); } it goes into fullscreen mode but it's just blank. (screen, flags, width, height and bpp are private variables in my class). Any ideas what I'm doing wrong?

Share this post


Link to post
Share on other sites
The first thing I noticed when looking at your code is that the video flags appear to be incorrect. SDL_GL_DOUBLEBUFFER is intended to be used with the 'set attribute' function, not as a video flag. Also, I don't think SDL_HWSURFACE is necessary when creating an OpenGL rendering context.

I don't know if this is what's causing the problem you describe, but you might start by fixing the video flags, and see if that makes any difference.

Share this post


Link to post
Share on other sites
Quote:
http://sdl.beuc.net/sdl.wiki/SDL_SetVideoMode
User note 2: Also note that, in Windows, setting the video mode resets the current OpenGL context. You must execute again the OpenGL initialization code (set the clear color or the shade model, or reload textures, for example) after calling SDL_SetVideoMode. In Linux, however, it works fine, and the initialization code only needs to be executed after the first call to SDL_SetVideoMode (although there is no harm in executing the initialization code after each call to SDL_SetVideoMode, for example for a multiplatform application).

Also...
Quote:
Original post by jyk
The first thing I noticed when looking at your code is that the video flags appear to be incorrect. SDL_GL_DOUBLEBUFFER is intended to be used with the 'set attribute' function, not as a video flag. Also, I don't think SDL_HWSURFACE is necessary when creating an OpenGL rendering context.

I don't know if this is what's causing the problem you describe, but you might start by fixing the video flags, and see if that makes any difference.

This same mistake was recently made by somebody else here. Is there some tutorial that does this?

Share this post


Link to post
Share on other sites
Thanks for poiting out my errors. I think that I have to do the OpenGL initialization again. That's probably why I get a blank screen. But you'd think that the next buffer swap would fix that for you. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by GlassBil
Thanks for poiting out my errors. I think that I have to do the OpenGL initialization again. That's probably why I get a blank screen. But you'd think that the next buffer swap would fix that for you. :)


I found that I had to re-do the gl init, but my textures were intact.

SDL is getting slammed for this but once you know about it - it's not a problem to cope with it.

Just my 2c.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this