README.txt
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2013 09:15:36 -0700
changeset 7563 c128ed448c30
parent 7359 96ac247b672e
child 7599 bd0c15431dc9
permissions -rw-r--r--
Fixed bug 1968 - SDL_RenderCopy stretch loses proportion on viewport boundaries for 3D renderers

driedfruit

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.

[attached patch]
this leaves Software Renderer buggy, as it does it's own clipping later on
slouken@7222
     1
slouken@7222
     2
                         Simple DirectMedia Layer
slouken@7222
     3
slouken@7222
     4
                                  (SDL)
slouken@7222
     5
slouken@7222
     6
                                Version 2.0
slouken@7222
     7
slouken@7222
     8
---
slouken@7222
     9
http://www.libsdl.org/
slouken@7222
    10
slouken@7359
    11
Simple DirectMedia Layer is a cross-platform development library designed
slouken@7359
    12
to provide low level access to audio, keyboard, mouse, joystick, and graphics
slouken@7359
    13
hardware via OpenGL and DirectX. It is used by video playback software,
slouken@7359
    14
emulators, and popular games including Valve's award winning catalog
slouken@7359
    15
and many Humble Bundle games.
slouken@7222
    16
slouken@7359
    17
The current version supports Windows, Mac OS X, Linux, iOS, and Android.
slouken@7359
    18
The code contains support for other operating systems but those are not
slouken@7359
    19
officially supported.
slouken@7222
    20
slouken@7222
    21
SDL is written in C, but works with C++ natively, and has bindings to
slouken@7359
    22
several other languages, including C#, Python and more in progress.
slouken@7222
    23
slouken@7222
    24
This library is distributed under the zlib license, which can be found
slouken@7330
    25
in the file "COPYING.txt".
slouken@7222
    26
slouken@7222
    27
The best way to learn how to use SDL is to check out the header files in
slouken@7222
    28
the "include" subdirectory and the programs in the "test" subdirectory.
slouken@7222
    29
The header files and test programs are well commented and always up to date.
philipp@7241
    30
More documentation and FAQs are available online at:
slouken@7222
    31
	http://wiki.libsdl.org/
slouken@7222
    32
slouken@7222
    33
If you need help with the library, or just want to discuss SDL related
slouken@7222
    34
issues, you can join the developers mailing list:
slouken@7222
    35
	http://www.libsdl.org/mailing-list.php
slouken@7222
    36
slouken@7222
    37
Enjoy!
slouken@7222
    38
	Sam Lantinga				(slouken@libsdl.org)
slouken@7222
    39