SDL icon indicating copy to clipboard operation
SDL copied to clipboard

TestWM with scale 2 uses only a quarter of the window

Open Dragon-Baroque opened this issue 1 year ago • 3 comments

SDL3 as of 1ca45c58912aaa2c02e0f143d36d7f171e5afbb5, Linux, Video driver X11 ( default ) or Wayland ( by SDL_VIDEO_DRIVER ) :

testwm --scale 2 printouts are truncated to the upper left quarter of the window :

TestWM

Dragon-Baroque avatar Oct 05 '24 13:10 Dragon-Baroque

Seems like the render viewport needs to be adjusted to the scale: https://github.com/libsdl-org/SDL/blob/1ca45c58912aaa2c02e0f143d36d7f171e5afbb5/test/testwm.c#L228-L233

diff --git a/test/testwm.c b/test/testwm.c
index c92cd98bb..fd792e4e5 100644
--- a/test/testwm.c
+++ b/test/testwm.c
@@ -230,6 +230,10 @@ static void loop(void)
 
             SDL_SetRenderViewport(renderer, NULL);
             SDL_GetRenderSafeArea(renderer, &viewport);
+            if (state->scale != 0.0f) {
+                viewport.w = (int)(viewport.w * state->scale);
+                viewport.h = (int)(viewport.h * state->scale);
+            }
             SDL_SetRenderViewport(renderer, &viewport);
 
             SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);

This is just a guess. No idea if this is the intended way to fix this.

Sackzement avatar Oct 05 '24 14:10 Sackzement

This is just a guess. No idea if this is the intended way to fix this.

Nope, thanks but it needs to be fixed inside SDL.

Thanks!

slouken avatar Oct 05 '24 16:10 slouken

As a surprise to no one, I bisected this bug and it's 54459def695b2fea70d9ef01585cae5e162f3f72 (the removal of logical presentation render targets) that broke things. I'll fix that up.

icculus avatar Oct 18 '24 01:10 icculus