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 1001

Summary: OpenGL context no longer re-created upon subsequent calls to SDL_SetVideoMode?
Product: SDL Reporter: Sagittaur <SDL>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 1.2.14   
Hardware: x86   
OS: Windows (NT)   

Description Sagittaur 2010-05-09 22:20:09 UTC
I'm not sure if this is a bug or not, but...  Upgrading from 1.2.11 to 1.2.14 broke something in my app:

My app calls SDL_SetVideoMode to create a small SDL+OpenGL window (where user selects window size), then it calls SDL_SetVideoMode again with larger dimensions.  With the older DLL, this worked OK, but with the newer DLL, everything is squished down into the lower left corner of the 2nd window.  The squished rendering area in the 2nd window seems to have the same dimensions as the 1st window.

This does not happen if 2nd window is created fullscreen.

My guess is that the "OpenGL context" was re-created inside SDL_SetVideoMode in the older version, but in the newer version it is retained.

My solution is to call SDL_QuitSubSystem and SDL_InitSubSystem before calling SDL_SetVideoMode the 2nd time.

(Let me know if I have been doing something wrong.)
Comment 1 Ryan C. Gordon 2010-05-10 14:34:38 UTC
There was a change made on Windows to retain the GL context when just resizing the window, since most games would have to reload all their textures, buffers, shaders, state, etc.

Your solution (explicitly restarting the video subsystem) is correct, if you want to reset all the state.

I'd like to make this API more clear in SDL 1.3, though.

--ryan.
Comment 2 Sagittaur 2010-05-10 19:39:44 UTC
Thanks for the response.  This really isn't all a big deal...  I'm just curious to know what I'm missing.

I was still a little confused until I found that I was supposed to call glViewport after SDL_SetVideoMode... as if the window was resizeable and I was handling the event.  Doing so eliminates the need to call SDL_QuitSubSystem and SDL_InitSubSystem.

So now I am just wondering: is this new behavior supposed to be consistent across platforms?