We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2927 - Clipping rectangle behaving incorrectly
Summary: Clipping rectangle behaving incorrectly
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.3
Hardware: x86_64 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-28 20:43 UTC by sieng
Modified: 2015-05-29 02:00 UTC (History)
0 users

See Also:


Attachments
Program, image and screenshot (39.00 KB, application/zip)
2015-03-28 20:43 UTC, sieng
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sieng 2015-03-28 20:43:44 UTC
Created attachment 2100 [details]
Program, image and screenshot

When running the attached program, the clipping rectangle behaves incorrectly. The right border of the clipping rectangle is 16 or 17 logical pixels to the left of where it should be. The top, bottom and left borders of the clipping rectangle work as expected.
Comment 1 sieng 2015-03-29 20:03:29 UTC
UPDATE:
I think I found a fix. In file SDL_render.c, SDL_RenderSetClipRect, the following lines:

renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x);
renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y);

should be:

renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x + renderer->viewport.x);

renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y + renderer->viewport.y);


I modified my program so that I could better visualize the clipping rectangle and then experimented with all sorts of resolutions and clipping rectangles, with both SDL_WINDOW_FULLSCREEN_DESKTOP and SDL_WINDOW_FULLSCREEN, with SetLogicalSize and without it, and it seems to work fine. I'm not familiar with SDL's codebase though, so I may have messed something around.
Comment 2 Sam Lantinga 2015-05-29 02:00:31 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/1d13a878b066