Dealing with ALT-Tab Switching on Windows

I am developing a Windows based game, and now need to handle Alt-Tab
switching. In SDL 1.2 we used to get DeviceLost errors. At that point we
would reload all the textures, etc.

However, now the DX9 Renderer seems to handle device lost errors by itself,
and uses Managed Textures, so on the face of it, I need to do nothing to
handle Alt-Tab switching. The DX9 renderer tries to reset the device once
it is lost (which is the only way to make it operational again). The DX9
specs say that Managed Textures are flushed from VRAM when a device is
reset, but I would imagine it should not be a issue, as DX driver could
simply reload them from the system RAM copy it maintains for Managed
Textures.

However, I just get a black screen when I try Alt-Tab switching a
FULLSCREEN app, or if I lock the screen using WindowsKey + L and then
unlock.

Any clues to what I should do?–
Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768

Interestingly, I have found the following:

  1. If I compile SDL2.dll on my Win8 box, with Visual C++ Express 2012,
    I have no issues with Alt-Tab switching at all. SDL2 performs as
    expected. However, I face another problem. The game only runs when run
    via VC++ debugger. When I try to run it by double clicking, it crashes
    somewhere in the SDL Timer thread in SDL_Init().

  2. If I drop in SDL2.dll compiled elsewhere into the project, the game
    runs fine from both debugger and otherwise. However, ALT-Tab switching
    leads to screen becoming blank.

I get the feeling I am making some mistake in my SDL compile, but I
can’t put a finger to it :(On 11/16/2013 8:56 AM, Pallav Nawani wrote:

I am developing a Windows based game, and now need to handle Alt-Tab
switching. In SDL 1.2 we used to get DeviceLost errors. At that point
we would reload all the textures, etc.

However, now the DX9 Renderer seems to handle device lost errors by
itself, and uses Managed Textures, so on the face of it, I need to do
nothing to handle Alt-Tab switching. The DX9 renderer tries to reset
the device once it is lost (which is the only way to make it
operational again). The DX9 specs say that Managed Textures are
flushed from VRAM when a device is reset, but I would imagine it
should not be a issue, as DX driver could simply reload them from the
system RAM copy it maintains for Managed Textures.

However, I just get a black screen when I try Alt-Tab switching a
FULLSCREEN app, or if I lock the screen using WindowsKey + L and then
unlock.

Any clues to what I should do?


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768


Pallav Nawani
Game Designer/CEO
http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming

Are you using Render Targets? Those are not restored automagically IIRC
because they are not implemented with managed textures.

2013/11/16 Pallav Nawani > I am developing a Windows based game, and now need to handle Alt-Tab

switching. In SDL 1.2 we used to get DeviceLost errors. At that point we
would reload all the textures, etc.

However, now the DX9 Renderer seems to handle device lost errors by
itself, and uses Managed Textures, so on the face of it, I need to do
nothing to handle Alt-Tab switching. The DX9 renderer tries to reset the
device once it is lost (which is the only way to make it operational
again). The DX9 specs say that Managed Textures are flushed from VRAM when
a device is reset, but I would imagine it should not be a issue, as DX
driver could simply reload them from the system RAM copy it maintains for
Managed Textures.

However, I just get a black screen when I try Alt-Tab switching a
FULLSCREEN app, or if I lock the screen using WindowsKey + L and then
unlock.

Any clues to what I should do?


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768


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


Gabriel.

Yes, I am using render targets in fact. Is there a way to determine that
directx device has been lost?On Sat, Nov 16, 2013 at 5:30 PM, Gabriel Jacobo wrote:

Are you using Render Targets? Those are not restored automagically IIRC
because they are not implemented with managed textures.

2013/11/16 Pallav Nawani <@Pallav_Nawani>

I am developing a Windows based game, and now need to handle Alt-Tab
switching. In SDL 1.2 we used to get DeviceLost errors. At that point we
would reload all the textures, etc.

However, now the DX9 Renderer seems to handle device lost errors by
itself, and uses Managed Textures, so on the face of it, I need to do
nothing to handle Alt-Tab switching. The DX9 renderer tries to reset the
device once it is lost (which is the only way to make it operational
again). The DX9 specs say that Managed Textures are flushed from VRAM when
a device is reset, but I would imagine it should not be a issue, as DX
driver could simply reload them from the system RAM copy it maintains for
Managed Textures.

However, I just get a black screen when I try Alt-Tab switching a
FULLSCREEN app, or if I lock the screen using WindowsKey + L and then
unlock.

Any clues to what I should do?


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768


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


Gabriel.


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


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768

I don’t think so, it’s something I’ve been meaning to do since forever,
send a message when this sort of situation occurs (which can happen in
OpenGL too, specially on mobile platforms).

2013/11/16 Pallav Nawani > Yes, I am using render targets in fact. Is there a way to determine that

directx device has been lost?

On Sat, Nov 16, 2013 at 5:30 PM, Gabriel Jacobo <@Gabriel_Jacobo> wrote:

Are you using Render Targets? Those are not restored automagically IIRC
because they are not implemented with managed textures.

2013/11/16 Pallav Nawani

I am developing a Windows based game, and now need to handle Alt-Tab
switching. In SDL 1.2 we used to get DeviceLost errors. At that point we
would reload all the textures, etc.

However, now the DX9 Renderer seems to handle device lost errors by
itself, and uses Managed Textures, so on the face of it, I need to do
nothing to handle Alt-Tab switching. The DX9 renderer tries to reset the
device once it is lost (which is the only way to make it operational
again). The DX9 specs say that Managed Textures are flushed from VRAM when
a device is reset, but I would imagine it should not be a issue, as DX
driver could simply reload them from the system RAM copy it maintains for
Managed Textures.

However, I just get a black screen when I try Alt-Tab switching a
FULLSCREEN app, or if I lock the screen using WindowsKey + L and then
unlock.

Any clues to what I should do?


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768


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


Gabriel.


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


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768


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


Gabriel.