From 727b4924c851f18107b853286a38cc4965082043 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 25 Jun 2025 09:42:23 -0700
Subject: [PATCH] Update the viewport when logical presentation changes
Fixes https://github.com/libsdl-org/SDL/issues/13256
---
src/render/SDL_render.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 0a088a8b43fc3..60265b81c39f6 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -2743,6 +2743,8 @@ static void UpdateLogicalPresentation(SDL_Renderer *renderer)
view->pixel_h = (int) view->logical_dst_rect.h;
UpdatePixelViewport(renderer, view);
UpdatePixelClipRect(renderer, view);
+ QueueCmdSetViewport(renderer);
+ QueueCmdSetClipRect(renderer);
}
bool SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode)
@@ -3663,7 +3665,7 @@ bool SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count
#endif
SDL_RenderViewState *view = renderer->view;
- const bool islogical = ((view == &renderer->main_view) && (view->logical_presentation_mode != SDL_LOGICAL_PRESENTATION_DISABLED));
+ const bool islogical = (view->logical_presentation_mode != SDL_LOGICAL_PRESENTATION_DISABLED);
if (islogical || (renderer->line_method == SDL_RENDERLINEMETHOD_GEOMETRY)) {
const float scale_x = view->current_scale.x;
@@ -3682,7 +3684,7 @@ bool SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count
int num_indices = 0;
const int size_indices = 4;
int cur_index = -4;
- const int is_looping = (points[0].x == points[count - 1].x && points[0].y == points[count - 1].y);
+ const bool is_looping = (points[0].x == points[count - 1].x && points[0].y == points[count - 1].y);
SDL_FPoint p; // previous point
p.x = p.y = 0.0f;
/* p q
@@ -3714,7 +3716,7 @@ bool SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count
num_indices += 3;
// closed polyline, don“t draw twice the point
- if (i || is_looping == 0) {
+ if (i || !is_looping) {
ADD_TRIANGLE(4, 5, 6)
ADD_TRIANGLE(4, 6, 7)
}