Mercurial > sdl-ios-xcode
view build-scripts/makedep.sh @ 3333:b334b4f7dfa0
[SDL] Bad math in SDL_RenderCopy
Mason Wheeler to sdl
When I tried to render an image using something other than NULL for srcrect, it got horribly distorted. I traced it down to the fact that the math in the rectangle adjustments performed just before the call to renderer->RenderCopy is written inside out. It should look like this:
if (dstrect->w != real_dstrect.w) {
int deltax = (dstrect->x - real_dstrect.x);
int deltaw = (dstrect->w - real_dstrect.w);
real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;
}
if (dstrect->h != real_dstrect.h) {
int deltay = (dstrect->y - real_dstrect.y);
int deltah = (dstrect->h - real_dstrect.h);
real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h;
real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h;
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 03 Oct 2009 16:23:16 +0000 |
parents | 93994f65c74c |
children |
line wrap: on
line source
#!/bin/sh # # Generate dependencies from a list of source files # Check to make sure our environment variables are set if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$output" = x; then echo "SOURCES, INCLUDE, and output needs to be set" exit 1 fi cache_prefix=".#$$" generate_var() { echo $1 | sed -e 's|^.*/||' -e 's|\.|_|g' } search_deps() { base=`echo $1 | sed 's|/[^/]*$||'` grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \ while read file do cache=${cache_prefix}_`generate_var $file` if test -f $cache; then : # We already ahve this cached else : >$cache for path in $base `echo $INCLUDE | sed 's|-I||g'` do dep="$path/$file" if test -f "$dep"; then echo " $dep \\" >>$cache search_deps $dep >>$cache break fi done fi cat $cache done } :>${output}.new for src in $SOURCES do echo "Generating dependencies for $src" ext=`echo $src | sed 's|.*\.\(.*\)|\1|'` if test x"$ext" = x"rc"; then obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"` else obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"` fi echo "\$(objects)/$obj: $src \\" >>${output}.new search_deps $src | sort | uniq >>${output}.new case $ext in c) cat >>${output}.new <<__EOF__ \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ __EOF__ ;; cc) cat >>${output}.new <<__EOF__ \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ __EOF__ ;; m) cat >>${output}.new <<__EOF__ \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ __EOF__ ;; S) cat >>${output}.new <<__EOF__ \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ __EOF__ ;; rc) cat >>${output}.new <<__EOF__ \$(WINDRES) $src \$@ __EOF__ ;; *) echo "Unknown file extension: $ext";; esac echo "" >>${output}.new done mv ${output}.new ${output} rm -f ${cache_prefix}*