README-hg.txt
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2013 09:15:36 -0700
changeset 7563 c128ed448c30
parent 7241 28602f5ca96d
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
     1 The latest development version of SDL is available via Mercurial.
     2 Mercurial allows you to get up-to-the-minute fixes and enhancements;
     3 as a developer works on a source tree, you can use "hg" to mirror that
     4 source tree instead of waiting for an official release. Please look
     5 at the Mercurial website ( http://mercurial.selenic.com/ ) for more
     6 information on using hg, where you can also download software for
     7 Mac OS X, Windows, and Unix systems.
     8 
     9   hg clone http://hg.libsdl.org/SDL
    10 
    11 If you are building SDL with an IDE, you will need to copy the file
    12 include/SDL_config.h.default to include/SDL_config.h before building.
    13 
    14 If you are building SDL via configure, you will need to run autogen.sh
    15 before running configure.
    16 
    17 There is a web interface to the subversion repository at:
    18 
    19 	http://hg.libsdl.org/SDL/
    20 
    21 There is an RSS feed available at that URL, for those that want to
    22 track commits in real time.
    23