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 239

Summary: Window resize, OpenGL context lost idea
Product: SDL Reporter: Achille Peternier <apeternier>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED WONTFIX QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2    
Version: 1.2.9   
Hardware: x86   
OS: Windows (All)   

Description Achille Peternier 2006-05-23 11:12:39 UTC
Hi, I'm still surprised by the lack of a simple SDL_ResizeVideo function allowing to dynamically resize the window (under Windows, under other OSs I dunno) without loosing the current OpenGL context. So I simply added a function to SDL and it works! Why not implementing something similar in the official release? Here my perhaps naive solution, but perfectly working on every PC I tested so far (quite a lot of different HW configurations):

/*
 * Update only the size of the window, without killing any context
 */
void SDL_ResizeVideoMode(int width, int height)
{
   SDL_VideoDevice *video = current_video;	
   video->screen->h = height;
   video->screen->w = width;

	/* Reset the mouse cursor and grab for new video mode */
	video->UpdateMouse(video);	
}

I just have to call that when I receive a SDL_RESIZE event, after I modified the  glViewport. 

Dunno if this is a dirty and ugly solution for you, but it always worked for me and every time I update my SDL lib, I've to modify the SDL source code just to add this func. Pls let me know if there's a better way to get that and don't hesistate to tell me that I'm a dumb wheel reinventor! ;)
Comment 1 Sam Lantinga 2006-06-19 23:53:33 UTC
Proper OpenGL resizing support is planned for SDL 1.3, thanks for the idea though!