Some SDL/OpenGL Win32 ResizeEvent hack !?

There was a major problem for me using SDL+OpenGL on Win2k:

The std method for resizing a window (re-calling SDL_SetVideoMode())
re-creates the OpenGL context flushing all textures, etc. this way…

Now I found some work-around, which seems to make the SDL_SetVideoMode()
call obsolete & is fine for me:

Catch the respective SDL_ResizeEvent and write new width & height into
SDL_GetVideoSurface()'s result (don’t forget to adjust glViewport) -
yes, I know: this surface pointer is supposed to be read-only - but hey,
it works!

Is this work-around documented somewhere ? Does it work for any other
Win32 platforms ?

Cheers,
zimerman

There was a major problem for me using SDL+OpenGL on Win2k:

The std method for resizing a window (re-calling SDL_SetVideoMode())
re-creates the OpenGL context flushing all textures, etc. this way…

Now I found some work-around, which seems to make the SDL_SetVideoMode()
call obsolete & is fine for me:

Catch the respective SDL_ResizeEvent and write new width & height into
SDL_GetVideoSurface()'s result (don’t forget to adjust glViewport) -
yes, I know: this surface pointer is supposed to be read-only - but hey,
it works!

Is this work-around documented somewhere ?
probably not
Does it work for any other
Win32 platforms ?
i can’t test win32; i modified a NeHe/SDL/Linux demo to do what you said
and it kind of works. it is cut off beyond the original width (possibly
a problem with pitch?) and it looks like the gl viewport is messed up.
But the window resizes with the same context, so I think this is a Sort
of Working™ here. I’m running SuSE linux 10.1 with commercial nvidia
drivers.On Wed, 2006-06-28 at 10:52 +0200, Johannes Zimmermann wrote:

Cheers,
zimerman


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Is this work-around documented somewhere ? Does it work for any other
Win32 platforms ?

Nope, this is quite platform dependent. On win32, you can get away with
this hack. On x11 you have to call SDL_SetVideoMode, but it doesn’t
recreate your context. And on OS X you have to call SDL_SetVideoMode and
reload everything in your context.

There has been discussion on introducing some way of telling whether the
context was recreated, but it isn’t available anywhere yet AFAIK. Another
improvement would to rewrite the backends to keep the old context as long
as possible, but this still requires some way of knowing whether it
actually was recreated. Hopefully we’ll see some of this in 1.3?

// MartinOn Wed, 28 Jun 2006, Johannes Zimmermann wrote: