Makefile.minimal
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2013 09:15:36 -0700
changeset 7563 c128ed448c30
parent 5310 a9945ce48999
child 7667 be1cc6f55840
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@1484
     1
# Makefile to build the SDL library
slouken@1484
     2
slouken@1484
     3
INCLUDE = -I./include
slouken@1484
     4
CFLAGS  = -g -O2 $(INCLUDE)
slouken@1484
     5
AR	= ar
slouken@1484
     6
RANLIB	= ranlib
slouken@1484
     7
slouken@1484
     8
TARGET  = libSDL.a
slouken@1484
     9
SOURCES = \
slouken@1484
    10
	src/*.c \
slouken@1484
    11
	src/audio/*.c \
slouken@5310
    12
	src/audio/dummy/*.c \
slouken@1484
    13
	src/cpuinfo/*.c \
slouken@1484
    14
	src/events/*.c \
slouken@1484
    15
	src/file/*.c \
slouken@5310
    16
	src/haptic/*.c \
slouken@5310
    17
	src/haptic/dummy/*.c \
slouken@1484
    18
	src/joystick/*.c \
slouken@5310
    19
	src/joystick/dummy/*.c \
slouken@5310
    20
	src/loadso/dummy/*.c \
slouken@5310
    21
	src/power/*.c \
slouken@5310
    22
	src/render/*.c \
slouken@5310
    23
	src/render/software/*.c \
slouken@1484
    24
	src/stdlib/*.c \
slouken@1484
    25
	src/thread/*.c \
slouken@5310
    26
	src/thread/generic/*.c \
slouken@1484
    27
	src/timer/*.c \
slouken@5310
    28
	src/timer/dummy/*.c \
slouken@1484
    29
	src/video/*.c \
slouken@1484
    30
	src/video/dummy/*.c \
slouken@1484
    31
slouken@1484
    32
OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
slouken@1484
    33
slouken@1484
    34
all: $(TARGET)
slouken@1484
    35
slouken@5310
    36
$(TARGET): $(OBJECTS)
slouken@1484
    37
	$(AR) crv $@ $^
slouken@1484
    38
	$(RANLIB) $@
slouken@1484
    39
slouken@1484
    40
clean:
slouken@1484
    41
	rm -f $(TARGET) $(OBJECTS)