Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_SetRenderLogicalSize behavior is extremely buggy #1164

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 2 comments
Closed

SDL_SetRenderLogicalSize behavior is extremely buggy #1164

SDLBugzilla opened this issue Feb 10, 2021 · 2 comments

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.1
Reported for operating system, platform: Windows 7, x86_64

Comments on the original bug report:

On 2013-10-23 23:52:06 +0000, Mason Wheeler wrote:

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.

On 2013-10-24 03:50:14 +0000, Sam Lantinga wrote:

  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.

  2. 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!

On 2013-10-24 21:28:17 +0000, Mason Wheeler wrote:

(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.

  2. 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.)

On 2017-08-15 05:15:33 +0000, Sam Lantinga wrote:

We're going to revisit this for SDL 2.1.

On 2019-08-18 07:13:54 +0000, Kostyarezkiy wrote:

What ever happened with this? @ mason wheeler?

@sinf
Copy link

sinf commented Apr 5, 2021

I came here because I noticed something while working on 1oom SDL code (on gitlab):

  • Calling both SDL_RenderSetLogicalSize and SDL_RenderSetIntegerScale sometimes results in a viewport 1 pixel too small. So the integer scale not respected as promised.
  • If the aforementioned 2 things are both used and SDL_RenderSetLogicalSize is passed a size smaller than the actual window then viewport (as reported by SDL_RenderGetViewport) becomes -2147483648x-2147483648 so I suppose the integer scale became 0
    This was on SDL 2.0.14. I'll have a look at the code.

@icculus
Copy link
Collaborator

icculus commented Aug 10, 2021

@sinf I'm going to kick this to a new issue and close this old one, which goes back years and is the result of an ongoing disagreement about the nature of this API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants