SDL/src/render
Sam Lantinga a082c12fd1 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
2013-08-01 09:15:36 -07:00
..
direct3d Fixed compiler warning with gcc 2013-07-30 00:02:45 -07:00
opengl Updated blend semantics so blending uses the following formula: 2013-07-23 08:06:49 -07:00
opengles Updated blend semantics so blending uses the following formula: 2013-07-23 08:06:49 -07:00
opengles2 Updated blend semantics so blending uses the following formula: 2013-07-23 08:06:49 -07:00
psp File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
software Fixed bug updating the clip rect for the software renderer 2013-06-27 11:27:19 -07:00
mmx.h Made it possible to create a texture of any format, even if not supported by the renderer. 2011-02-03 00:19:40 -08:00
SDL_render.c Fixed bug 1968 - SDL_RenderCopy stretch loses proportion on viewport boundaries for 3D renderers 2013-08-01 09:15:36 -07:00
SDL_sysrender.h When the window is resized, the viewport is automatically reset. 2013-05-29 03:22:19 -07:00
SDL_yuv_mmx.c File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
SDL_yuv_sw_c.h Happy New Year! 2013-02-15 08:47:44 -08:00
SDL_yuv_sw.c Include SDL_assert.h to fix broken build. 2013-07-20 21:22:37 -04:00