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

Summary: Clipping rectangle behaving incorrectly
Product: SDL Reporter: sieng
Component: *don't know*Assignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.3   
Hardware: x86_64   
OS: Windows 7   
Attachments: Program, image and screenshot

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