-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Milestone
Description
From https://discourse.libsdl.org/t/wrong-sdl-rendergetcliprect-sdl-rendersetcliprect-behaviour/35373:
After upgrading from 2.0.12 to 2.0.22 I got a strange glitch.
After some investigation, I wrote simple code to reproduce the error.
float scale = float(2048) / float(1920); //window size.x = 2048, logical size.x =1920
SDL_RenderSetScale(renderer, scale, scale);
SDL_Rect clip = { 0, 0, 1920, 1080 };
SDL_RenderSetClipRect(renderer, &clip);
SDL_Rect new_clip;
SDL_RenderGetClipRect(renderer, &new_clip);
printf("before: %d %d %d %d\n", clip.x, clip.y, clip.w, clip.h);
printf("after : %d %d %d %d\n", new_clip.x, new_clip.y, new_clip.w, new_clip.h);
prints
before: 0 0 1920 1080
after : 0 0 1919 1080
Problem occurs because SDL_RenderGetClipRect uses SDL_floor for calculating dimensions (w/h).