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_RenderCopy stretch loses proportion on viewport boundaries #964

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

SDL_RenderCopy stretch loses proportion on viewport boundaries #964

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

@SDLBugzilla SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Linux, x86

Comments on the original bug report:

On 2013-07-13 07:51:43 +0000, driedfruit wrote:

Created attachment 1225
minimal test case

SDL_RenderCopy clips dstrect against the viewport. Then it adjusts the
srcrect by "appropriate" amount of pixels. This amount is actually
wrong, quite a lot, because of the rounding errors introduced in the "*
factor / factor" scale.

        real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
        real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;

For example:

I have a 32 x 32 srcrect and a 64 x 64 dstrect. So far the
stretching is done perfectly, by a factor of 2.

Now, consider dstrect being clipped against the viewport, so it becomes
56 x 64. Now, the factor becomes 1.75 ! The adjustment to "srcrect"
can't handle this, cause srcrect is in integers.

And thus we now have incorrect mapping, with dstrect not being in the
right proportion to srcrect.

The problem is most evident when upscaling stuff, like displaying a 8x8
texture with a zoom of 64 or more, and moving it beyond the corners of
the screen. It looks really really bad.

Note: RenderCopyEX does no such clipping, and is right to do so. The fix would be to remove any such clipping from RenderCopy too. And then fix the software renderer, because it has the same fault, independently of RenderCopy.

On 2013-07-13 08:38:11 +0000, driedfruit wrote:

Created attachment 1226
proposed patch

this leaves Software Renderer buggy, as it does it's own clipping later on

On 2013-08-01 12:17:34 +0000, Sam Lantinga wrote:

This patch is applied, which fixes it for the 3D renderers.
http://hg.libsdl.org/SDL/rev/c128ed448c30

I'm leaving this bug open for the software renderer to be fixed post 2.0 release.
You can reproduce it by taking the test case and running:
SDL_RENDER_DRIVER=software ./rect

Thanks!

@1bsyl 1bsyl closed this as completed Jan 28, 2022
1bsyl added a commit that referenced this issue Jan 29, 2022
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

2 participants