In Fullscreen, after 'Alt + Tab', my prog ram just Blank Screen

Hi.

I made a fullscreen with SDL 2.0.

but, i Input ‘Alt + Tab’ to change to desktop, and returned to my program by clicking my program title in task bar.

however, there is just blank (black) screen.

i heard in that case (i heard this is ‘device lost’), the program have to re-create the texture.

so, my question is…

how to check the timing (or event) to re-create the texture??

I think that’s specific to Direct3D. Not sure if OpenGL loses its
textures on video mode change.

Anyway, you can check when the window gains or loses focus if needed.
Look up the SDL_WINDOWEVENT event as well as the SDL_WindowEventID
enumeration.

2013/2/6, ricoh11 :>

Hi.

I made a fullscreen with SDL 2.0.

but, i Input ‘Alt + Tab’ to change to desktop, and returned to my program
by clicking my program title in task bar.

however, there is just blank (black) screen.

i heard in that case (i heard this is ‘device lost’), the program have to
re-create the texture.

so, my question is…

how to check the timing (or event) to re-create the texture??

2013/2/6 ricoh11

Hi.

I made a fullscreen with SDL 2.0.

but, i Input ‘Alt + Tab’ to change to desktop, and returned to my program
by clicking my program title in task bar.

however, there is just blank (black) screen.

i heard in that case (i heard this is ‘device lost’), the program have to
re-create the texture.

so, my question is…

how to check the timing (or event) to re-create the texture??

If you are using Direct3D or OpenGL ES on some Android devices, you may
lose your “context” (device lost in D3D speak) and have to recreate the
textures. We discussed about adding an event to notify the user of this
situation, but never got around to implement it. The Direct3D backend uses
managed textures which should recreate the textures automatically when the
device is lost, however, if you use rendering to textures (
http://wiki.libsdl.org/moin.cgi/SDL_SetRenderTarget), this won’t be the
case as they are not managed. Is this your case?–
Gabriel.

Hi.

I want to re-create texture. because of ‘device lost’ phenomenon.

so, I implemented re-create code when window focus is changed.

below is a my way.
however, the program works below re-create code many times,
texture seems to be displayed crashed and, throws an Access Violation Message in Visual Studio Debugger.

How to Re-create Texture in a safe way???

SDL_Surface * pSurface; //Surface includes my game sprite.
SDL_Texture * pTexture; //Texture includes my surface.

// … Texture was already created but it is crashed because of ‘device lost’

SDL_DestroyTexture ( pTexture ) ;
SDL_CreateTextureFromSurface ( pRenderer, pSurface); // pRender is a Renderer.