Fixed bug where the render target is updated instead of the default output when the window is resized.
authorSam Lantinga <slouken@libsdl.org>
Sun, 17 Aug 2014 14:34:41 -0700
changeset 9084a8cbb653aea4
parent 9083 029f8d643dbe
child 9085 7cafa57c23ec
Fixed bug where the render target is updated instead of the default output when the window is resized.
src/render/SDL_render.c
     1.1 --- a/src/render/SDL_render.c	Sun Aug 17 13:49:53 2014 -0700
     1.2 +++ b/src/render/SDL_render.c	Sun Aug 17 14:34:41 2014 -0700
     1.3 @@ -115,6 +115,12 @@
     1.4              }
     1.5  
     1.6              if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
     1.7 +                /* Make sure we're operating on the default render target */
     1.8 +                SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
     1.9 +                if (saved_target) {
    1.10 +                    SDL_SetRenderTarget(renderer, NULL);
    1.11 +                }
    1.12 +
    1.13                  if (renderer->logical_w) {
    1.14                      UpdateLogicalSize(renderer);
    1.15                  } else {
    1.16 @@ -140,6 +146,10 @@
    1.17                          renderer->UpdateViewport(renderer);
    1.18                      }
    1.19                  }
    1.20 +
    1.21 +                if (saved_target) {
    1.22 +                    SDL_SetRenderTarget(renderer, saved_target);
    1.23 +                }
    1.24              } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
    1.25                  renderer->hidden = SDL_TRUE;
    1.26              } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
    1.27 @@ -916,12 +926,12 @@
    1.28          SDL_assert(!texture->native);
    1.29          renderer = texture->renderer;
    1.30          SDL_assert(renderer->UpdateTextureYUV);
    1.31 -		if (renderer->UpdateTextureYUV) {
    1.32 -			return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
    1.33 -		} else {
    1.34 -			return SDL_Unsupported();
    1.35 -		}
    1.36 -	}
    1.37 +        if (renderer->UpdateTextureYUV) {
    1.38 +            return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
    1.39 +        } else {
    1.40 +            return SDL_Unsupported();
    1.41 +        }
    1.42 +    }
    1.43  }
    1.44  
    1.45  static int