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 - Viewport and clip rect getters are broken
Summary: Viewport and clip rect getters are broken
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.6
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-26 13:00 UTC by Daniel
Modified: 2017-10-26 21:41 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.