Bug in SDL_resize.c

int SDL_PrivateResize(int w, int h)
{
int posted;
SDL_Event events[32];

/* See if this event would change the video surface */
if ( !w || !h ||
((last_resize.w == w) && (last_resize.h == h)) ) {
return(0);
}

This part seems fine.

last_resize.w = w;
last_resize.h = h;
if ( ! SDL_VideoSurface ||
((w == SDL_VideoSurface->w) && (h == SDL_VideoSurface->h)) ) {
return(0);
}
// Proceed to post SDL_VIDEORESIZE

But this is wrong. Consider creating a resizable window of
given size, for example:

SDL_SetVideoMode(400, 300, 32, SDL_OPENGL|SDL_RESIZABLE);

We’d like to get SDL_VIDEORESIZE every time the size of the
window is changed. But, since SDL_VideoSurface never changes,
we’ll always compare the new size to (640, 480) before
posting the message.

The effect is clearly seen when just maximizing the new
window and then restoring it - we’ll get SDL_VIDEORESIZE
for the max, but not for the restore.

SDL_SetVideoMode(400, 300, 32, SDL_OPENGL|SDL_RESIZABLE);

We’d like to get SDL_VIDEORESIZE every time the size of the
window is changed. But, since SDL_VideoSurface never changes,

Ah, but you need to respond to the resize message by setting
the video mode to the new width and height.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

We’d like to get SDL_VIDEORESIZE every time the size of the
window is changed. But, since SDL_VideoSurface never changes,

Ah, but you need to respond to the resize message by setting
the video mode to the new width and height.

Ah, sorry about that. It’s even in the doc, now that I
look at it again. It just never occurred to me that I’d
have to call something like SetVideoMode() when just
resizing a window. I called glViewPort(), etc, as usual.
And everything worked. Until I started wondering why it
failed in some cases…

Shouldn’t yell “bug!” too often. :wink: