Textures are destroyed after window resize?

Hello, well apparently I have this issue when I have to resize my window with SDL_SetWindowSize(), but trying to render a texture generated dynamically to my window appears not to work. (the texture is generated from bunch of textures with SDL_RenderCopy() and rederer targeting a SDL_TEXTUREACCESS_TARGET flagged texture)
Is there a way for me to solve this issue ?

P.S: I might sound like a looser but I am stuck on this for a couple of days … It really gets on my nerves now, so someone helping me to get around this will get a huge blessings package from my side.

I’m not sure if this helps, but I think you first have to pass SDL_WINDOW_RESIZABLE to the window flags of SDL_CreateWindow (the last parameter of the function).

That does not fix the issue. It has something to do with the renderer allocated for the window.
Rendering the same texture right before resizing works just fine.

What I have tried: Setting renderer view port after resizing to match the window;
creating a new texture so I can render the “destroyed” texture on - then rendering that to the window, still it does not work.

You have to reload/recreate your textures after a window resize. The underlying context is destroyed and a new one created… You want to setup a window size change routine that unloads textures then reloads and re-creates textures after the resize.

What do you mean by “The underlying context is destroyed and a new one created”, can you go more into details?
Reloading/recreating textures on the fly when window is resized sound like a lot “heavy weight lifting”, just for that simple operation. It seems so illogical for me that this should be the way to go.
Isn’t there a better way?

Indeed. What OS/platform are you using? The only precaution I take when resizing my window is to deselect the target texture beforehand and then reselect it afterwards:

SDL_Texture *target = SDL_GetRenderTarget (renderer) ;
SDL_SetRenderTarget (renderer, NULL) ;
SDL_SetWindowSize (window, width, height) ;
SDL_SetRenderTarget (renderer, target) ;

Apart from that I have not found it necessary to “recreate textures after a window resize”.

Hmm… I am on MS Windows.
Well what my texture wrapper class is doing when constructing is generating the said texture by targeting it with the renderer, copying certain textures above then returning the target back to NULL - default target.
So when I am resizing I am not targeting the texture.

On Windows I force the OpenGL backend, I don’t know whether that makes a difference (I wouldn’t have expected it to):

SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");