We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 907 - SDL window restore SDL_VIDEORESIZE event issue...
Summary: SDL window restore SDL_VIDEORESIZE event issue...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 1.2.14
Hardware: x86 Windows Vista
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-14 20:32 UTC by cjj_009
Modified: 2011-12-30 03:02 UTC (History)
0 users

See Also:


Attachments
Simple C++ openGL/SDL program to demonstrate SDL_VIDEORESIZE issue (2.79 MB, application/zip)
2009-12-14 20:32 UTC, cjj_009
Details
Proposed patch for SDL_resize.c (821 bytes, patch)
2010-03-28 15:15 UTC, vgvgf
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cjj_009 2009-12-14 20:32:35 UTC
Created attachment 464 [details]
Simple C++ openGL/SDL program to demonstrate SDL_VIDEORESIZE issue

I've been working on an SDL/OpenGL program, that among other things, must deal
with resizing events in order to adjust the aspect ratio.
It doesn't always seem to get the SDL_VIDEORESIZE event when it should, causing
the aspect ratio to not be adjusted as needed.

I've run it in debug mode and made these observations:
*When it initially starts up, if I maximize the window, it receives the
SDL_VIDEORESIZE event as needed.
*If, after starting up the the application and maximizing the window, I then
restore the window by double clicking the title bar, it does NOT receive the
SDL_VIDEORESIZE event.
*I can repeat the last two steps, and it will get continue to get the
SDL_VIDEORESIZE on the maximize but not get one on the restore.
*If I then do a slight adjustment to the width or height of the window, it will
get the SDL_VIDEORESIZE event.
*From then on, if I do restore operations to the window, the SDL_VIDEORESIZE
event will be caught properly.

I included a simple Open GL rotating pyramid program to demonstrate the
problem, written in Visual C++ 2008 Express.  The steps above should produce
the error, in which case you will see an incorrect aspect ratio on the scene. 
A Win32 function to create a message box is included at the problem point, but
remarked out.  Uncomment it if you wish to use it.

See http://forums.libsdl.org/viewtopic.php?t=5291 for additional information.
See the attached Visual Studio solution (includes one .cpp file) for the
example program.
Comment 1 vgvgf 2010-03-28 15:15:16 UTC
Created attachment 502 [details]
Proposed patch for SDL_resize.c

The width and height values stored in SDL_VideoSurface are the sizes of the video surface when it was created. So, when the window is rezised back to its creation size, the following condition will make the SDL_PrivateResize function stop, and the video resize msg won't be queued.
if ( ! SDL_VideoSurface ||
     ((w == SDL_VideoSurface->w) && (h == SDL_VideoSurface->h)) ) {
	return(0);
}
Comment 2 Sam Lantinga 2011-12-30 02:59:51 UTC
I'm okay with applying this patch, but be aware that the expected response to a resize message is that you call SDL_SetVideoMode() again with the new mode.  This signals SDL that you're expecting the new size, and there may be other problems if you don't do this.
Comment 3 Sam Lantinga 2011-12-30 03:02:27 UTC
The patch is in, thanks!
http://hg.libsdl.org/SDL/rev/f56b95794ac8