Makefile.in
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2013 09:15:36 -0700
changeset 7563 c128ed448c30
parent 7387 85303f85cb70
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
     1 # Makefile to build and install the SDL library
     2 
     3 top_builddir = .
     4 srcdir  = @srcdir@
     5 objects = build
     6 prefix = @prefix@
     7 exec_prefix = @exec_prefix@
     8 bindir	= @bindir@
     9 libdir  = @libdir@
    10 includedir = @includedir@
    11 datarootdir = @datarootdir@
    12 datadir	= @datadir@
    13 auxdir	= @ac_aux_dir@
    14 distpath = $(srcdir)/..
    15 distdir = SDL2-@SDL_VERSION@
    16 distfile = $(distdir).tar.gz
    17 
    18 @SET_MAKE@
    19 SHELL	= @SHELL@
    20 CC      = @CC@
    21 INCLUDE = @INCLUDE@
    22 CFLAGS  = @BUILD_CFLAGS@
    23 EXTRA_CFLAGS = @EXTRA_CFLAGS@
    24 LDFLAGS = @BUILD_LDFLAGS@
    25 EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
    26 LIBTOOL = @LIBTOOL@
    27 INSTALL = @INSTALL@
    28 AR	= @AR@
    29 RANLIB	= @RANLIB@
    30 WINDRES	= @WINDRES@
    31 
    32 TARGET  = libSDL2.la
    33 OBJECTS = @OBJECTS@
    34 VERSION_OBJECTS = @VERSION_OBJECTS@
    35 
    36 SDLMAIN_TARGET = libSDL2main.a
    37 SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
    38 
    39 SDLTEST_TARGET = libSDL2_test.a
    40 SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
    41 
    42 SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake configure configure.in debian include Makefile.* sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test VisualC.html VisualC Xcode Xcode-iOS
    43 GEN_DIST = SDL2.spec
    44 
    45 HDRS = \
    46 	SDL.h \
    47 	SDL_assert.h \
    48 	SDL_atomic.h \
    49 	SDL_audio.h \
    50     SDL_bits.h \
    51 	SDL_blendmode.h \
    52 	SDL_clipboard.h \
    53 	SDL_cpuinfo.h \
    54 	SDL_endian.h \
    55 	SDL_error.h \
    56 	SDL_events.h \
    57 	SDL_gamecontroller.h \
    58 	SDL_gesture.h \
    59 	SDL_haptic.h \
    60 	SDL_hints.h \
    61 	SDL_joystick.h \
    62 	SDL_keyboard.h \
    63 	SDL_keycode.h \
    64 	SDL_loadso.h \
    65 	SDL_log.h \
    66 	SDL_main.h \
    67 	SDL_messagebox.h \
    68 	SDL_mouse.h \
    69 	SDL_mutex.h \
    70 	SDL_name.h \
    71 	SDL_opengl.h \
    72 	SDL_opengles.h \
    73 	SDL_opengles2.h \
    74 	SDL_pixels.h \
    75 	SDL_platform.h \
    76 	SDL_power.h \
    77 	SDL_quit.h \
    78 	SDL_rect.h \
    79 	SDL_render.h \
    80 	SDL_rwops.h \
    81 	SDL_scancode.h \
    82 	SDL_shape.h \
    83 	SDL_stdinc.h \
    84 	SDL_surface.h \
    85 	SDL_system.h \
    86 	SDL_syswm.h \
    87 	SDL_thread.h \
    88 	SDL_timer.h \
    89 	SDL_touch.h \
    90 	SDL_types.h \
    91 	SDL_version.h \
    92 	SDL_video.h \
    93 	begin_code.h \
    94 	close_code.h
    95 
    96 SDLTEST_HDRS = $(shell ls $(srcdir)/include | fgrep SDL_test)
    97 
    98 LT_AGE      = @LT_AGE@
    99 LT_CURRENT  = @LT_CURRENT@
   100 LT_RELEASE  = @LT_RELEASE@
   101 LT_REVISION = @LT_REVISION@
   102 LT_LDFLAGS  = -no-undefined -rpath $(DESTDIR)$(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
   103 
   104 all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
   105 
   106 $(srcdir)/configure: $(srcdir)/configure.in
   107 	@echo "Warning, configure.in is out of date"
   108 	#(cd $(srcdir) && sh autogen.sh && sh configure)
   109 	@sleep 3
   110 
   111 Makefile: $(srcdir)/Makefile.in
   112 	$(SHELL) config.status $@
   113 
   114 Makefile.in:;
   115 
   116 $(objects):
   117 	$(SHELL) $(auxdir)/mkinstalldirs $@
   118 
   119 update-revision:
   120 	$(SHELL) $(auxdir)/updaterev.sh
   121 
   122 .PHONY: all update-revision install install-bin install-hdrs install-lib install-data uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data clean distclean dist $(OBJECTS:.lo=.d)
   123 
   124 $(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
   125 	$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
   126 
   127 $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
   128 	$(AR) cru $@ $(SDLMAIN_OBJECTS)
   129 	$(RANLIB) $@
   130 
   131 $(objects)/$(SDLTEST_TARGET): $(SDLTEST_OBJECTS)
   132 	$(AR) cru $@ $(SDLTEST_OBJECTS)
   133 	$(RANLIB) $@
   134 
   135 install: all install-bin install-hdrs install-lib install-data
   136 install-bin:
   137 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(bindir)
   138 	$(INSTALL) -m 755 sdl2-config $(DESTDIR)$(bindir)/sdl2-config
   139 install-hdrs: update-revision
   140 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(includedir)/SDL2
   141 	for file in $(HDRS) $(SDLTEST_HDRS); do \
   142 	    $(INSTALL) -m 644 $(srcdir)/include/$$file $(DESTDIR)$(includedir)/SDL2/$$file; \
   143 	done
   144 	$(INSTALL) -m 644 include/SDL_config.h $(DESTDIR)$(includedir)/SDL2/SDL_config.h
   145 	if test -f include/SDL_revision.h; then \
   146 	    $(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL2/SDL_revision.h; \
   147 	else \
   148 	    $(INSTALL) -m 644 $(srcdir)/include/SDL_revision.h $(DESTDIR)$(includedir)/SDL2/SDL_revision.h; \
   149 	fi
   150 
   151 install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
   152 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)
   153 	$(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET)
   154 	$(INSTALL) -m 644 $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
   155 	$(RANLIB) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
   156 	$(INSTALL) -m 644 $(objects)/$(SDLTEST_TARGET) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
   157 	$(RANLIB) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
   158 install-data:
   159 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(datadir)/aclocal
   160 	$(INSTALL) -m 644 $(srcdir)/sdl2.m4 $(DESTDIR)$(datadir)/aclocal/sdl2.m4
   161 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
   162 	$(INSTALL) -m 644 sdl2.pc $(DESTDIR)$(libdir)/pkgconfig
   163 
   164 uninstall: uninstall-bin uninstall-hdrs uninstall-lib uninstall-data
   165 uninstall-bin:
   166 	rm -f $(DESTDIR)$(bindir)/sdl2-config
   167 uninstall-hdrs:
   168 	for file in $(HDRS) $(SDLTEST_HDRS); do \
   169 	    rm -f $(DESTDIR)$(includedir)/SDL2/$$file; \
   170 	done
   171 	rm -f $(DESTDIR)$(includedir)/SDL2/SDL_config.h
   172 	rm -f $(DESTDIR)$(includedir)/SDL2/SDL_revision.h
   173 	-rmdir $(DESTDIR)$(includedir)/SDL2
   174 uninstall-lib:
   175 	$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(TARGET)
   176 	rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
   177 	rm -f $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
   178 uninstall-data:
   179 	rm -f $(DESTDIR)$(datadir)/aclocal/sdl2.m4
   180 	rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl2.pc
   181 
   182 clean:
   183 	rm -rf $(objects)
   184 	if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
   185 
   186 distclean: clean
   187 	rm -f Makefile Makefile.rules sdl2-config
   188 	rm -f config.status config.cache config.log libtool
   189 	rm -rf $(srcdir)/autom4te*
   190 	find $(srcdir) \( \
   191 	    -name '*~' -o \
   192 	    -name '*.bak' -o \
   193 	    -name '*.old' -o \
   194 	    -name '*.rej' -o \
   195 	    -name '*.orig' -o \
   196 	    -name '.#*' \) \
   197 	    -exec rm -f {} \;
   198 	if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
   199 
   200 dist $(distfile):
   201 	$(SHELL) $(auxdir)/mkinstalldirs $(distdir)
   202 	(cd $(srcdir); tar cf - $(SRC_DIST)) | (cd $(distdir); tar xf -)
   203 	tar cf - $(GEN_DIST) | (cd $(distdir); tar xf -)
   204 	find $(distdir) \( \
   205 	    -name '*~' -o \
   206 	    -name '*.bak' -o \
   207 	    -name '*.old' -o \
   208 	    -name '*.rej' -o \
   209 	    -name '*.orig' -o \
   210 	    -name '.#*' \) \
   211 	    -exec rm -f {} \;
   212 	if test -f $(distdir)/test/Makefile; then (cd $(distdir)/test && make distclean); fi
   213 	(cd $(distdir); build-scripts/updaterev.sh)
   214 	tar cvf - $(distdir) | gzip --best >$(distfile)
   215 	rm -rf $(distdir)
   216 
   217 rpm: $(distfile)
   218 	rpmbuild -ta $?