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 3922

Summary: Viewport and clip rect getters are broken
Product: SDL Reporter: Daniel <daniel.plakhotich>
Component: renderAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: 2.0.6   
Hardware: x86_64   
OS: Linux   

Description Daniel 2017-10-26 13:00:46 UTC
SDL_RenderGetClipRect() and SDL_RenderGetViewport() are broken due to the lossy math. They don't return original rectangles most of the time.

Consider x coordinate 5 and renderer scale 0.1. SDL_RenderSetClipRect() will truncate it ((int)floor(5 * 0.1)), resulting in renderer->clip_rect.x equal to 0.
When SDL_RenderGetClipRect() will return as (int)(0 / 0.1), resulting in 0.

The same happen with scale > 1.0 - it will usually return 1 px smaller coordinate. When SDL_RenderSetClipRect() and SDL_RenderSetClipRect() calls are chained, the error will accumulate. This makes SDL_RenderGetClipRect() and SDL_RenderGetViewport() completely useless.