Window resizes

i’m calling SDL_SetVideoMode with SDL_OPENGL and SDL_RESIZABLE.

when i resize, i call a new set video mode with the new size. the call seems to fail, strangely, but the app doesn’t seem to care. the problem, tho, is that this seems to invalidate my opengl handles (like textures). i can remove the set video call and things still run (on my machine, anyway) but the mouse events only seem to register in the “old size” area of the window. that is, if my initial size is 800x600, mouse events beyond those bounds are clipped to 799, 599.

i find it interesting that on my machine at least, i don’t need to call the set video mode on resize to actually make things work (aside from the mouse problem). and really, the set video mode has always reported a failure (tho it seems to work). am i just not doing things correctly? is the set video mode resize not as important for opengl buffers?

Miles Vignol wrote:

i’m calling SDL_SetVideoMode with SDL_OPENGL and SDL_RESIZABLE.

when i resize, i call a new set video mode with the new size. the
call seems to fail, strangely, but the app doesn’t seem to care. the
problem, tho, is that this seems to invalidate my opengl handles (like
textures). i can remove the set video call and things still run (on
my machine, anyway) but the mouse events only seem to register in the
"old size" area of the window. that is, if my initial size is
800x600, mouse events beyond those bounds are clipped to 799, 599.

i find it interesting that on my machine at least, i don’t need to
call the set video mode on resize to actually make things work (aside
from the mouse problem). and really, the set video mode has always
reported a failure (tho it seems to work). am i just not doing things
correctly? is the set video mode resize not as important for opengl
buffers?

That’s how it works, after a window resize, the OpenGL state can be lost
(that depends on the platform). So it’ll happen sometimes, and you have
to recreate the window. That means you have to recreate the full OpenGL
state (textures, buffers…) after a resize.

Also notice that this happens with every OpenGL software out there,
that’s not specific to OpenGL (for example, that’s why enemy territory
has to do a full reload after a video mode change).

Stephane

Miles Vignol wrote:

i’m calling SDL_SetVideoMode with SDL_OPENGL and SDL_RESIZABLE.

when i resize, i call a new set video mode with the new size. the
call seems to fail, strangely, but the app doesn’t seem to care. the
problem, tho, is that this seems to invalidate my opengl handles (like
textures). i can remove the set video call and things still run (on
my machine, anyway) but the mouse events only seem to register in the
"old size" area of the window. that is, if my initial size is
800x600, mouse events beyond those bounds are clipped to 799, 599.

i find it interesting that on my machine at least, i don’t need to
call the set video mode on resize to actually make things work (aside
from the mouse problem). and really, the set video mode has always
reported a failure (tho it seems to work). am i just not doing things
correctly? is the set video mode resize not as important for opengl
buffers?

That’s how it works, after a window resize, the OpenGL state can be lost
(that depends on the platform). So it’ll happen sometimes, and you have
to recreate the window. That means you have to recreate the full OpenGL
state (textures, buffers…) after a resize.

Also notice that this happens with every OpenGL software out there,
that’s not specific to OpenGL (for example, that’s why enemy territory
has to do a full reload after a video mode change).

Stephane

thanks for the reply. i’m still grappling with how best to deal with this
issue. so far, i’m just creating a window of a large size and letting user
resize without calling setVideoMode. this way, the window still thinks it’s
larger than it really is so my mouse events are correct. works on my 2k
machine with an ATI card and my xp machine with an nVidia card. i’m not
changing bit depth or going to fullscreen or anything – just changing the
window size. it’s a drag that i can’t just change the window parameters (x
and y size namely) without destroying and recreating my opengl context. but
like i said, this method works so far.From: stephane.marchesin@wanadoo.fr (Stephane Marchesin)