[SDL] Target textures getting randomly swapped on window resize !!

Eric Wing ewmailing at gmail.com
Fri Sep 23 15:42:05 PDT 2016


On 9/23/16, sgrsgsrg <thephanoo at gmail.com> wrote:
> Got rid of the problem by regenerating all target textures on window
> resize.
>
> Is there a way to avoid doing that ? This 'glitch' isnt documented anywhere,
> and there is no fun handling that
>

You didn't say anything about what operating system and video card you
are using, nor which renderer backend. I'll speculate that you are on
Windows and by default, you use the Direct3D backend which is very
susceptible to losing your textures on various window events. (OpenGL
tends to be a little more resilient in my experience.)

Unfortunately, you must handle this. However, this is documented and
there are two SDL events you should look for.

SDL_RENDER_TARGETS_RESET and SDL_RENDER_DEVICE_RESET. When these
events occur, this is when you should reload your textures.

https://wiki.libsdl.org/SDL_EventType


-Eric


More information about the SDL mailing list