SDL2: Recovering from alt-tabbing in full-screen mode - HOW?

Since my previous question about OpenGL and SDL 1.2 (https://forums.libsdl.org/viewtopic.php?t=12014) got no replies, I bit the bullet and implemented SDL2 support for my game. However, results were not quite what I expected.

First of all, some players still report the OpenGL bug is still there - sometimes when they go back to game they get GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 after every GL operation. What should be done about this? Is there any way to recover from this or is SDL2 not usable for all Windows platforms with OpenGL?

To make things worse, there are now new problems with the SDL mode, too. I learned the hard way that textures that are used as render targets are lost when alt-tabbing away and back. And this time, there doesn’t seem to be any way of noticing the situation. With SDL 1.2, when blit returned -2 I could reload all textures but now there doesn’t seem to be any solid way of knowing when things have gone wrong. SDL_SetRenderTarget fails when the game is in background but when it is brought back in, all RenderCopys and SetRenderTargets return success even though they don’t work. There even isn’t the old way of knowing if the app is active (SDL_GetAppState() & SDL_APPACTIVE) so it is very confusing for me to understand how this should really be handled. If I just listen to window focus event it doesn’t guarantee render targets work already.

I made a horrible hack where I have a dummy texture I keep putting as render target in every frame and when it starts failing, I delete it and in every frame after that try to recreate it, assuming that when it succeeds and can be put as a target again it is time to recreate all other render targets, too. But this surely cannot be the right way to do it right?

There should be events that notify you when target textures need to be
updated or recreated. See https://wiki.libsdl.org/SDL_EventType

SDL_RENDER_TARGETS_RESET
the render targets have been reset and their contents need to be updated
(>= SDL 2.0.2)

SDL_RENDER_DEVICE_RESET
the device has been reset and all textures need to be recreated (>= SDL
2.0.4)

Since I do not use render targets in my own application, I cannot say how
well that works, however.

In general, it seems the SDL community is smaller these days. Havn’t
received much input to my own mails either.

Kai

Since my previous question about OpenGL and SDL 1.2 (
https://forums.libsdl.org/viewtopic.php?t=12014) got no replies, I bit the
bullet and implemented SDL2 support for my game. However, results were not
quite what I expected.

First of all, some players still report the OpenGL bug is still there -
sometimes when they go back to game they get
GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 after every GL operation. What
should be done about this? Is there any way to recover from this or is SDL2
not usable for all Windows platforms with OpenGL?

To make things worse, there are now new problems with the SDL mode, too.
I learned the hard way that textures that are used as render targets are
lost when alt-tabbing away and back. And this time, there doesn’t seem to
be any way of noticing the situation. With SDL 1.2, when blit returned -2 I
could reload all textures but now there doesn’t seem to be any solid way of
knowing when things have gone wrong. SDL_SetRenderTarget fails when the
game is in background but when it is brought back in, all RenderCopys and
SetRenderTargets return success even though they don’t work. There even
isn’t the old way of knowing if the app is active (SDL_GetAppState() &
SDL_APPACTIVE) so it is very confusing for me to understand how this should
really be handled. If I just listen to window focus event it doesn’t
guarantee render targets work already.

I made a horrible hack where I have a dummy texture I keep putting as
render target in every frame and when it starts failing, I delete it and in
every frame after that try to recreate it, assuming that when it succeeds
and can be put as a target again it is time to recreate all other render
targets, too. But this surely cannot be the right way to do it right?On Fri, Jul 22, 2016 at 3:45 PM, Ande wrote:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thank you! I had missed all that in the documentation.

Too bad every application still has to take care of those manually. It seems that won’t solve the OpenGL issue as release notes tell DEVICE_RESET is sent only for windows D3D.

Thank you! I had missed all that in the documentation.

Took me a while to find them there as well, even though I knew they had to
be there :slight_smile:

Too bad every application still has to take care of those manually. It
seems that won’t
solve the OpenGL issue as release notes tell DEVICE_RESET is sent only
for
windows D3D.

That’s my understanding as well.

Personally, I have no experience with OpenGL (under Windows or else), so no
idea where your (users) problem originates from. But looks more like a
shoddy video driver and not especially related to the combination of SDL +
OpenGL as such.

KaiOn Fri, Jul 22, 2016 at 4:53 PM, Ande wrote: