From f8e1874d01ab7439cedd4b8aa9a9e94d2d6dfafa Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 13 Aug 2017 22:50:23 -0700 Subject: [PATCH] Fixed bug 2646 - Problems with software renderer when SDL_SetRenderLogicalSize set Fixed setting the software renderer clip rectangle when a viewport is set --- src/render/software/SDL_render_sw.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index e8d323b8a..62b680edc 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -371,9 +371,14 @@ SW_UpdateClipRect(SDL_Renderer * renderer) SDL_Surface *surface = data->surface; if (surface) { if (renderer->clipping_enabled) { - SDL_SetClipRect(surface, &renderer->clip_rect); + SDL_Rect clip_rect; + clip_rect = renderer->clip_rect; + clip_rect.x += renderer->viewport.x; + clip_rect.y += renderer->viewport.y; + SDL_IntersectRect(&renderer->viewport, &clip_rect, &clip_rect); + SDL_SetClipRect(surface, &clip_rect); } else { - SDL_SetClipRect(surface, NULL); + SDL_SetClipRect(surface, &renderer->viewport); } } return 0;