[SDL] SDL_VIDEORESIZE, OpenGL, Win32
stanmuffin at hotmail.com
Fri Apr 11 19:56:01 PDT 2003
I am developing a windowed OpenGL application that I've recently ported
from GLUT to SDL so I can take advantage of portable threads, SDL_Net,
etc. I've run into a little hitch in resizing the window--namely, all
OpenGL state is lost as soon as I call SDL_SetVideoMode(). Yes, I know
this has been discussed before--and I know that changing the pixel
format of an OpenGL rendering context on Win32 requires resetting
OpenGL--but simply changing the dimensions of the viewport shouldn't (it
didn't under GLUT, anyhow).
So I guess what I'm asking is, can I just resize the current SDL surface
without having to ditch it and create a new one? I mean, without
resorting to the nasty trickery shown below...
// Holy cow, this is evil. But it seemed to do the trick.
SDL_Surface *surface = SDL_GetVideoSurface();
surface->w = event.resize.w;
surface->h = event.resize.h;
SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_OPENGL
glViewport(0, 0, (GLsizei) event.resize.w, (GLsizei) event.resize.h);
More information about the SDL