Fixed bug where the render target is updated instead of the default output when the window is resized.

This commit is contained in:
Sam Lantinga 2014-08-17 14:34:41 -07:00
parent f17587df4a
commit 2e3c778ef5

View File

@ -115,6 +115,12 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
} }
if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
/* Make sure we're operating on the default render target */
SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
if (saved_target) {
SDL_SetRenderTarget(renderer, NULL);
}
if (renderer->logical_w) { if (renderer->logical_w) {
UpdateLogicalSize(renderer); UpdateLogicalSize(renderer);
} else { } else {
@ -140,6 +146,10 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
renderer->UpdateViewport(renderer); renderer->UpdateViewport(renderer);
} }
} }
if (saved_target) {
SDL_SetRenderTarget(renderer, saved_target);
}
} else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) { } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
renderer->hidden = SDL_TRUE; renderer->hidden = SDL_TRUE;
} else if (event->window.event == SDL_WINDOWEVENT_SHOWN) { } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {