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 2179

Summary: SDL_SetRenderLogicalSize behavior is extremely buggy
Product: SDL Reporter: Mason Wheeler <masonwheeler>
Component: renderAssignee: Mason Wheeler <masonwheeler>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: Roung1990
Version: HG 2.1   
Hardware: x86_64   
OS: Windows 7   

Description Mason Wheeler 2013-10-23 23:52:06 UTC
I created the original Logical Size concept in SDL, and provided the API for it and the original OpenGL backend.  It was intended to do only one very simple thing: make an SDL window use a set of logical dimensions that was different from the window's actual size in pixels.

The current implementation is badly broken, as it instead does three things:

1) Creates a region within the window--which may not comprise the entire window if the aspect ratio of the logical size is different from the aspect ratio in real pixels of the window--containing the number of logical pixels specified.
2) Applies letterboxing if the aspect ratio is different
3) Introduces an internal scaling factor which is applied to render operations, meaning that the SDL coordinate system is no longer the same as the raw API coordinate system.  In other words, if the scaling factor != 1.0, a SDL render operation targeting (25,40) and a GL draw operation targeting (25,40) will not render to the same coordinates in the output!

All of this behavior is completely incorrect and undesirable, and needs to be fixed.  Logical Size is supposed to do exactly what it did in my original implementation: create a logical rendering size for the window that is not necessarily the same as the pixel size of the window.
Comment 1 Sam Lantinga 2013-10-24 03:50:14 UTC
1) and 2) are really the same issue, and that behavior is extremely useful for games which have a fixed drawing aspect ratio.  You can definitely create a hint to disable this behavior though.

3) should probably move the scaling down into the render driver level to take advantage of the hardware transform and keep the coordinate system under your control if you want.  Feel free to submit a patch for that.

Thanks!
Comment 2 Mason Wheeler 2013-10-24 21:28:17 UTC
(In reply to Sam Lantinga from comment #1)
> 1) and 2) are really the same issue, and that behavior is extremely useful
> for games which have a fixed drawing aspect ratio.  You can definitely
> create a hint to disable this behavior though.
> 
> 3) should probably move the scaling down into the render driver level to
> take advantage of the hardware transform and keep the coordinate system
> under your control if you want.  Feel free to submit a patch for that.
> 
> Thanks!

The problem is, it will be difficult to fix 3) without also fixing 1) and 2), since the right way to fix 3) is to rip out all of the special calculations that currently implement Logical Size and replace the whole thing with a simple call that redefines the viewport of the rendering window when a logical size is chosen.  But if we do that, how do we also keep the letterboxing?  (Which I still don't think should be kept.  Games that really need that tend to be older, simpler ones that should have plenty of processor power to spare in order to render to a render target and then render that to the screen to implement their own letterboxing.)
Comment 3 Sam Lantinga 2017-08-15 05:15:33 UTC
We're going to revisit this for SDL 2.1.
Comment 4 Kostyarezkiy 2019-08-18 07:13:54 UTC
What ever happened with this? @mason wheeler?