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 40 - Inform applications about OpenGL context recreation
Summary: Inform applications about OpenGL context recreation
Status: RESOLVED ENDOFLIFE
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 1.2
Hardware: All All
: P2 API change
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL: http://www.devolution.com/pipermail/s...
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-10 17:10 UTC by Patrice Mandin
Modified: 2015-08-25 09:38 UTC (History)
1 user (show)

See Also:


Attachments
Definition of a flag for screen surface, and example setting it for x11 driver (1.95 KB, patch)
2006-02-07 16:58 UTC, Patrice Mandin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patrice Mandin 2006-01-10 17:10:05 UTC
Not all OpenGL implementations used by SDL destroy and recreate the OpenGL context  when SDL_SetVideoMode() is called, or when the application window is resized.

My proposal was to add two things in SDL:
- Set a bit in SDL_Surface screen flag that tells that the OpenGL context has been kept (leave it to zero if context has been destroyed, so all current applications still don't care about it).
- Add a new event to tell that the OpenGL context has been destroyed and recreated. This is when the window is resized, because the application does not   call SDL_SetVideoMode() in this case.

Currently some applications has some #ifdef WIN32 part of code to force reloading everything related to the OpenGL context (textures, display lists, etc...) when either SDL_SetVideoMode() is called or the application window is resized. This topic is platform-dependent, so it should be hidden inside SDL.

The topic comes back once in a while, see an older one:
http://www.devolution.com/pipermail/sdl/2004-November/065847.html
Comment 1 Ryan C. Gordon 2006-01-27 11:23:13 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 2 Patrice Mandin 2006-02-07 16:58:11 UTC
Created attachment 70 [details]
Definition of a flag for screen surface, and example setting it for x11 driver

OK, here is the small patch. I add a new flag for the SDL_Surface screen
flag. The flag is cleared before calling any <driver>_SetVideoMode. Then
it is the responsibility of the driver to set the flag if the OpenGL
context has been kept (not destroyed). I added the small patch for the
x11 driver. Then, the application can check this bit to see if the
OpenGL context has been destroyed or not. So now we can have:

- Old applications with new SDL: Don't care about the bit
- New applications with old SDL: Always see the bit as zero, so behave
the same.
- New applications with new SDL: What we intended.

Both windib and windx5 always destroy the context, I don't know about
other video drivers. At least, for my part (using OSMesa on Atari),
simply resizing the context does not destroy it, so I will do this part
myself.

Also, it seems there is no need for a special event, as SDL_VIDEORESIZE
only tell about the new size, and the application must call
SDL_SetVideoMode().

Of course, any comments are welcomed.
Comment 3 Ryan C. Gordon 2006-02-07 20:42:03 UTC
My only concern is that it's possible to lose hardware surfaces on Windows completely outside the control of your application...are we SURE there's no time other than SetVideoMode where the GL context can be lost?

--ryan.

Comment 4 Sam Lantinga 2006-02-08 12:28:01 UTC
(In reply to comment #3)
> My only concern is that it's possible to lose hardware surfaces on Windows
> completely outside the control of your application...are we SURE there's no
> time other than SetVideoMode where the GL context can be lost?

I believe that's the case, and even when the window is resized it isn't lost, it's only when the fullscreen video mode changes, which is under the application's control.

I'd like to hold off on this patch, in the hope that we can have different code paths for window resizing and setting new video modes in SDL 1.3.  Currently everyone always re-creates their OpenGL state when they call SDL_SetVideoMode(), which is the safe thing to do.

Comment 5 Gerry JJ 2006-02-16 11:16:21 UTC
(In reply to comment #4)
> I believe that's the case, and even when the window is resized it isn't lost,
> it's only when the fullscreen video mode changes, which is under the
> application's control.

What happens if the SDL app runs in a window while a *different* app switches the fullscreen video mode ?
Comment 6 Ryan C. Gordon 2011-12-30 00:29:46 UTC
I'm going to close this as WONTFIX for 1.2, since the 1.3 API handles this properly, and I don't think we should make changes like this to 1.2 at this point.

--ryan.
Comment 7 Ryan C. Gordon 2015-08-25 09:38:22 UTC
Hello, and sorry if you're getting several copies of this message by email, since we are closing many bugs at once here.

We have decided to mark all SDL 1.2-related bugs as RESOLVED ENDOFLIFE, as we don't intend to work on SDL 1.2 any further, but didn't want to mark a large quantity of bugs as RESOLVED WONTFIX, to clearly show what was left unattended to and make it easily searchable.

Our current focus is on SDL 2.0.

If you are still having problems with an ENDOFLIFE bug, your absolute best option is to move your program to SDL2, as it will likely fix the problem by default, and give you access to modern platforms and tons of super-cool new features.

Failing that, we _will_ accept small patches to fix these issues, and put them in revision control, although we do not intend to do any further official 1.2 releases.

Failing that, please feel free to contact me directly by email (icculus@icculus.org) and we'll try to find some way to help you out of your situation.

Thank you,
--ryan.