summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGraydon, Tracy <tracy.graydon@intel.com>2012-11-28 19:43:53 -0800
committerGraydon, Tracy <tracy.graydon@intel.com>2012-11-28 19:43:53 -0800
commit55af18608e149dd3930e420014068df6fe416552 (patch)
tree3d85f5ddc0de53fce59b0a8a4dcd9891e58a43eb /test
downloadSDL-55af18608e149dd3930e420014068df6fe416552.tar.gz
SDL-55af18608e149dd3930e420014068df6fe416552.tar.bz2
SDL-55af18608e149dd3930e420014068df6fe416552.zip
Initial commit for Tizensubmit/1.0/20121129.034415
Diffstat (limited to 'test')
-rw-r--r--test/COPYING8
-rw-r--r--test/Makefile.in117
-rw-r--r--test/README35
-rw-r--r--test/acinclude.m4181
-rw-r--r--test/aclocal.m4181
-rwxr-xr-xtest/autogen.sh12
-rw-r--r--test/checkkeys.c146
-rwxr-xr-xtest/configure5000
-rw-r--r--test/configure.in105
-rwxr-xr-xtest/gcc-fat.sh134
-rw-r--r--test/graywin.c257
-rw-r--r--test/icon.bmpbin0 -> 578 bytes
-rw-r--r--test/loopwave.c114
-rw-r--r--test/moose.datbin0 -> 56320 bytes
-rw-r--r--test/picture.xbm14
-rw-r--r--test/sail.bmpbin0 -> 15858 bytes
-rw-r--r--test/sample.bmpbin0 -> 69202 bytes
-rw-r--r--test/sample.wavbin0 -> 121946 bytes
-rw-r--r--test/testalpha.c537
-rw-r--r--test/testbitmap.c184
-rw-r--r--test/testblitspeed.c420
-rw-r--r--test/testcdrom.c209
-rw-r--r--test/testcursor.c216
-rw-r--r--test/testdyngl.c209
-rw-r--r--test/testerror.c61
-rw-r--r--test/testfile.c182
-rw-r--r--test/testgamma.c197
-rw-r--r--test/testgl.c856
-rw-r--r--test/testhread.c82
-rw-r--r--test/testiconv.c73
-rw-r--r--test/testjoystick.c188
-rw-r--r--test/testkeys.c25
-rw-r--r--test/testloadso.c71
-rw-r--r--test/testlock.c102
-rw-r--r--test/testoverlay.c594
-rw-r--r--test/testoverlay2.c600
-rw-r--r--test/testpalette.c342
-rw-r--r--test/testplatform.c210
-rw-r--r--test/testsem.c78
-rw-r--r--test/testsprite.c323
-rw-r--r--test/testtimer.c87
-rw-r--r--test/testver.c37
-rw-r--r--test/testvidinfo.c465
-rw-r--r--test/testwin.c377
-rw-r--r--test/testwm.c443
-rw-r--r--test/threadwin.c338
-rw-r--r--test/torturethread.c91
-rw-r--r--test/utf8.txt287
48 files changed, 14188 insertions, 0 deletions
diff --git a/test/COPYING b/test/COPYING
new file mode 100644
index 0000000..c4c27e0
--- /dev/null
+++ b/test/COPYING
@@ -0,0 +1,8 @@
+
+The test programs in this directory tree are for demonstrating and
+testing the functionality of the SDL library, and are placed in the
+public domain.
+
+October 28, 1997
+--
+ Sam Lantinga (slouken@libsdl.org)
diff --git a/test/Makefile.in b/test/Makefile.in
new file mode 100644
index 0000000..7d5bb8b
--- /dev/null
+++ b/test/Makefile.in
@@ -0,0 +1,117 @@
+# Makefile to build the SDL tests
+
+srcdir = @srcdir@
+
+CC = @CC@
+EXE = @EXE@
+CFLAGS = @CFLAGS@
+LIBS = @LIBS@
+
+TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) threadwin$(EXE) torturethread$(EXE) testloadso$(EXE)
+
+all: $(TARGETS)
+
+checkkeys$(EXE): $(srcdir)/checkkeys.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+graywin$(EXE): $(srcdir)/graywin.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+loopwave$(EXE): $(srcdir)/loopwave.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testalpha$(EXE): $(srcdir)/testalpha.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
+
+testbitmap$(EXE): $(srcdir)/testbitmap.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testblitspeed$(EXE): $(srcdir)/testblitspeed.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testcdrom$(EXE): $(srcdir)/testcdrom.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testcursor$(EXE): $(srcdir)/testcursor.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testdyngl$(EXE): $(srcdir)/testdyngl.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testerror$(EXE): $(srcdir)/testerror.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testfile$(EXE): $(srcdir)/testfile.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testgamma$(EXE): $(srcdir)/testgamma.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
+
+testgl$(EXE): $(srcdir)/testgl.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
+
+testhread$(EXE): $(srcdir)/testhread.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testiconv$(EXE): $(srcdir)/testiconv.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testjoystick$(EXE): $(srcdir)/testjoystick.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testkeys$(EXE): $(srcdir)/testkeys.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testlock$(EXE): $(srcdir)/testlock.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testoverlay2$(EXE): $(srcdir)/testoverlay2.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testoverlay$(EXE): $(srcdir)/testoverlay.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testpalette$(EXE): $(srcdir)/testpalette.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
+
+testplatform$(EXE): $(srcdir)/testplatform.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testsem$(EXE): $(srcdir)/testsem.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testsprite$(EXE): $(srcdir)/testsprite.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
+
+testtimer$(EXE): $(srcdir)/testtimer.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testver$(EXE): $(srcdir)/testver.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testvidinfo$(EXE): $(srcdir)/testvidinfo.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testwin$(EXE): $(srcdir)/testwin.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testwm$(EXE): $(srcdir)/testwm.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+threadwin$(EXE): $(srcdir)/threadwin.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+torturethread$(EXE): $(srcdir)/torturethread.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+testloadso$(EXE): $(srcdir)/testloadso.c
+ $(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
+
+clean:
+ rm -f $(TARGETS)
+
+distclean: clean
+ rm -f Makefile
+ rm -f config.status config.cache config.log
+ rm -rf $(srcdir)/autom4te*
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..9cf5659
--- /dev/null
+++ b/test/README
@@ -0,0 +1,35 @@
+
+These are test programs for the SDL library:
+
+ checkkeys Watch the key events to check the keyboard
+ graywin Display a gray gradient and center mouse on spacebar
+ loopwave Audio test -- loop playing a WAV file
+ testalpha Display an alpha faded icon -- paint with mouse
+ testbitmap Test displaying 1-bit bitmaps
+ testblitspeed Tests performance of SDL's blitters and converters.
+ testcdrom Sample audio CD control program
+ testcursor Tests custom mouse cursor
+ testdyngl Tests dynamically loading OpenGL library
+ testerror Tests multi-threaded error handling
+ testfile Tests RWops layer
+ testgamma Tests video device gamma ramp
+ testgl A very simple example of using OpenGL with SDL
+ testhread Hacked up test of multi-threading
+ testiconv Tests international string conversion
+ testjoystick List joysticks and watch joystick events
+ testkeys List the available keyboard keys
+ testloadso Tests the loadable library layer
+ testlock Hacked up test of multi-threading and locking
+ testoverlay Tests the software/hardware overlay functionality.
+ testoverlay2 Tests the overlay flickering/scaling during playback.
+ testpalette Tests palette color cycling
+ testplatform Tests types, endianness and cpu capabilities
+ testsem Tests SDL's semaphore implementation
+ testsprite Example of fast sprite movement on the screen
+ testtimer Test the timer facilities
+ testver Check the version and dynamic loading and endianness
+ testvidinfo Show the pixel format of the display and perfom the benchmark
+ testwin Display a BMP image at various depths
+ testwm Test window manager -- title, icon, events
+ threadwin Test multi-threaded event handling
+ torturethread Simple test for thread creation/destruction
diff --git a/test/acinclude.m4 b/test/acinclude.m4
new file mode 100644
index 0000000..b6df43f
--- /dev/null
+++ b/test/acinclude.m4
@@ -0,0 +1,181 @@
+# Configure paths for SDL
+# Sam Lantinga 9/21/99
+# stolen from Manish Singh
+# stolen back from Frank Belew
+# stolen from Manish Singh
+# Shamelessly stolen from Owen Taylor
+
+dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
+dnl
+AC_DEFUN([AM_PATH_SDL],
+[dnl
+dnl Get the cflags and libraries from the sdl-config script
+dnl
+AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
+ sdl_prefix="$withval", sdl_prefix="")
+AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
+ sdl_exec_prefix="$withval", sdl_exec_prefix="")
+AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
+ , enable_sdltest=yes)
+
+ if test x$sdl_exec_prefix != x ; then
+ sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
+ if test x${SDL_CONFIG+set} != xset ; then
+ SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
+ fi
+ fi
+ if test x$sdl_prefix != x ; then
+ sdl_args="$sdl_args --prefix=$sdl_prefix"
+ if test x${SDL_CONFIG+set} != xset ; then
+ SDL_CONFIG=$sdl_prefix/bin/sdl-config
+ fi
+ fi
+
+ if test "x$prefix" != xNONE; then
+ PATH="$prefix/bin:$prefix/usr/bin:$PATH"
+ fi
+ AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
+ min_sdl_version=ifelse([$1], ,0.11.0,$1)
+ AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
+ no_sdl=""
+ if test "$SDL_CONFIG" = "no" ; then
+ no_sdl=yes
+ else
+ SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
+ SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
+
+ sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+ sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+ sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+ if test "x$enable_sdltest" = "xyes" ; then
+ ac_save_CFLAGS="$CFLAGS"
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ ac_save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"
+dnl
+dnl Now check if the installed SDL is sufficiently new. (Also sanity
+dnl checks the results of sdl-config to some extent
+dnl
+ rm -f conf.sdltest
+ AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SDL.h"
+
+char*
+my_strdup (char *str)
+{
+ char *new_str;
+
+ if (str)
+ {
+ new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
+ strcpy (new_str, str);
+ }
+ else
+ new_str = NULL;
+
+ return new_str;
+}
+
+int main (int argc, char *argv[])
+{
+ int major, minor, micro;
+ char *tmp_version;
+
+ /* This hangs on some systems (?)
+ system ("touch conf.sdltest");
+ */
+ { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
+
+ /* HP/UX 9 (%@#!) writes to sscanf strings */
+ tmp_version = my_strdup("$min_sdl_version");
+ if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+ printf("%s, bad version string\n", "$min_sdl_version");
+ exit(1);
+ }
+
+ if (($sdl_major_version > major) ||
+ (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
+ (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
+ {
+ return 0;
+ }
+ else
+ {
+ printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
+ printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
+ printf("*** best to upgrade to the required version.\n");
+ printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
+ printf("*** to point to the correct copy of sdl-config, and remove the file\n");
+ printf("*** config.cache before re-running configure\n");
+ return 1;
+ }
+}
+
+],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+ CFLAGS="$ac_save_CFLAGS"
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+ fi
+ if test "x$no_sdl" = x ; then
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ AC_MSG_RESULT(no)
+ if test "$SDL_CONFIG" = "no" ; then
+ echo "*** The sdl-config script installed by SDL could not be found"
+ echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
+ echo "*** your path, or set the SDL_CONFIG environment variable to the"
+ echo "*** full path to sdl-config."
+ else
+ if test -f conf.sdltest ; then
+ :
+ else
+ echo "*** Could not run SDL test program, checking why..."
+ CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"
+ AC_TRY_LINK([
+#include <stdio.h>
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{ return 0; }
+#undef main
+#define main K_and_R_C_main
+], [ return 0; ],
+ [ echo "*** The test program compiled, but did not run. This usually means"
+ echo "*** that the run-time linker is not finding SDL or finding the wrong"
+ echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
+ echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+ echo "*** to the installed location Also, make sure you have run ldconfig if that"
+ echo "*** is required on your system"
+ echo "***"
+ echo "*** If you have an old version installed, it is best to remove it, although"
+ echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+ [ echo "*** The test program failed to compile or link. See the file config.log for the"
+ echo "*** exact error that occured. This usually means SDL was incorrectly installed"
+ echo "*** or that you have moved SDL since it was installed. In the latter case, you"
+ echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
+ CFLAGS="$ac_save_CFLAGS"
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+ fi
+ SDL_CFLAGS=""
+ SDL_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(SDL_CFLAGS)
+ AC_SUBST(SDL_LIBS)
+ rm -f conf.sdltest
+])
diff --git a/test/aclocal.m4 b/test/aclocal.m4
new file mode 100644
index 0000000..b6df43f
--- /dev/null
+++ b/test/aclocal.m4
@@ -0,0 +1,181 @@
+# Configure paths for SDL
+# Sam Lantinga 9/21/99
+# stolen from Manish Singh
+# stolen back from Frank Belew
+# stolen from Manish Singh
+# Shamelessly stolen from Owen Taylor
+
+dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
+dnl
+AC_DEFUN([AM_PATH_SDL],
+[dnl
+dnl Get the cflags and libraries from the sdl-config script
+dnl
+AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
+ sdl_prefix="$withval", sdl_prefix="")
+AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
+ sdl_exec_prefix="$withval", sdl_exec_prefix="")
+AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
+ , enable_sdltest=yes)
+
+ if test x$sdl_exec_prefix != x ; then
+ sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
+ if test x${SDL_CONFIG+set} != xset ; then
+ SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
+ fi
+ fi
+ if test x$sdl_prefix != x ; then
+ sdl_args="$sdl_args --prefix=$sdl_prefix"
+ if test x${SDL_CONFIG+set} != xset ; then
+ SDL_CONFIG=$sdl_prefix/bin/sdl-config
+ fi
+ fi
+
+ if test "x$prefix" != xNONE; then
+ PATH="$prefix/bin:$prefix/usr/bin:$PATH"
+ fi
+ AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
+ min_sdl_version=ifelse([$1], ,0.11.0,$1)
+ AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
+ no_sdl=""
+ if test "$SDL_CONFIG" = "no" ; then
+ no_sdl=yes
+ else
+ SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
+ SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
+
+ sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+ sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+ sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+ if test "x$enable_sdltest" = "xyes" ; then
+ ac_save_CFLAGS="$CFLAGS"
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ ac_save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"
+dnl
+dnl Now check if the installed SDL is sufficiently new. (Also sanity
+dnl checks the results of sdl-config to some extent
+dnl
+ rm -f conf.sdltest
+ AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SDL.h"
+
+char*
+my_strdup (char *str)
+{
+ char *new_str;
+
+ if (str)
+ {
+ new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
+ strcpy (new_str, str);
+ }
+ else
+ new_str = NULL;
+
+ return new_str;
+}
+
+int main (int argc, char *argv[])
+{
+ int major, minor, micro;
+ char *tmp_version;
+
+ /* This hangs on some systems (?)
+ system ("touch conf.sdltest");
+ */
+ { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
+
+ /* HP/UX 9 (%@#!) writes to sscanf strings */
+ tmp_version = my_strdup("$min_sdl_version");
+ if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+ printf("%s, bad version string\n", "$min_sdl_version");
+ exit(1);
+ }
+
+ if (($sdl_major_version > major) ||
+ (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
+ (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
+ {
+ return 0;
+ }
+ else
+ {
+ printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
+ printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
+ printf("*** best to upgrade to the required version.\n");
+ printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
+ printf("*** to point to the correct copy of sdl-config, and remove the file\n");
+ printf("*** config.cache before re-running configure\n");
+ return 1;
+ }
+}
+
+],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+ CFLAGS="$ac_save_CFLAGS"
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+ fi
+ if test "x$no_sdl" = x ; then
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ AC_MSG_RESULT(no)
+ if test "$SDL_CONFIG" = "no" ; then
+ echo "*** The sdl-config script installed by SDL could not be found"
+ echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
+ echo "*** your path, or set the SDL_CONFIG environment variable to the"
+ echo "*** full path to sdl-config."
+ else
+ if test -f conf.sdltest ; then
+ :
+ else
+ echo "*** Could not run SDL test program, checking why..."
+ CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"
+ AC_TRY_LINK([
+#include <stdio.h>
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{ return 0; }
+#undef main
+#define main K_and_R_C_main
+], [ return 0; ],
+ [ echo "*** The test program compiled, but did not run. This usually means"
+ echo "*** that the run-time linker is not finding SDL or finding the wrong"
+ echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
+ echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+ echo "*** to the installed location Also, make sure you have run ldconfig if that"
+ echo "*** is required on your system"
+ echo "***"
+ echo "*** If you have an old version installed, it is best to remove it, although"
+ echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+ [ echo "*** The test program failed to compile or link. See the file config.log for the"
+ echo "*** exact error that occured. This usually means SDL was incorrectly installed"
+ echo "*** or that you have moved SDL since it was installed. In the latter case, you"
+ echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
+ CFLAGS="$ac_save_CFLAGS"
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+ fi
+ SDL_CFLAGS=""
+ SDL_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(SDL_CFLAGS)
+ AC_SUBST(SDL_LIBS)
+ rm -f conf.sdltest
+])
diff --git a/test/autogen.sh b/test/autogen.sh
new file mode 100755
index 0000000..939f34c
--- /dev/null
+++ b/test/autogen.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# Regenerate configuration files
+cp acinclude.m4 aclocal.m4
+found=false
+for autoconf in autoconf autoconf259 autoconf-2.59
+do if which $autoconf >/dev/null 2>&1; then $autoconf && found=true; break; fi
+done
+if test x$found = xfalse; then
+ echo "Couldn't find autoconf, aborting"
+ exit 1
+fi
diff --git a/test/checkkeys.c b/test/checkkeys.c
new file mode 100644
index 0000000..8dbb24f
--- /dev/null
+++ b/test/checkkeys.c
@@ -0,0 +1,146 @@
+
+/* Simple program: Loop, watching keystrokes
+ Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to
+ pump the event loop and catch keystrokes.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+static void print_modifiers(void)
+{
+ int mod;
+ printf(" modifiers:");
+ mod = SDL_GetModState();
+ if(!mod) {
+ printf(" (none)");
+ return;
+ }
+ if(mod & KMOD_LSHIFT)
+ printf(" LSHIFT");
+ if(mod & KMOD_RSHIFT)
+ printf(" RSHIFT");
+ if(mod & KMOD_LCTRL)
+ printf(" LCTRL");
+ if(mod & KMOD_RCTRL)
+ printf(" RCTRL");
+ if(mod & KMOD_LALT)
+ printf(" LALT");
+ if(mod & KMOD_RALT)
+ printf(" RALT");
+ if(mod & KMOD_LMETA)
+ printf(" LMETA");
+ if(mod & KMOD_RMETA)
+ printf(" RMETA");
+ if(mod & KMOD_NUM)
+ printf(" NUM");
+ if(mod & KMOD_CAPS)
+ printf(" CAPS");
+ if(mod & KMOD_MODE)
+ printf(" MODE");
+}
+
+static void PrintKey(SDL_keysym *sym, int pressed)
+{
+ /* Print the keycode, name and state */
+ if ( sym->sym ) {
+ printf("Key %s: %d-%s ", pressed ? "pressed" : "released",
+ sym->sym, SDL_GetKeyName(sym->sym));
+ } else {
+ printf("Unknown Key (scancode = %d) %s ", sym->scancode,
+ pressed ? "pressed" : "released");
+ }
+
+ /* Print the translated character, if one exists */
+ if ( sym->unicode ) {
+ /* Is it a control-character? */
+ if ( sym->unicode < ' ' ) {
+ printf(" (^%c)", sym->unicode+'@');
+ } else {
+#ifdef UNICODE
+ printf(" (%c)", sym->unicode);
+#else
+ /* This is a Latin-1 program, so only show 8-bits */
+ if ( !(sym->unicode & 0xFF00) )
+ printf(" (%c)", sym->unicode);
+ else
+ printf(" (0x%X)", sym->unicode);
+#endif
+ }
+ }
+ print_modifiers();
+ printf("\n");
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Event event;
+ int done;
+ Uint32 videoflags;
+
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ videoflags = SDL_SWSURFACE;
+ while( argc > 1 ) {
+ --argc;
+ if ( argv[argc] && !strcmp(argv[argc], "-fullscreen") ) {
+ videoflags |= SDL_FULLSCREEN;
+ } else {
+ fprintf(stderr, "Usage: %s [-fullscreen]\n", argv[0]);
+ quit(1);
+ }
+ }
+
+ /* Set 640x480 video mode */
+ if ( SDL_SetVideoMode(640, 480, 0, videoflags) == NULL ) {
+ fprintf(stderr, "Couldn't set 640x480 video mode: %s\n",
+ SDL_GetError());
+ quit(2);
+ }
+
+ /* Enable UNICODE translation for keyboard input */
+ SDL_EnableUNICODE(1);
+
+ /* Enable auto repeat for keyboard input */
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
+ SDL_DEFAULT_REPEAT_INTERVAL);
+
+ /* Watch keystrokes */
+ done = 0;
+ while ( !done ) {
+ /* Check for events */
+ SDL_WaitEvent(&event);
+ switch (event.type) {
+ case SDL_KEYDOWN:
+ PrintKey(&event.key.keysym, 1);
+ break;
+ case SDL_KEYUP:
+ PrintKey(&event.key.keysym, 0);
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ /* Any button press quits the app... */
+ case SDL_QUIT:
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ }
+
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/configure b/test/configure
new file mode 100755
index 0000000..30b56b6
--- /dev/null
+++ b/test/configure
@@ -0,0 +1,5000 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.63.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+ if (eval ":") 2>/dev/null; then
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+
+ if test $as_have_required = yes && (eval ":
+(as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=\$LINENO
+ as_lineno_2=\$LINENO
+ test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+ test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+ :
+else
+ as_candidate_shells=
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ case $as_dir in
+ /*)
+ for as_base in sh bash ksh sh5; do
+ as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+ done;;
+ esac
+done
+IFS=$as_save_IFS
+
+
+ for as_shell in $as_candidate_shells $SHELL; do
+ # Try only shells that exist, to save several forks.
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+ CONFIG_SHELL=$as_shell
+ as_have_required=yes
+ if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+ (exit $1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+ break
+fi
+
+fi
+
+ done
+
+ if test "x$CONFIG_SHELL" != x; then
+ for as_var in BASH_ENV ENV
+ do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ done
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+ if test $as_have_required = no; then
+ echo This script requires a shell more modern than all the
+ echo shells that I found on your system. Please install a
+ echo modern shell, or manually run the script under such a
+ echo shell if you do have one.
+ { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+ echo No shell found that supports shell functions.
+ echo Please tell bug-autoconf@gnu.org about your system,
+ echo including any error possibly output before this message.
+ echo This can help us improve future autoconf versions.
+ echo Configuration will now proceed without shell functions.
+}
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -p'
+ fi
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+exec 7<&0 </dev/null 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_unique_file="README"
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+GLLIB
+CPP
+XMKMF
+SDL_LIBS
+SDL_CFLAGS
+SDL_CONFIG
+MATHLIB
+EXE
+OSMESA_CONFIG
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+with_sdl_prefix
+with_sdl_exec_prefix
+enable_sdltest
+with_x
+'
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+XMKMF
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { $as_echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { $as_echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+ fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
+ { (exit 1); exit 1; }; } ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; }
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ { $as_echo "$as_me: error: working directory cannot be determined" >&2
+ { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
+ { (exit 1); exit 1; }; }
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
+ { (exit 1); exit 1; }; }
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+X features:
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --disable-sdltest Do not try to compile and run a test SDL program
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)
+ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)
+ --with-x use the X Window System
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ XMKMF Path to xmkmf, Makefile generator for X Window System
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+configure
+generated by GNU Autoconf 2.63
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.63. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test -r "$ac_site_file"; then
+ { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir/../build-scripts; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir/../build-scripts" >&5
+$as_echo "$as_me: error: cannot find install-sh or install.sh in $srcdir/../build-scripts" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+{ $as_echo "$as_me:$LINENO: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+$as_echo "$as_me: error: invalid value of canonical build" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:$LINENO: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+$as_echo "$as_me: error: invalid value of canonical host" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compiler --version >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compiler -v >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compiler -V >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+if test -z "$ac_file"; then
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_compiler_gnu=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ CFLAGS=""
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_c89=$ac_arg
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
+if test "${ac_cv_c_const+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+ /* Ultrix mips cc rejects this. */
+ typedef int charset[2];
+ const charset cs;
+ /* SunOS 4.1.1 cc rejects this. */
+ char const *const *pcpcc;
+ char **ppc;
+ /* NEC SVR4.0.2 mips cc rejects this. */
+ struct point {int x, y;};
+ static struct point const zero = {0,0};
+ /* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in
+ an arm of an if-expression whose if-part is not a constant
+ expression */
+ const char *g = "string";
+ pcpcc = &g + (g ? g-g : 0);
+ /* HPUX 7.0 cc rejects these. */
+ ++pcpcc;
+ ppc = (char**) pcpcc;
+ pcpcc = (char const *const *) ppc;
+ { /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+ if (s) return 0;
+ }
+ { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+ }
+ { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+ }
+ { /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+ }
+ { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+ if (!foo) return 0;
+ }
+ return !cs[0] && !zero.x;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_c_const=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_c_const=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+$as_echo "$ac_cv_c_const" >&6; }
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const /**/
+_ACEOF
+
+fi
+
+
+case "$host" in
+ *-*-cygwin* | *-*-mingw32*)
+ EXE=".exe"
+ MATHLIB=""
+ SYS_GL_LIBS="-lopengl32"
+ ;;
+ *-*-beos* | *-*-haiku*)
+ EXE=""
+ MATHLIB=""
+ SYS_GL_LIBS="-lGL"
+ ;;
+ *-*-darwin* )
+ EXE=""
+ MATHLIB=""
+ SYS_GL_LIBS="-Wl,-framework,OpenGL"
+ ;;
+ *-*-aix*)
+ EXE=""
+ if test x$ac_cv_c_compiler_gnu = xyes; then
+ CFLAGS="-mthreads"
+ fi
+ SYS_GL_LIBS=""
+ ;;
+ *-*-mint*)
+ EXE=""
+ MATHLIB=""
+ # Extract the first word of "osmesa-config", so it can be a program name with args.
+set dummy osmesa-config; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_OSMESA_CONFIG+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ case $OSMESA_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_OSMESA_CONFIG="$OSMESA_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_OSMESA_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_OSMESA_CONFIG" && ac_cv_path_OSMESA_CONFIG="no"
+ ;;
+esac
+fi
+OSMESA_CONFIG=$ac_cv_path_OSMESA_CONFIG
+if test -n "$OSMESA_CONFIG"; then
+ { $as_echo "$as_me:$LINENO: result: $OSMESA_CONFIG" >&5
+$as_echo "$OSMESA_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test "x$OSMESA_CONFIG" = "xyes"; then
+ OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
+ OSMESA_LIBS=`$OSMESA_CONFIG --libs`
+ CFLAGS="$CFLAGS $OSMESA_CFLAGS"
+ SYS_GL_LIBS="$OSMESA_LIBS"
+ else
+ SYS_GL_LIBS="-lOSMesa"
+ fi
+ ;;
+ *)
+ EXE=""
+ MATHLIB="-lm"
+ SYS_GL_LIBS="-lGL"
+ ;;
+esac
+
+
+
+SDL_VERSION=1.2.10
+
+# Check whether --with-sdl-prefix was given.
+if test "${with_sdl_prefix+set}" = set; then
+ withval=$with_sdl_prefix; sdl_prefix="$withval"
+else
+ sdl_prefix=""
+fi
+
+
+# Check whether --with-sdl-exec-prefix was given.
+if test "${with_sdl_exec_prefix+set}" = set; then
+ withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval"
+else
+ sdl_exec_prefix=""
+fi
+
+# Check whether --enable-sdltest was given.
+if test "${enable_sdltest+set}" = set; then
+ enableval=$enable_sdltest;
+else
+ enable_sdltest=yes
+fi
+
+
+ if test x$sdl_exec_prefix != x ; then
+ sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
+ if test x${SDL_CONFIG+set} != xset ; then
+ SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
+ fi
+ fi
+ if test x$sdl_prefix != x ; then
+ sdl_args="$sdl_args --prefix=$sdl_prefix"
+ if test x${SDL_CONFIG+set} != xset ; then
+ SDL_CONFIG=$sdl_prefix/bin/sdl-config
+ fi
+ fi
+
+ if test "x$prefix" != xNONE; then
+ PATH="$prefix/bin:$prefix/usr/bin:$PATH"
+ fi
+ # Extract the first word of "sdl-config", so it can be a program name with args.
+set dummy sdl-config; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_SDL_CONFIG+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ case $SDL_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no"
+ ;;
+esac
+fi
+SDL_CONFIG=$ac_cv_path_SDL_CONFIG
+if test -n "$SDL_CONFIG"; then
+ { $as_echo "$as_me:$LINENO: result: $SDL_CONFIG" >&5
+$as_echo "$SDL_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ min_sdl_version=$SDL_VERSION
+ { $as_echo "$as_me:$LINENO: checking for SDL - version >= $min_sdl_version" >&5
+$as_echo_n "checking for SDL - version >= $min_sdl_version... " >&6; }
+ no_sdl=""
+ if test "$SDL_CONFIG" = "no" ; then
+ no_sdl=yes
+ else
+ SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
+ SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
+
+ sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
+ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
+ sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
+ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
+ sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
+ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
+ if test "x$enable_sdltest" = "xyes" ; then
+ ac_save_CFLAGS="$CFLAGS"
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ ac_save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"
+ rm -f conf.sdltest
+ if test "$cross_compiling" = yes; then
+ echo $ac_n "cross compiling; assumed OK... $ac_c"
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SDL.h"
+
+char*
+my_strdup (char *str)
+{
+ char *new_str;
+
+ if (str)
+ {
+ new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
+ strcpy (new_str, str);
+ }
+ else
+ new_str = NULL;
+
+ return new_str;
+}
+
+int main (int argc, char *argv[])
+{
+ int major, minor, micro;
+ char *tmp_version;
+
+ /* This hangs on some systems (?)
+ system ("touch conf.sdltest");
+ */
+ { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
+
+ /* HP/UX 9 (%@#!) writes to sscanf strings */
+ tmp_version = my_strdup("$min_sdl_version");
+ if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+ printf("%s, bad version string\n", "$min_sdl_version");
+ exit(1);
+ }
+
+ if (($sdl_major_version > major) ||
+ (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
+ (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
+ {
+ return 0;
+ }
+ else
+ {
+ printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
+ printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
+ printf("*** best to upgrade to the required version.\n");
+ printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
+ printf("*** to point to the correct copy of sdl-config, and remove the file\n");
+ printf("*** config.cache before re-running configure\n");
+ return 1;
+ }
+}
+
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+no_sdl=yes
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+ CFLAGS="$ac_save_CFLAGS"
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+ fi
+ if test "x$no_sdl" = x ; then
+ { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+ :
+ else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ if test "$SDL_CONFIG" = "no" ; then
+ echo "*** The sdl-config script installed by SDL could not be found"
+ echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
+ echo "*** your path, or set the SDL_CONFIG environment variable to the"
+ echo "*** full path to sdl-config."
+ else
+ if test -f conf.sdltest ; then
+ :
+ else
+ echo "*** Could not run SDL test program, checking why..."
+ CFLAGS="$CFLAGS $SDL_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdio.h>
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{ return 0; }
+#undef main
+#define main K_and_R_C_main
+
+int
+main ()
+{
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ echo "*** The test program compiled, but did not run. This usually means"
+ echo "*** that the run-time linker is not finding SDL or finding the wrong"
+ echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
+ echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+ echo "*** to the installed location Also, make sure you have run ldconfig if that"
+ echo "*** is required on your system"
+ echo "***"
+ echo "*** If you have an old version installed, it is best to remove it, although"
+ echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ echo "*** The test program failed to compile or link. See the file config.log for the"
+ echo "*** exact error that occured. This usually means SDL was incorrectly installed"
+ echo "*** or that you have moved SDL since it was installed. In the latter case, you"
+ echo "*** may want to edit the sdl-config script: $SDL_CONFIG"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS="$ac_save_CFLAGS"
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+ fi
+ SDL_CFLAGS=""
+ SDL_LIBS=""
+ { { $as_echo "$as_me:$LINENO: error: *** SDL version $SDL_VERSION not found!" >&5
+$as_echo "$as_me: error: *** SDL version $SDL_VERSION not found!" >&2;}
+ { (exit 1); exit 1; }; }
+
+ fi
+
+
+ rm -f conf.sdltest
+
+CFLAGS="$CFLAGS $SDL_CFLAGS"
+LIBS="$LIBS $SDL_LIBS"
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:$LINENO: checking for X" >&5
+$as_echo_n "checking for X... " >&6; }
+
+
+# Check whether --with-x was given.
+if test "${with_x+set}" = set; then
+ withval=$with_x;
+fi
+
+# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+if test "x$with_x" = xno; then
+ # The user explicitly disabled X.
+ have_x=disabled
+else
+ case $x_includes,$x_libraries in #(
+ *\'*) { { $as_echo "$as_me:$LINENO: error: cannot use X directory names containing '" >&5
+$as_echo "$as_me: error: cannot use X directory names containing '" >&2;}
+ { (exit 1); exit 1; }; };; #(
+ *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ # One or both of the vars are not set, and there is no cached value.
+ac_x_includes=no ac_x_libraries=no
+rm -f -r conftest.dir
+if mkdir conftest.dir; then
+ cd conftest.dir
+ cat >Imakefile <<'_ACEOF'
+incroot:
+ @echo incroot='${INCROOT}'
+usrlibdir:
+ @echo usrlibdir='${USRLIBDIR}'
+libdir:
+ @echo libdir='${LIBDIR}'
+_ACEOF
+ if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
+ # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+ for ac_var in incroot usrlibdir libdir; do
+ eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
+ done
+ # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+ for ac_extension in a so sl dylib la dll; do
+ if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
+ test -f "$ac_im_libdir/libX11.$ac_extension"; then
+ ac_im_usrlibdir=$ac_im_libdir; break
+ fi
+ done
+ # Screen out bogus values from the imake configuration. They are
+ # bogus both because they are the default anyway, and because
+ # using them would break gcc on systems where it needs fixed includes.
+ case $ac_im_incroot in
+ /usr/include) ac_x_includes= ;;
+ *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+ esac
+ case $ac_im_usrlibdir in
+ /usr/lib | /usr/lib64 | /lib | /lib64) ;;
+ *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+ esac
+ fi
+ cd ..
+ rm -f -r conftest.dir
+fi
+
+# Standard set of common directories for X headers.
+# Check X11 before X11Rn because it is often a symlink to the current release.
+ac_x_header_dirs='
+/usr/X11/include
+/usr/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
+
+/usr/include/X11
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
+
+/usr/local/X11/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
+
+/usr/local/include/X11
+/usr/local/include/X11R6
+/usr/local/include/X11R5
+/usr/local/include/X11R4
+
+/usr/X386/include
+/usr/x386/include
+/usr/XFree86/include/X11
+
+/usr/include
+/usr/local/include
+/usr/unsupported/include
+/usr/athena/include
+/usr/local/x11r5/include
+/usr/lpp/Xamples/include
+
+/usr/openwin/include
+/usr/openwin/share/include'
+
+if test "$ac_x_includes" = no; then
+ # Guess where to find include files, by looking for Xlib.h.
+ # First, try using that file with no special directory specified.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <X11/Xlib.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # We can compile using X headers with no special include directory.
+ac_x_includes=
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ for ac_dir in $ac_x_header_dirs; do
+ if test -r "$ac_dir/X11/Xlib.h"; then
+ ac_x_includes=$ac_dir
+ break
+ fi
+done
+fi
+
+rm -f conftest.err conftest.$ac_ext
+fi # $ac_x_includes = no
+
+if test "$ac_x_libraries" = no; then
+ # Check for the libraries.
+ # See if we find them without any special options.
+ # Don't add to $LIBS permanently.
+ ac_save_LIBS=$LIBS
+ LIBS="-lX11 $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <X11/Xlib.h>
+int
+main ()
+{
+XrmInitialize ()
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ LIBS=$ac_save_LIBS
+for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+do
+ # Don't even attempt the hair of trying to link an X program!
+ for ac_extension in a so sl dylib la dll; do
+ if test -r "$ac_dir/libX11.$ac_extension"; then
+ ac_x_libraries=$ac_dir
+ break 2
+ fi
+ done
+done
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi # $ac_x_libraries = no
+
+case $ac_x_includes,$ac_x_libraries in #(
+ no,* | *,no | *\'*)
+ # Didn't find X, or a directory has "'" in its name.
+ ac_cv_have_x="have_x=no";; #(
+ *)
+ # Record where we found X for the cache.
+ ac_cv_have_x="have_x=yes\
+ ac_x_includes='$ac_x_includes'\
+ ac_x_libraries='$ac_x_libraries'"
+esac
+fi
+;; #(
+ *) have_x=yes;;
+ esac
+ eval "$ac_cv_have_x"
+fi # $with_x != no
+
+if test "$have_x" != yes; then
+ { $as_echo "$as_me:$LINENO: result: $have_x" >&5
+$as_echo "$have_x" >&6; }
+ no_x=yes
+else
+ # If each of the values was on the command line, it overrides each guess.
+ test "x$x_includes" = xNONE && x_includes=$ac_x_includes
+ test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
+ # Update the cache value to reflect the command line values.
+ ac_cv_have_x="have_x=yes\
+ ac_x_includes='$x_includes'\
+ ac_x_libraries='$x_libraries'"
+ { $as_echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
+$as_echo "libraries $x_libraries, headers $x_includes" >&6; }
+fi
+
+if test x$have_x = xyes; then
+ if test x$ac_x_includes = xno || test x$ac_x_includes = x; then
+ :
+ else
+ CFLAGS="$CFLAGS -I$ac_x_includes"
+ fi
+ if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then
+ :
+ else
+ XPATH="-L$ac_x_libraries"
+ fi
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for OpenGL support" >&5
+$as_echo_n "checking for OpenGL support... " >&6; }
+have_opengl=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ #include "SDL_opengl.h"
+
+int
+main ()
+{
+
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+
+have_opengl=yes
+
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $have_opengl" >&5
+$as_echo "$have_opengl" >&6; }
+if test x$have_opengl = xyes; then
+ CFLAGS="$CFLAGS -DHAVE_OPENGL"
+ GLLIB="$XPATH $SYS_GL_LIBS"
+else
+ GLLIB=""
+fi
+
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ test "x$cache_file" != "x/dev/null" &&
+ { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ cat confcache >$cache_file
+ else
+ { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then branch to the quote section. Otherwise,
+# look for a macro that doesn't take arguments.
+ac_script='
+:mline
+/\\$/{
+ N
+ s,\\\n,,
+ b mline
+}
+t clear
+:clear
+s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
+t quote
+s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
+t quote
+b any
+:quote
+s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
+s/\[/\\&/g
+s/\]/\\&/g
+s/\$/$$/g
+H
+:any
+${
+ g
+ s/^\n//
+ s/\n/ /g
+ p
+}
+'
+DEFS=`sed -n "$ac_script" confdefs.h`
+
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -p'
+ fi
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.63. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTION]... [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+
+Configuration files:
+$config_files
+
+Report bugs to <bug-autoconf@gnu.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.63,
+ with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h | --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { $as_echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+ *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp=
+ trap 'exit_status=$?
+ { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} ||
+{
+ $as_echo "$as_me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=' '
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\).*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\).*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+ || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
+$as_echo "$as_me: error: could not setup config files machinery" >&2;}
+ { (exit 1); exit 1; }; }
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[ ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+
+eval set X " :F $CONFIG_FILES "
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
+$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
+ { (exit 1); exit 1; }; };;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ ac_file_inputs="$ac_file_inputs '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:$LINENO: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$tmp/stdin" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ { as_dir="$ac_dir"
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
+ { (exit 1); exit 1; }; }; }
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&2;}
+
+ rm -f "$tmp/stdin"
+ case $ac_file in
+ -) cat "$tmp/out" && rm -f "$tmp/out";;
+ *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+ esac \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+
+
+
+ esac
+
+done # for ac_tag
+
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/test/configure.in b/test/configure.in
new file mode 100644
index 0000000..7c25c17
--- /dev/null
+++ b/test/configure.in
@@ -0,0 +1,105 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(README)
+
+dnl Detect the canonical build and host environments
+AC_CONFIG_AUX_DIRS($srcdir/../build-scripts)
+AC_CANONICAL_HOST
+
+dnl Check for tools
+
+AC_PROG_CC
+
+dnl Check for compiler environment
+
+AC_C_CONST
+
+dnl Figure out which math library to use
+case "$host" in
+ *-*-cygwin* | *-*-mingw32*)
+ EXE=".exe"
+ MATHLIB=""
+ SYS_GL_LIBS="-lopengl32"
+ ;;
+ *-*-beos* | *-*-haiku*)
+ EXE=""
+ MATHLIB=""
+ SYS_GL_LIBS="-lGL"
+ ;;
+ *-*-darwin* )
+ EXE=""
+ MATHLIB=""
+ SYS_GL_LIBS="-Wl,-framework,OpenGL"
+ ;;
+ *-*-aix*)
+ EXE=""
+ if test x$ac_cv_prog_gcc = xyes; then
+ CFLAGS="-mthreads"
+ fi
+ SYS_GL_LIBS=""
+ ;;
+ *-*-mint*)
+ EXE=""
+ MATHLIB=""
+ AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
+ if test "x$OSMESA_CONFIG" = "xyes"; then
+ OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
+ OSMESA_LIBS=`$OSMESA_CONFIG --libs`
+ CFLAGS="$CFLAGS $OSMESA_CFLAGS"
+ SYS_GL_LIBS="$OSMESA_LIBS"
+ else
+ SYS_GL_LIBS="-lOSMesa"
+ fi
+ ;;
+ *)
+ EXE=""
+ MATHLIB="-lm"
+ SYS_GL_LIBS="-lGL"
+ ;;
+esac
+AC_SUBST(EXE)
+AC_SUBST(MATHLIB)
+
+dnl Check for SDL
+SDL_VERSION=1.2.10
+AM_PATH_SDL($SDL_VERSION,
+ :,
+ AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
+)
+CFLAGS="$CFLAGS $SDL_CFLAGS"
+LIBS="$LIBS $SDL_LIBS"
+
+dnl Check for X11 path, needed for OpenGL on some systems
+AC_PATH_X
+if test x$have_x = xyes; then
+ if test x$ac_x_includes = xno || test x$ac_x_includes = x; then
+ :
+ else
+ CFLAGS="$CFLAGS -I$ac_x_includes"
+ fi
+ if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then
+ :
+ else
+ XPATH="-L$ac_x_libraries"
+ fi
+fi
+
+dnl Check for OpenGL
+AC_MSG_CHECKING(for OpenGL support)
+have_opengl=no
+AC_TRY_COMPILE([
+ #include "SDL_opengl.h"
+],[
+],[
+have_opengl=yes
+])
+AC_MSG_RESULT($have_opengl)
+if test x$have_opengl = xyes; then
+ CFLAGS="$CFLAGS -DHAVE_OPENGL"
+ GLLIB="$XPATH $SYS_GL_LIBS"
+else
+ GLLIB=""
+fi
+AC_SUBST(GLLIB)
+
+dnl Finally create all the generated files
+AC_OUTPUT([Makefile])
diff --git a/test/gcc-fat.sh b/test/gcc-fat.sh
new file mode 100755
index 0000000..203b941
--- /dev/null
+++ b/test/gcc-fat.sh
@@ -0,0 +1,134 @@
+#!/bin/sh
+#
+# Build Universal binaries on Mac OS X, thanks Ryan!
+#
+# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf ppc x86
+
+# Locate Xcode SDK path
+SDK_PATH=/Developer/SDKs
+if [ ! -d $SDK_PATH ]; then
+ echo "Couldn't find SDK path"
+ exit 1
+fi
+
+if [ -d "$SDK_PATH/MacOSX10.2.8.sdk" ]; then
+ # PowerPC compiler flags (10.2 runtime compatibility)
+ GCC_COMPILE_PPC="gcc-3.3 -arch ppc \
+-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
+-nostdinc \
+-F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
+-I$SDK_PATH/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
+-isystem $SDK_PATH/MacOSX10.2.8.sdk/usr/include"
+
+ GCC_LINK_PPC="\
+-L$SDK_PATH/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
+-F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
+-Wl,-syslibroot,$SDK_PATH/MacOSX10.2.8.sdk"
+
+else # 10.2 or 10.3 SDK
+ # PowerPC compiler flags (10.3 runtime compatibility)
+ GCC_COMPILE_PPC="gcc-4.0 -arch ppc -mmacosx-version-min=10.3 \
+-DMAC_OS_X_VERSION_MIN_REQUIRED=1030 \
+-nostdinc \
+-F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
+-I$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1/include \
+-isystem $SDK_PATH/MacOSX10.3.9.sdk/usr/include"
+
+ GCC_LINK_PPC="\
+-L$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1 \
+-F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
+-Wl,-syslibroot,$SDK_PATH/MacOSX10.3.9.sdk"
+
+fi # 10.2 or 10.3 SDK
+
+# Intel compiler flags (10.4 runtime compatibility)
+GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
+-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
+-nostdinc \
+-F$SDK_PATH/MacOSX10.4u.sdk/System/Library/Frameworks \
+-I$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include \
+-isystem $SDK_PATH/MacOSX10.4u.sdk/usr/include"
+
+GCC_LINK_X86="\
+-L$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1 \
+-Wl,-syslibroot,$SDK_PATH/MacOSX10.4u.sdk"
+
+# Output both PowerPC and Intel object files
+args="$*"
+compile=yes
+link=yes
+while test x$1 != x; do
+ case $1 in
+ --version) exec gcc $1;;
+ -v) exec gcc $1;;
+ -V) exec gcc $1;;
+ -print-prog-name=*) exec gcc $1;;
+ -print-search-dirs) exec gcc $1;;
+ -E) GCC_COMPILE_PPC="$GCC_COMPILE_PPC -E"
+ GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
+ compile=no; link=no;;
+ -c) link=no;;
+ -o) output=$2;;
+ *.c|*.cc|*.cpp|*.S) source=$1;;
+ esac
+ shift
+done
+if test x$link = xyes; then
+ GCC_COMPILE_PPC="$GCC_COMPILE_PPC $GCC_LINK_PPC"
+ GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
+fi
+if test x"$output" = x; then
+ if test x$link = xyes; then
+ output=a.out
+ elif test x$compile = xyes; then
+ output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
+ fi
+fi
+
+if test x"$output" != x; then
+ dir=ppc/`dirname $output`
+ if test -d $dir; then
+ :
+ else
+ mkdir -p $dir
+ fi
+fi
+set -- $args
+while test x$1 != x; do
+ if test -f "ppc/$1" && test "$1" != "$output"; then
+ ppc_args="$ppc_args ppc/$1"
+ else
+ ppc_args="$ppc_args $1"
+ fi
+ shift
+done
+$GCC_COMPILE_PPC $ppc_args || exit $?
+if test x"$output" != x; then
+ cp $output ppc/$output
+fi
+
+if test x"$output" != x; then
+ dir=x86/`dirname $output`
+ if test -d $dir; then
+ :
+ else
+ mkdir -p $dir
+ fi
+fi
+set -- $args
+while test x$1 != x; do
+ if test -f "x86/$1" && test "$1" != "$output"; then
+ x86_args="$x86_args x86/$1"
+ else
+ x86_args="$x86_args $1"
+ fi
+ shift
+done
+$GCC_COMPILE_X86 $x86_args || exit $?
+if test x"$output" != x; then
+ cp $output x86/$output
+fi
+
+if test x"$output" != x; then
+ lipo -create -o $output ppc/$output x86/$output
+fi
diff --git a/test/graywin.c b/test/graywin.c
new file mode 100644
index 0000000..4563114
--- /dev/null
+++ b/test/graywin.c
@@ -0,0 +1,257 @@
+
+/* Simple program: Fill a colormap with gray and stripe it down the screen */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "SDL.h"
+
+#ifdef TEST_VGA16 /* Define this if you want to test VGA 16-color video modes */
+#define NUM_COLORS 16
+#else
+#define NUM_COLORS 256
+#endif
+
+/* Draw a randomly sized and colored box centered about (X,Y) */
+void DrawBox(SDL_Surface *screen, int X, int Y, int width, int height)
+{
+ static unsigned int seeded = 0;
+ SDL_Rect area;
+ Uint32 color;
+ Uint32 randc;
+
+ /* Seed the random number generator */
+ if ( seeded == 0 ) {
+ srand(time(NULL));
+ seeded = 1;
+ }
+
+ /* Get the bounds of the rectangle */
+ area.w = (rand()%width);
+ area.h = (rand()%height);
+ area.x = X-(area.w/2);
+ area.y = Y-(area.h/2);
+ randc = (rand()%NUM_COLORS);
+
+ if (screen->format->BytesPerPixel==1)
+ {
+ color = randc;
+ }
+ else
+ {
+ color = SDL_MapRGB(screen->format, randc, randc, randc);
+ }
+
+ /* Do it! */
+ SDL_FillRect(screen, &area, color);
+ if ( screen->flags & SDL_DOUBLEBUF ) {
+ SDL_Flip(screen);
+ } else {
+ SDL_UpdateRects(screen, 1, &area);
+ }
+}
+
+void DrawBackground(SDL_Surface *screen)
+{
+ int i, j, k;
+ Uint8 *buffer;
+ Uint16 *buffer16;
+ Uint16 color;
+ Uint8 gradient;
+
+ /* Set the surface pixels and refresh! */
+ /* Use two loops in case the surface is double-buffered (both sides) */
+
+ for ( j=0; j<2; ++j ) {
+ if ( SDL_LockSurface(screen) < 0 ) {
+ fprintf(stderr, "Couldn't lock display surface: %s\n",
+ SDL_GetError());
+ return;
+ }
+ buffer = (Uint8 *)screen->pixels;
+
+ if (screen->format->BytesPerPixel!=2) {
+ for ( i=0; i<screen->h; ++i ) {
+ memset(buffer,(i*(NUM_COLORS-1))/screen->h, screen->w * screen->format->BytesPerPixel);
+ buffer += screen->pitch;
+ }
+ }
+ else
+ {
+ for ( i=0; i<screen->h; ++i ) {
+ gradient=((i*(NUM_COLORS-1))/screen->h);
+ color = SDL_MapRGB(screen->format, gradient, gradient, gradient);
+ buffer16=(Uint16*)buffer;
+ for (k=0; k<screen->w; k++)
+ {
+ *(buffer16+k)=color;
+ }
+ buffer += screen->pitch;
+ }
+ }
+
+ SDL_UnlockSurface(screen);
+ if ( screen->flags & SDL_DOUBLEBUF ) {
+ SDL_Flip(screen);
+ } else {
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+ break;
+ }
+ }
+}
+
+SDL_Surface *CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags)
+{
+ SDL_Surface *screen;
+ int i;
+ SDL_Color palette[NUM_COLORS];
+
+ /* Set the video mode */
+ screen = SDL_SetVideoMode(w, h, bpp, flags);
+ if ( screen == NULL ) {
+ fprintf(stderr, "Couldn't set display mode: %s\n",
+ SDL_GetError());
+ return(NULL);
+ }
+ fprintf(stderr, "Screen is in %s mode\n",
+ (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
+
+ if (bpp==8) {
+ /* Set a gray colormap, reverse order from white to black */
+ for ( i=0; i<NUM_COLORS; ++i ) {
+ palette[i].r = (NUM_COLORS-1)-i * (256 / NUM_COLORS);
+ palette[i].g = (NUM_COLORS-1)-i * (256 / NUM_COLORS);
+ palette[i].b = (NUM_COLORS-1)-i * (256 / NUM_COLORS);
+ }
+ SDL_SetColors(screen, palette, 0, NUM_COLORS);
+ }
+
+ return(screen);
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+ Uint32 videoflags;
+ int done;
+ SDL_Event event;
+ int width, height, bpp;
+
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ exit(1);
+ }
+
+ /* See if we try to get a hardware colormap */
+ width = 640;
+ height = 480;
+ bpp = 8;
+ videoflags = SDL_SWSURFACE;
+ while ( argc > 1 ) {
+ --argc;
+ if ( argv[argc-1] && (strcmp(argv[argc-1], "-width") == 0) ) {
+ width = atoi(argv[argc]);
+ --argc;
+ } else
+ if ( argv[argc-1] && (strcmp(argv[argc-1], "-height") == 0) ) {
+ height = atoi(argv[argc]);
+ --argc;
+ } else
+ if ( argv[argc-1] && (strcmp(argv[argc-1], "-bpp") == 0) ) {
+ bpp = atoi(argv[argc]);
+ --argc;
+ } else
+ if ( argv[argc] && (strcmp(argv[argc], "-hw") == 0) ) {
+ videoflags |= SDL_HWSURFACE;
+ } else
+ if ( argv[argc] && (strcmp(argv[argc], "-hwpalette") == 0) ) {
+ videoflags |= SDL_HWPALETTE;
+ } else
+ if ( argv[argc] && (strcmp(argv[argc], "-flip") == 0) ) {
+ videoflags |= SDL_DOUBLEBUF;
+ } else
+ if ( argv[argc] && (strcmp(argv[argc], "-noframe") == 0) ) {
+ videoflags |= SDL_NOFRAME;
+ } else
+ if ( argv[argc] && (strcmp(argv[argc], "-resize") == 0) ) {
+ videoflags |= SDL_RESIZABLE;
+ } else
+ if ( argv[argc] && (strcmp(argv[argc], "-fullscreen") == 0) ) {
+ videoflags |= SDL_FULLSCREEN;
+ } else {
+ fprintf(stderr, "Usage: %s [-width] [-height] [-bpp] [-hw] [-hwpalette] [-flip] [-noframe] [-fullscreen] [-resize]\n",
+ argv[0]);
+ exit(1);
+ }
+ }
+
+ /* Set a video mode */
+ screen = CreateScreen(width, height, bpp, videoflags);
+ if ( screen == NULL ) {
+ exit(2);
+ }
+
+ DrawBackground(screen);
+
+ /* Wait for a keystroke */
+ done = 0;
+ while ( !done && SDL_WaitEvent(&event) ) {
+ switch (event.type) {
+ case SDL_MOUSEBUTTONDOWN:
+ DrawBox(screen, event.button.x, event.button.y, width, height);
+ break;
+ case SDL_KEYDOWN:
+ /* Ignore ALT-TAB for windows */
+ if ( (event.key.keysym.sym == SDLK_LALT) ||
+ (event.key.keysym.sym == SDLK_TAB) ) {
+ break;
+ }
+ /* Center the mouse on <SPACE> */
+ if ( event.key.keysym.sym == SDLK_SPACE ) {
+ SDL_WarpMouse(width/2, height/2);
+ break;
+ }
+ /* Toggle fullscreen mode on <RETURN> */
+ if ( event.key.keysym.sym == SDLK_RETURN ) {
+ videoflags ^= SDL_FULLSCREEN;
+ screen = CreateScreen(
+ screen->w, screen->h,
+ screen->format->BitsPerPixel,
+ videoflags);
+ if ( screen == NULL ) {
+ fprintf(stderr,
+ "Couldn't toggle fullscreen mode\n");
+ done = 1;
+ }
+ DrawBackground(screen);
+ break;
+ }
+ /* Any other key quits the application... */
+ case SDL_QUIT:
+ done = 1;
+ break;
+ case SDL_VIDEOEXPOSE:
+ DrawBackground(screen);
+ break;
+ case SDL_VIDEORESIZE:
+ screen = CreateScreen(
+ event.resize.w, event.resize.h,
+ screen->format->BitsPerPixel,
+ videoflags);
+ if ( screen == NULL ) {
+ fprintf(stderr,
+ "Couldn't resize video mode\n");
+ done = 1;
+ }
+ DrawBackground(screen);
+ break;
+ default:
+ break;
+ }
+ }
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/icon.bmp b/test/icon.bmp
new file mode 100644
index 0000000..cc96356
--- /dev/null
+++ b/test/icon.bmp
Binary files differ
diff --git a/test/loopwave.c b/test/loopwave.c
new file mode 100644
index 0000000..e1df747
--- /dev/null
+++ b/test/loopwave.c
@@ -0,0 +1,114 @@
+
+/* Program to load a wave file and loop playing it using SDL sound */
+
+/* loopwaves.c is much more robust in handling WAVE files --
+ This is only for simple WAVEs
+*/
+#include "SDL_config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#include "SDL.h"
+#include "SDL_audio.h"
+
+struct {
+ SDL_AudioSpec spec;
+ Uint8 *sound; /* Pointer to wave data */
+ Uint32 soundlen; /* Length of wave data */
+ int soundpos; /* Current play position */
+} wave;
+
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+
+void SDLCALL fillerup(void *unused, Uint8 *stream, int len)
+{
+ Uint8 *waveptr;
+ int waveleft;
+
+ /* Set up the pointers */
+ waveptr = wave.sound + wave.soundpos;
+ waveleft = wave.soundlen - wave.soundpos;
+
+ /* Go! */
+ while ( waveleft <= len ) {
+ SDL_memcpy(stream, waveptr, waveleft);
+ stream += waveleft;
+ len -= waveleft;
+ waveptr = wave.sound;
+ waveleft = wave.soundlen;
+ wave.soundpos = 0;
+ }
+ SDL_memcpy(stream, waveptr, len);
+ wave.soundpos += len;
+}
+
+static int done = 0;
+void poked(int sig)
+{
+ done = 1;
+}
+
+int main(int argc, char *argv[])
+{
+ char name[32];
+
+ /* Load the SDL library */
+ if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+ if ( argv[1] == NULL ) {
+ argv[1] = "sample.wav";
+ }
+ /* Load the wave file into memory */
+ if ( SDL_LoadWAV(argv[1],
+ &wave.spec, &wave.sound, &wave.soundlen) == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s\n",
+ argv[1], SDL_GetError());
+ quit(1);
+ }
+
+ wave.spec.callback = fillerup;
+#if HAVE_SIGNAL_H
+ /* Set the signals */
+#ifdef SIGHUP
+ signal(SIGHUP, poked);
+#endif
+ signal(SIGINT, poked);
+#ifdef SIGQUIT
+ signal(SIGQUIT, poked);
+#endif
+ signal(SIGTERM, poked);
+#endif /* HAVE_SIGNAL_H */
+
+ /* Initialize fillerup() variables */
+ if ( SDL_OpenAudio(&wave.spec, NULL) < 0 ) {
+ fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+ SDL_FreeWAV(wave.sound);
+ quit(2);
+ }
+ SDL_PauseAudio(0);
+
+ /* Let the audio run */
+ printf("Using audio driver: %s\n", SDL_AudioDriverName(name, 32));
+ while ( ! done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING) )
+ SDL_Delay(1000);
+
+ /* Clean up on signal */
+ SDL_CloseAudio();
+ SDL_FreeWAV(wave.sound);
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/moose.dat b/test/moose.dat
new file mode 100644
index 0000000..1053004
--- /dev/null
+++ b/test/moose.dat
Binary files differ
diff --git a/test/picture.xbm b/test/picture.xbm
new file mode 100644
index 0000000..c873a60
--- /dev/null
+++ b/test/picture.xbm
@@ -0,0 +1,14 @@
+#define picture_width 32
+#define picture_height 32
+static char picture_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x18,
+ 0x64, 0x6f, 0xf6, 0x26, 0x0a, 0x00, 0x00, 0x50, 0xf2, 0xff, 0xff, 0x4f,
+ 0x14, 0x04, 0x00, 0x28, 0x14, 0x0e, 0x00, 0x28, 0x10, 0x32, 0x00, 0x08,
+ 0x94, 0x03, 0x00, 0x08, 0xf4, 0x04, 0x00, 0x08, 0xb0, 0x08, 0x00, 0x08,
+ 0x34, 0x01, 0x00, 0x28, 0x34, 0x01, 0x00, 0x28, 0x12, 0x00, 0x40, 0x48,
+ 0x12, 0x20, 0xa6, 0x48, 0x14, 0x50, 0x11, 0x29, 0x14, 0x50, 0x48, 0x2a,
+ 0x10, 0x27, 0xac, 0x0e, 0xd4, 0x71, 0xe8, 0x0a, 0x74, 0x20, 0xa8, 0x0a,
+ 0x14, 0x20, 0x00, 0x08, 0x10, 0x50, 0x00, 0x08, 0x14, 0x00, 0x00, 0x28,
+ 0x14, 0x00, 0x00, 0x28, 0xf2, 0xff, 0xff, 0x4f, 0x0a, 0x00, 0x00, 0x50,
+ 0x64, 0x6f, 0xf6, 0x26, 0x18, 0x80, 0x01, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/test/sail.bmp b/test/sail.bmp
new file mode 100644
index 0000000..12850c3
--- /dev/null
+++ b/test/sail.bmp
Binary files differ
diff --git a/test/sample.bmp b/test/sample.bmp
new file mode 100644
index 0000000..aca8bbc
--- /dev/null
+++ b/test/sample.bmp
Binary files differ
diff --git a/test/sample.wav b/test/sample.wav
new file mode 100644
index 0000000..002f815
--- /dev/null
+++ b/test/sample.wav
Binary files differ
diff --git a/test/testalpha.c b/test/testalpha.c
new file mode 100644
index 0000000..4af5c10
--- /dev/null
+++ b/test/testalpha.c
@@ -0,0 +1,537 @@
+
+/* Simple program: Fill a colormap with gray and stripe it down the screen,
+ Then move an alpha valued sprite around the screen.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "SDL.h"
+
+#define FRAME_TICKS (1000/30) /* 30 frames/second */
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+/* Fill the screen with a gradient */
+static void FillBackground(SDL_Surface *screen)
+{
+ Uint8 *buffer;
+ Uint16 *buffer16;
+ Uint16 color;
+ Uint8 gradient;
+ int i, k;
+
+ /* Set the surface pixels and refresh! */
+ if ( SDL_LockSurface(screen) < 0 ) {
+ fprintf(stderr, "Couldn't lock the display surface: %s\n",
+ SDL_GetError());
+ quit(2);
+ }
+ buffer=(Uint8 *)screen->pixels;
+ if (screen->format->BytesPerPixel!=2) {
+ for ( i=0; i<screen->h; ++i ) {
+ memset(buffer,(i*255)/screen->h, screen->w*screen->format->BytesPerPixel);
+ buffer += screen->pitch;
+ }
+ }
+ else
+ {
+ for ( i=0; i<screen->h; ++i ) {
+ gradient=((i*255)/screen->h);
+ color = (Uint16)SDL_MapRGB(screen->format, gradient, gradient, gradient);
+ buffer16=(Uint16*)buffer;
+ for (k=0; k<screen->w; k++)
+ {
+ *(buffer16+k)=color;
+ }
+ buffer += screen->pitch;
+ }
+ }
+
+ SDL_UnlockSurface(screen);
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+}
+
+/* Create a "light" -- a yellowish surface with variable alpha */
+SDL_Surface *CreateLight(int radius)
+{
+ Uint8 trans, alphamask;
+ int range, addition;
+ int xdist, ydist;
+ Uint16 x, y;
+ Uint16 skip;
+ Uint32 pixel;
+ SDL_Surface *light;
+
+#ifdef LIGHT_16BIT
+ Uint16 *buf;
+
+ /* Create a 16 (4/4/4/4) bpp square with a full 4-bit alpha channel */
+ /* Note: this isn't any faster than a 32 bit alpha surface */
+ alphamask = 0x0000000F;
+ light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2*radius, 2*radius, 16,
+ 0x0000F000, 0x00000F00, 0x000000F0, alphamask);
+#else
+ Uint32 *buf;
+
+ /* Create a 32 (8/8/8/8) bpp square with a full 8-bit alpha channel */
+ alphamask = 0x000000FF;
+ light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2*radius, 2*radius, 32,
+ 0xFF000000, 0x00FF0000, 0x0000FF00, alphamask);
+ if ( light == NULL ) {
+ fprintf(stderr, "Couldn't create light: %s\n", SDL_GetError());
+ return(NULL);
+ }
+#endif
+
+ /* Fill with a light yellow-orange color */
+ skip = light->pitch-(light->w*light->format->BytesPerPixel);
+#ifdef LIGHT_16BIT
+ buf = (Uint16 *)light->pixels;
+#else
+ buf = (Uint32 *)light->pixels;
+#endif
+ /* Get a tranparent pixel value - we'll add alpha later */
+ pixel = SDL_MapRGBA(light->format, 0xFF, 0xDD, 0x88, 0);
+ for ( y=0; y<light->h; ++y ) {
+ for ( x=0; x<light->w; ++x ) {
+ *buf++ = pixel;
+ }
+ buf += skip; /* Almost always 0, but just in case... */
+ }
+
+ /* Calculate alpha values for the surface. */
+#ifdef LIGHT_16BIT
+ buf = (Uint16 *)light->pixels;
+#else
+ buf = (Uint32 *)light->pixels;
+#endif
+ for ( y=0; y<light->h; ++y ) {
+ for ( x=0; x<light->w; ++x ) {
+ /* Slow distance formula (from center of light) */
+ xdist = x-(light->w/2);
+ ydist = y-(light->h/2);
+ range = (int)sqrt(xdist*xdist+ydist*ydist);
+
+ /* Scale distance to range of transparency (0-255) */
+ if ( range > radius ) {
+ trans = alphamask;
+ } else {
+ /* Increasing transparency with distance */
+ trans = (Uint8)((range*alphamask)/radius);
+
+ /* Lights are very transparent */
+ addition = (alphamask+1)/8;
+ if ( (int)trans+addition > alphamask ) {
+ trans = alphamask;
+ } else {
+ trans += addition;
+ }
+ }
+ /* We set the alpha component as the right N bits */
+ *buf++ |= (255-trans);
+ }
+ buf += skip; /* Almost always 0, but just in case... */
+ }
+ /* Enable RLE acceleration of this alpha surface */
+ SDL_SetAlpha(light, SDL_SRCALPHA|SDL_RLEACCEL, 0);
+
+ /* We're done! */
+ return(light);
+}
+
+static Uint32 flashes = 0;
+static Uint32 flashtime = 0;
+
+void FlashLight(SDL_Surface *screen, SDL_Surface *light, int x, int y)
+{
+ SDL_Rect position;
+ Uint32 ticks1;
+ Uint32 ticks2;
+
+ /* Easy, center light */
+ position.x = x-(light->w/2);
+ position.y = y-(light->h/2);
+ position.w = light->w;
+ position.h = light->h;
+ ticks1 = SDL_GetTicks();
+ SDL_BlitSurface(light, NULL, screen, &position);
+ ticks2 = SDL_GetTicks();
+ SDL_UpdateRects(screen, 1, &position);
+ ++flashes;
+
+ /* Update time spend doing alpha blitting */
+ flashtime += (ticks2-ticks1);
+}
+
+static int sprite_visible = 0;
+static SDL_Surface *sprite;
+static SDL_Surface *backing;
+static SDL_Rect position;
+static int x_vel, y_vel;
+static int alpha_vel;
+
+int LoadSprite(SDL_Surface *screen, char *file)
+{
+ SDL_Surface *converted;
+
+ /* Load the sprite image */
+ sprite = SDL_LoadBMP(file);
+ if ( sprite == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+ return(-1);
+ }
+
+ /* Set transparent pixel as the pixel at (0,0) */
+ if ( sprite->format->palette ) {
+ SDL_SetColorKey(sprite, SDL_SRCCOLORKEY,
+ *(Uint8 *)sprite->pixels);
+ }
+
+ /* Convert sprite to video format */
+ converted = SDL_DisplayFormat(sprite);
+ SDL_FreeSurface(sprite);
+ if ( converted == NULL ) {
+ fprintf(stderr, "Couldn't convert background: %s\n",
+ SDL_GetError());
+ return(-1);
+ }
+ sprite = converted;
+
+ /* Create the background */
+ backing = SDL_CreateRGBSurface(SDL_SWSURFACE, sprite->w, sprite->h, 8,
+ 0, 0, 0, 0);
+ if ( backing == NULL ) {
+ fprintf(stderr, "Couldn't create background: %s\n",
+ SDL_GetError());
+ SDL_FreeSurface(sprite);
+ return(-1);
+ }
+
+ /* Convert background to video format */
+ converted = SDL_DisplayFormat(backing);
+ SDL_FreeSurface(backing);
+ if ( converted == NULL ) {
+ fprintf(stderr, "Couldn't convert background: %s\n",
+ SDL_GetError());
+ SDL_FreeSurface(sprite);
+ return(-1);
+ }
+ backing = converted;
+
+ /* Set the initial position of the sprite */
+ position.x = (screen->w-sprite->w)/2;
+ position.y = (screen->h-sprite->h)/2;
+ position.w = sprite->w;
+ position.h = sprite->h;
+ x_vel = 0; y_vel = 0;
+ alpha_vel = 1;
+
+ /* We're ready to roll. :) */
+ return(0);
+}
+
+void AttractSprite(Uint16 x, Uint16 y)
+{
+ x_vel = ((int)x-position.x)/10;
+ y_vel = ((int)y-position.y)/10;
+}
+
+void MoveSprite(SDL_Surface *screen, SDL_Surface *light)
+{
+ SDL_Rect updates[2];
+ int alpha;
+
+ /* Erase the sprite if it was visible */
+ if ( sprite_visible ) {
+ updates[0] = position;
+ SDL_BlitSurface(backing, NULL, screen, &updates[0]);
+ } else {
+ updates[0].x = 0; updates[0].y = 0;
+ updates[0].w = 0; updates[0].h = 0;
+ sprite_visible = 1;
+ }
+
+ /* Since the sprite is off the screen, we can do other drawing
+ without being overwritten by the saved area behind the sprite.
+ */
+ if ( light != NULL ) {
+ int x, y;
+
+ SDL_GetMouseState(&x, &y);
+ FlashLight(screen, light, x, y);
+ }
+
+ /* Move the sprite, bounce at the wall */
+ position.x += x_vel;
+ if ( (position.x < 0) || (position.x >= screen->w) ) {
+ x_vel = -x_vel;
+ position.x += x_vel;
+ }
+ position.y += y_vel;
+ if ( (position.y < 0) || (position.y >= screen->h) ) {
+ y_vel = -y_vel;
+ position.y += y_vel;
+ }
+
+ /* Update transparency (fade in and out) */
+ alpha = sprite->format->alpha;
+ if ( (alpha+alpha_vel) < 0 ) {
+ alpha_vel = -alpha_vel;
+ } else
+ if ( (alpha+alpha_vel) > 255 ) {
+ alpha_vel = -alpha_vel;
+ }
+ SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8)(alpha+alpha_vel));
+
+ /* Save the area behind the sprite */
+ updates[1] = position;
+ SDL_BlitSurface(screen, &updates[1], backing, NULL);
+
+ /* Blit the sprite onto the screen */
+ updates[1] = position;
+ SDL_BlitSurface(sprite, NULL, screen, &updates[1]);
+
+ /* Make it so! */
+ SDL_UpdateRects(screen, 2, updates);
+}
+
+void WarpSprite(SDL_Surface *screen, int x, int y)
+{
+ SDL_Rect updates[2];
+
+ /* Erase, move, Draw, update */
+ updates[0] = position;
+ SDL_BlitSurface(backing, NULL, screen, &updates[0]);
+ position.x = x-sprite->w/2; /* Center about X */
+ position.y = y-sprite->h/2; /* Center about Y */
+ updates[1] = position;
+ SDL_BlitSurface(screen, &updates[1], backing, NULL);
+ updates[1] = position;
+ SDL_BlitSurface(sprite, NULL, screen, &updates[1]);
+ SDL_UpdateRects(screen, 2, updates);
+}
+
+int main(int argc, char *argv[])
+{
+ const SDL_VideoInfo *info;
+ SDL_Surface *screen;
+ int w, h;
+ Uint8 video_bpp;
+ Uint32 videoflags;
+ int i, done;
+ SDL_Event event;
+ SDL_Surface *light;
+ int mouse_pressed;
+ Uint32 ticks, lastticks;
+
+
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ /* Alpha blending doesn't work well at 8-bit color */
+#ifdef _WIN32_WCE
+ /* Pocket PC */
+ w = 240;
+ h = 320;
+#else
+ w = 640;
+ h = 480;
+#endif
+ info = SDL_GetVideoInfo();
+ if ( info->vfmt->BitsPerPixel > 8 ) {
+ video_bpp = info->vfmt->BitsPerPixel;
+ } else {
+ video_bpp = 16;
+ fprintf(stderr, "forced 16 bpp mode\n");
+ }
+ videoflags = SDL_SWSURFACE;
+ for ( i = 1; argv[i]; ++i ) {
+ if ( strcmp(argv[i], "-bpp") == 0 ) {
+ video_bpp = atoi(argv[++i]);
+ if (video_bpp<=8) {
+ video_bpp=16;
+ fprintf(stderr, "forced 16 bpp mode\n");
+ }
+ } else
+ if ( strcmp(argv[i], "-hw") == 0 ) {
+ videoflags |= SDL_HWSURFACE;
+ } else
+ if ( strcmp(argv[i], "-warp") == 0 ) {
+ videoflags |= SDL_HWPALETTE;
+ } else
+ if ( strcmp(argv[i], "-width") == 0 && argv[i+1] ) {
+ w = atoi(argv[++i]);
+ } else
+ if ( strcmp(argv[i], "-height") == 0 && argv[i+1] ) {
+ h = atoi(argv[++i]);
+ } else
+ if ( strcmp(argv[i], "-resize") == 0 ) {
+ videoflags |= SDL_RESIZABLE;
+ } else
+ if ( strcmp(argv[i], "-noframe") == 0 ) {
+ videoflags |= SDL_NOFRAME;
+ } else
+ if ( strcmp(argv[i], "-fullscreen") == 0 ) {
+ videoflags |= SDL_FULLSCREEN;
+ } else {
+ fprintf(stderr,
+ "Usage: %s [-width N] [-height N] [-bpp N] [-warp] [-hw] [-fullscreen]\n",
+ argv[0]);
+ quit(1);
+ }
+ }
+
+ /* Set video mode */
+ if ( (screen=SDL_SetVideoMode(w,h,video_bpp,videoflags)) == NULL ) {
+ fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
+ w, h, video_bpp, SDL_GetError());
+ quit(2);
+ }
+ FillBackground(screen);
+
+ /* Create the light */
+ light = CreateLight(82);
+ if ( light == NULL ) {
+ quit(1);
+ }
+
+ /* Load the sprite */
+ if ( LoadSprite(screen, "icon.bmp") < 0 ) {
+ SDL_FreeSurface(light);
+ quit(1);
+ }
+
+ /* Print out information about our surfaces */
+ printf("Screen is at %d bits per pixel\n",screen->format->BitsPerPixel);
+ if ( (screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+ printf("Screen is in video memory\n");
+ } else {
+ printf("Screen is in system memory\n");
+ }
+ if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+ printf("Screen has double-buffering enabled\n");
+ }
+ if ( (sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+ printf("Sprite is in video memory\n");
+ } else {
+ printf("Sprite is in system memory\n");
+ }
+
+ /* Run a sample blit to trigger blit acceleration */
+ MoveSprite(screen, NULL);
+ if ( (sprite->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
+ printf("Sprite blit uses hardware alpha acceleration\n");
+ } else {
+ printf("Sprite blit dosn't uses hardware alpha acceleration\n");
+ }
+
+ /* Set a clipping rectangle to clip the outside edge of the screen */
+ { SDL_Rect clip;
+ clip.x = 32;
+ clip.y = 32;
+ clip.w = screen->w-(2*32);
+ clip.h = screen->h-(2*32);
+ SDL_SetClipRect(screen, &clip);
+ }
+
+ /* Wait for a keystroke */
+ lastticks = SDL_GetTicks();
+ done = 0;
+ mouse_pressed = 0;
+ while ( !done ) {
+ /* Update the frame -- move the sprite */
+ if ( mouse_pressed ) {
+ MoveSprite(screen, light);
+ mouse_pressed = 0;
+ } else {
+ MoveSprite(screen, NULL);
+ }
+
+ /* Slow down the loop to 30 frames/second */
+ ticks = SDL_GetTicks();
+ if ( (ticks-lastticks) < FRAME_TICKS ) {
+#ifdef CHECK_SLEEP_GRANULARITY
+fprintf(stderr, "Sleeping %d ticks\n", FRAME_TICKS-(ticks-lastticks));
+#endif
+ SDL_Delay(FRAME_TICKS-(ticks-lastticks));
+#ifdef CHECK_SLEEP_GRANULARITY
+fprintf(stderr, "Slept %d ticks\n", (SDL_GetTicks()-ticks));
+#endif
+ }
+ lastticks = ticks;
+
+ /* Check for events */
+ while ( SDL_PollEvent(&event) ) {
+ switch (event.type) {
+ case SDL_VIDEORESIZE:
+ screen = SDL_SetVideoMode(event.resize.w, event.resize.h, video_bpp, videoflags);
+ if ( screen ) {
+ FillBackground(screen);
+ }
+ break;
+ /* Attract sprite while mouse is held down */
+ case SDL_MOUSEMOTION:
+ if (event.motion.state != 0) {
+ AttractSprite(event.motion.x,
+ event.motion.y);
+ mouse_pressed = 1;
+ }
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ if ( event.button.button == 1 ) {
+ AttractSprite(event.button.x,
+ event.button.y);
+ mouse_pressed = 1;
+ } else {
+ SDL_Rect area;
+
+ area.x = event.button.x-16;
+ area.y = event.button.y-16;
+ area.w = 32;
+ area.h = 32;
+ SDL_FillRect(screen, &area, 0);
+ SDL_UpdateRects(screen,1,&area);
+ }
+ break;
+ case SDL_KEYDOWN:
+#ifndef _WIN32_WCE
+ if ( event.key.keysym.sym == SDLK_ESCAPE ) {
+ done = 1;
+ }
+#else
+ // there is no ESC key at all
+ done = 1;
+#endif
+ break;
+ case SDL_QUIT:
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ SDL_FreeSurface(light);
+ SDL_FreeSurface(sprite);
+ SDL_FreeSurface(backing);
+
+ /* Print out some timing information */
+ if ( flashes > 0 ) {
+ printf("%d alpha blits, ~%4.4f ms per blit\n",
+ flashes, (float)flashtime/flashes);
+ }
+
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testbitmap.c b/test/testbitmap.c
new file mode 100644
index 0000000..50cfcbb
--- /dev/null
+++ b/test/testbitmap.c
@@ -0,0 +1,184 @@
+
+/* Simple program: Test bitmap blits */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "picture.xbm"
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+SDL_Surface *LoadXBM(SDL_Surface *screen, int w, int h, Uint8 *bits)
+{
+ SDL_Surface *bitmap;
+ Uint8 *line;
+
+ /* Allocate the bitmap */
+ bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 1, 0, 0, 0, 0);
+ if ( bitmap == NULL ) {
+ fprintf(stderr, "Couldn't allocate bitmap: %s\n",
+ SDL_GetError());
+ return(NULL);
+ }
+
+ /* Copy the pixels */
+ line = (Uint8 *)bitmap->pixels;
+ w = (w+7)/8;
+ while ( h-- ) {
+ memcpy(line, bits, w);
+ /* X11 Bitmap images have the bits reversed */
+ { int i, j; Uint8 *buf, byte;
+ for ( buf=line, i=0; i<w; ++i, ++buf ) {
+ byte = *buf;
+ *buf = 0;
+ for ( j=7; j>=0; --j ) {
+ *buf |= (byte&0x01)<<j;
+ byte >>= 1;
+ }
+ }
+ }
+ line += bitmap->pitch;
+ bits += w;
+ }
+ return(bitmap);
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+ SDL_Surface *bitmap;
+ Uint8 video_bpp;
+ Uint32 videoflags;
+ Uint8 *buffer;
+ int i, k, done;
+ SDL_Event event;
+ Uint16 *buffer16;
+ Uint16 color;
+ Uint8 gradient;
+ SDL_Color palette[256];
+
+
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ video_bpp = 0;
+ videoflags = SDL_SWSURFACE;
+ while ( argc > 1 ) {
+ --argc;
+ if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
+ video_bpp = atoi(argv[argc]);
+ --argc;
+ } else
+ if ( strcmp(argv[argc], "-warp") == 0 ) {
+ videoflags |= SDL_HWPALETTE;
+ } else
+ if ( strcmp(argv[argc], "-hw") == 0 ) {
+ videoflags |= SDL_HWSURFACE;
+ } else
+ if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
+ videoflags |= SDL_FULLSCREEN;
+ } else {
+ fprintf(stderr,
+ "Usage: %s [-bpp N] [-warp] [-hw] [-fullscreen]\n",
+ argv[0]);
+ quit(1);
+ }
+ }
+
+ /* Set 640x480 video mode */
+ if ( (screen=SDL_SetVideoMode(640,480,video_bpp,videoflags)) == NULL ) {
+ fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
+ video_bpp, SDL_GetError());
+ quit(2);
+ }
+
+ if (video_bpp==8) {
+ /* Set a gray colormap, reverse order from white to black */
+ for ( i=0; i<256; ++i ) {
+ palette[i].r = 255-i;
+ palette[i].g = 255-i;
+ palette[i].b = 255-i;
+ }
+ SDL_SetColors(screen, palette, 0, 256);
+ }
+
+ /* Set the surface pixels and refresh! */
+ if ( SDL_LockSurface(screen) < 0 ) {
+ fprintf(stderr, "Couldn't lock the display surface: %s\n",
+ SDL_GetError());
+ quit(2);
+ }
+ buffer=(Uint8 *)screen->pixels;
+ if (screen->format->BytesPerPixel!=2) {
+ for ( i=0; i<screen->h; ++i ) {
+ memset(buffer,(i*255)/screen->h, screen->pitch);
+ buffer += screen->pitch;
+ }
+ }
+ else
+ {
+ for ( i=0; i<screen->h; ++i ) {
+ gradient=((i*255)/screen->h);
+ color = SDL_MapRGB(screen->format, gradient, gradient, gradient);
+ buffer16=(Uint16*)buffer;
+ for (k=0; k<screen->w; k++)
+ {
+ *(buffer16+k)=color;
+ }
+ buffer += screen->pitch;
+ }
+ }
+ SDL_UnlockSurface(screen);
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+ /* Load the bitmap */
+ bitmap = LoadXBM(screen, picture_width, picture_height,
+ (Uint8 *)picture_bits);
+ if ( bitmap == NULL ) {
+ quit(1);
+ }
+
+ /* Wait for a keystroke */
+ done = 0;
+ while ( !done ) {
+ /* Check for events */
+ while ( SDL_PollEvent(&event) ) {
+ switch (event.type) {
+ case SDL_MOUSEBUTTONDOWN: {
+ SDL_Rect dst;
+
+ dst.x = event.button.x - bitmap->w/2;
+ dst.y = event.button.y - bitmap->h/2;
+ dst.w = bitmap->w;
+ dst.h = bitmap->h;
+ SDL_BlitSurface(bitmap, NULL,
+ screen, &dst);
+ SDL_UpdateRects(screen,1,&dst);
+ }
+ break;
+ case SDL_KEYDOWN:
+ /* Any key press quits the app... */
+ done = 1;
+ break;
+ case SDL_QUIT:
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ SDL_FreeSurface(bitmap);
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testblitspeed.c b/test/testblitspeed.c
new file mode 100644
index 0000000..f5dff6b
--- /dev/null
+++ b/test/testblitspeed.c
@@ -0,0 +1,420 @@
+/*
+ * Benchmarks surface-to-surface blits in various formats.
+ *
+ * Written by Ryan C. Gordon.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+static SDL_Surface *dest = NULL;
+static SDL_Surface *src = NULL;
+static int testSeconds = 10;
+
+
+static int percent(int val, int total)
+{
+ return((int) ((((float) val) / ((float) total)) * 100.0f));
+}
+
+static int randRange(int lo, int hi)
+{
+ return(lo + (int) (((double) hi)*rand()/(RAND_MAX+1.0)));
+}
+
+static void copy_trunc_str(char *str, size_t strsize, const char *flagstr)
+{
+ if ( (strlen(str) + strlen(flagstr)) >= (strsize - 1) )
+ strcpy(str + (strsize - 5), " ...");
+ else
+ strcat(str, flagstr);
+}
+
+static void __append_sdl_surface_flag(SDL_Surface *_surface, char *str,
+ size_t strsize, Uint32 flag,
+ const char *flagstr)
+{
+ if (_surface->flags & flag)
+ copy_trunc_str(str, strsize, flagstr);
+}
+
+
+#define append_sdl_surface_flag(a, b, c, fl) __append_sdl_surface_flag(a, b, c, fl, " " #fl)
+#define print_tf_state(str, val) printf("%s: {%s}\n", str, (val) ? "true" : "false" )
+
+static void output_videoinfo_details(void)
+{
+ const SDL_VideoInfo *info = SDL_GetVideoInfo();
+ printf("SDL_GetVideoInfo():\n");
+ if (info == NULL)
+ printf(" (null.)\n");
+ else
+ {
+ print_tf_state(" hardware surface available", info->hw_available);
+ print_tf_state(" window manager available", info->wm_available);
+ print_tf_state(" accelerated hardware->hardware blits", info->blit_hw);
+ print_tf_state(" accelerated hardware->hardware colorkey blits", info->blit_hw_CC);
+ print_tf_state(" accelerated hardware->hardware alpha blits", info->blit_hw_A);
+ print_tf_state(" accelerated software->hardware blits", info->blit_sw);
+ print_tf_state(" accelerated software->hardware colorkey blits", info->blit_sw_CC);
+ print_tf_state(" accelerated software->hardware alpha blits", info->blit_sw_A);
+ print_tf_state(" accelerated color fills", info->blit_fill);
+ printf(" video memory: (%d)\n", info->video_mem);
+ }
+
+ printf("\n");
+}
+
+static void output_surface_details(const char *name, SDL_Surface *surface)
+{
+ printf("Details for %s:\n", name);
+
+ if (surface == NULL)
+ {
+ printf("-WARNING- You've got a NULL surface!");
+ }
+ else
+ {
+ char f[256];
+ printf(" width : %d\n", surface->w);
+ printf(" height : %d\n", surface->h);
+ printf(" depth : %d bits per pixel\n", surface->format->BitsPerPixel);
+ printf(" pitch : %d\n", (int) surface->pitch);
+ printf(" alpha : %d\n", (int) surface->format->alpha);
+ printf(" colorkey : 0x%X\n", (unsigned int) surface->format->colorkey);
+
+ printf(" red bits : 0x%08X mask, %d shift, %d loss\n",
+ (int) surface->format->Rmask,
+ (int) surface->format->Rshift,
+ (int) surface->format->Rloss);
+ printf(" green bits : 0x%08X mask, %d shift, %d loss\n",
+ (int) surface->format->Gmask,
+ (int) surface->format->Gshift,
+ (int) surface->format->Gloss);
+ printf(" blue bits : 0x%08X mask, %d shift, %d loss\n",
+ (int) surface->format->Bmask,
+ (int) surface->format->Bshift,
+ (int) surface->format->Bloss);
+ printf(" alpha bits : 0x%08X mask, %d shift, %d loss\n",
+ (int) surface->format->Amask,
+ (int) surface->format->Ashift,
+ (int) surface->format->Aloss);
+
+ f[0] = '\0';
+
+ /*append_sdl_surface_flag(surface, f, sizeof (f), SDL_SWSURFACE);*/
+ if ((surface->flags & SDL_HWSURFACE) == 0)
+ copy_trunc_str(f, sizeof (f), " SDL_SWSURFACE");
+
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_HWSURFACE);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_ASYNCBLIT);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_ANYFORMAT);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_HWPALETTE);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_DOUBLEBUF);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_FULLSCREEN);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_OPENGL);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_OPENGLBLIT);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_RESIZABLE);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_NOFRAME);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_HWACCEL);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_SRCCOLORKEY);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_RLEACCELOK);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_RLEACCEL);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_SRCALPHA);
+ append_sdl_surface_flag(surface, f, sizeof (f), SDL_PREALLOC);
+
+ if (f[0] == '\0')
+ strcpy(f, " (none)");
+
+ printf(" flags :%s\n", f);
+ }
+
+ printf("\n");
+}
+
+static void output_details(void)
+{
+ output_videoinfo_details();
+ output_surface_details("Source Surface", src);
+ output_surface_details("Destination Surface", dest);
+}
+
+static Uint32 blit(SDL_Surface *dst, SDL_Surface *src, int x, int y)
+{
+ Uint32 start = 0;
+ SDL_Rect srcRect;
+ SDL_Rect dstRect;
+
+ srcRect.x = 0;
+ srcRect.y = 0;
+ dstRect.x = x;
+ dstRect.y = y;
+ dstRect.w = srcRect.w = src->w; /* SDL will clip as appropriate. */
+ dstRect.h = srcRect.h = src->h;
+
+ start = SDL_GetTicks();
+ SDL_BlitSurface(src, &srcRect, dst, &dstRect);
+ return(SDL_GetTicks() - start);
+}
+
+static void blitCentered(SDL_Surface *dst, SDL_Surface *src)
+{
+ int x = (dst->w - src->w) / 2;
+ int y = (dst->h - src->h) / 2;
+ blit(dst, src, x, y);
+}
+
+static int atoi_hex(const char *str)
+{
+ if (str == NULL)
+ return 0;
+
+ if (strlen(str) > 2)
+ {
+ int retval = 0;
+ if ((str[0] == '0') && (str[1] == 'x'))
+ sscanf(str + 2, "%X", &retval);
+ return(retval);
+ }
+
+ return(atoi(str));
+}
+
+
+static int setup_test(int argc, char **argv)
+{
+ const char *dumpfile = NULL;
+ SDL_Surface *bmp = NULL;
+ Uint32 dstbpp = 32;
+ Uint32 dstrmask = 0x00FF0000;
+ Uint32 dstgmask = 0x0000FF00;
+ Uint32 dstbmask = 0x000000FF;
+ Uint32 dstamask = 0x00000000;
+ Uint32 dstflags = 0;
+ int dstw = 640;
+ int dsth = 480;
+ Uint32 srcbpp = 32;
+ Uint32 srcrmask = 0x00FF0000;
+ Uint32 srcgmask = 0x0000FF00;
+ Uint32 srcbmask = 0x000000FF;
+ Uint32 srcamask = 0x00000000;
+ Uint32 srcflags = 0;
+ int srcw = 640;
+ int srch = 480;
+ Uint32 origsrcalphaflags = 0;
+ Uint32 origdstalphaflags = 0;
+ Uint32 srcalphaflags = 0;
+ Uint32 dstalphaflags = 0;
+ int srcalpha = 255;
+ int dstalpha = 255;
+ int screenSurface = 0;
+ int i = 0;
+
+ for (i = 1; i < argc; i++)
+ {
+ const char *arg = argv[i];
+
+ if (strcmp(arg, "--dstbpp") == 0)
+ dstbpp = atoi(argv[++i]);
+ else if (strcmp(arg, "--dstrmask") == 0)
+ dstrmask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--dstgmask") == 0)
+ dstgmask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--dstbmask") == 0)
+ dstbmask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--dstamask") == 0)
+ dstamask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--dstwidth") == 0)
+ dstw = atoi(argv[++i]);
+ else if (strcmp(arg, "--dstheight") == 0)
+ dsth = atoi(argv[++i]);
+ else if (strcmp(arg, "--dsthwsurface") == 0)
+ dstflags |= SDL_HWSURFACE;
+ else if (strcmp(arg, "--srcbpp") == 0)
+ srcbpp = atoi(argv[++i]);
+ else if (strcmp(arg, "--srcrmask") == 0)
+ srcrmask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--srcgmask") == 0)
+ srcgmask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--srcbmask") == 0)
+ srcbmask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--srcamask") == 0)
+ srcamask = atoi_hex(argv[++i]);
+ else if (strcmp(arg, "--srcwidth") == 0)
+ srcw = atoi(argv[++i]);
+ else if (strcmp(arg, "--srcheight") == 0)
+ srch = atoi(argv[++i]);
+ else if (strcmp(arg, "--srchwsurface") == 0)
+ srcflags |= SDL_HWSURFACE;
+ else if (strcmp(arg, "--seconds") == 0)
+ testSeconds = atoi(argv[++i]);
+ else if (strcmp(arg, "--screen") == 0)
+ screenSurface = 1;
+ else if (strcmp(arg, "--dumpfile") == 0)
+ dumpfile = argv[++i];
+ /* !!! FIXME: set colorkey. */
+ else if (0) /* !!! FIXME: we handle some commandlines elsewhere now */
+ {
+ fprintf(stderr, "Unknown commandline option: %s\n", arg);
+ return(0);
+ }
+ }
+
+ if (SDL_Init(SDL_INIT_VIDEO) == -1)
+ {
+ fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
+ return(0);
+ }
+
+ bmp = SDL_LoadBMP("sample.bmp");
+ if (bmp == NULL)
+ {
+ fprintf(stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError());
+ SDL_Quit();
+ return(0);
+ }
+
+ if ((dstflags & SDL_HWSURFACE) == 0) dstflags |= SDL_SWSURFACE;
+ if ((srcflags & SDL_HWSURFACE) == 0) srcflags |= SDL_SWSURFACE;
+
+ if (screenSurface)
+ dest = SDL_SetVideoMode(dstw, dsth, dstbpp, dstflags);
+ else
+ {
+ dest = SDL_CreateRGBSurface(dstflags, dstw, dsth, dstbpp,
+ dstrmask, dstgmask, dstbmask, dstamask);
+ }
+
+ if (dest == NULL)
+ {
+ fprintf(stderr, "dest surface creation failed: %s\n", SDL_GetError());
+ SDL_Quit();
+ return(0);
+ }
+
+ src = SDL_CreateRGBSurface(srcflags, srcw, srch, srcbpp,
+ srcrmask, srcgmask, srcbmask, srcamask);
+ if (src == NULL)
+ {
+ fprintf(stderr, "src surface creation failed: %s\n", SDL_GetError());
+ SDL_Quit();
+ return(0);
+ }
+
+ /* handle alpha settings... */
+ srcalphaflags = (src->flags&SDL_SRCALPHA) | (src->flags&SDL_RLEACCEL);
+ dstalphaflags = (dest->flags&SDL_SRCALPHA) | (dest->flags&SDL_RLEACCEL);
+ origsrcalphaflags = srcalphaflags;
+ origdstalphaflags = dstalphaflags;
+ srcalpha = src->format->alpha;
+ dstalpha = dest->format->alpha;
+ for (i = 1; i < argc; i++)
+ {
+ const char *arg = argv[i];
+
+ if (strcmp(arg, "--srcalpha") == 0)
+ srcalpha = atoi(argv[++i]);
+ else if (strcmp(arg, "--dstalpha") == 0)
+ dstalpha = atoi(argv[++i]);
+ else if (strcmp(arg, "--srcsrcalpha") == 0)
+ srcalphaflags |= SDL_SRCALPHA;
+ else if (strcmp(arg, "--srcnosrcalpha") == 0)
+ srcalphaflags &= ~SDL_SRCALPHA;
+ else if (strcmp(arg, "--srcrleaccel") == 0)
+ srcalphaflags |= SDL_RLEACCEL;
+ else if (strcmp(arg, "--srcnorleaccel") == 0)
+ srcalphaflags &= ~SDL_RLEACCEL;
+ else if (strcmp(arg, "--dstsrcalpha") == 0)
+ dstalphaflags |= SDL_SRCALPHA;
+ else if (strcmp(arg, "--dstnosrcalpha") == 0)
+ dstalphaflags &= ~SDL_SRCALPHA;
+ else if (strcmp(arg, "--dstrleaccel") == 0)
+ dstalphaflags |= SDL_RLEACCEL;
+ else if (strcmp(arg, "--dstnorleaccel") == 0)
+ dstalphaflags &= ~SDL_RLEACCEL;
+ }
+ if ((dstalphaflags != origdstalphaflags) || (dstalpha != dest->format->alpha))
+ SDL_SetAlpha(dest, dstalphaflags, (Uint8) dstalpha);
+ if ((srcalphaflags != origsrcalphaflags) || (srcalpha != src->format->alpha))
+ SDL_SetAlpha(src, srcalphaflags, (Uint8) srcalpha);
+
+ /* set some sane defaults so we can see if the blit code is broken... */
+ SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
+ SDL_FillRect(src, NULL, SDL_MapRGB(src->format, 0, 0, 0));
+
+ blitCentered(src, bmp);
+ SDL_FreeSurface(bmp);
+
+ if (dumpfile)
+ SDL_SaveBMP(src, dumpfile); /* make sure initial convert is sane. */
+
+ output_details();
+
+ return(1);
+}
+
+
+static void test_blit_speed(void)
+{
+ Uint32 clearColor = SDL_MapRGB(dest->format, 0, 0, 0);
+ Uint32 iterations = 0;
+ Uint32 elasped = 0;
+ Uint32 end = 0;
+ Uint32 now = 0;
+ Uint32 last = 0;
+ int testms = testSeconds * 1000;
+ int wmax = (dest->w - src->w);
+ int hmax = (dest->h - src->h);
+ int isScreen = (SDL_GetVideoSurface() == dest);
+ SDL_Event event;
+
+ printf("Testing blit speed for %d seconds...\n", testSeconds);
+
+ now = SDL_GetTicks();
+ end = now + testms;
+
+ do
+ {
+ /* pump the event queue occasionally to keep OS happy... */
+ if (now - last > 1000)
+ {
+ last = now;
+ while (SDL_PollEvent(&event)) { /* no-op. */ }
+ }
+
+ iterations++;
+ elasped += blit(dest, src, randRange(0, wmax), randRange(0, hmax));
+ if (isScreen)
+ {
+ SDL_Flip(dest); /* show it! */
+ SDL_FillRect(dest, NULL, clearColor); /* blank it for next time! */
+ }
+
+ now = SDL_GetTicks();
+ } while (now < end);
+
+ printf("Non-blitting crap accounted for %d percent of this run.\n",
+ percent(testms - elasped, testms));
+
+ printf("%d blits took %d ms (%d fps).\n",
+ (int) iterations,
+ (int) elasped,
+ (int) (((float)iterations) / (((float)elasped) / 1000.0f)));
+}
+
+int main(int argc, char **argv)
+{
+ int initialized = setup_test(argc, argv);
+ if (initialized)
+ {
+ test_blit_speed();
+ SDL_Quit();
+ }
+ return(!initialized);
+}
+
+/* end of testblitspeed.c ... */
+
diff --git a/test/testcdrom.c b/test/testcdrom.c
new file mode 100644
index 0000000..782a66c
--- /dev/null
+++ b/test/testcdrom.c
@@ -0,0 +1,209 @@
+
+/* Test the SDL CD-ROM audio functions */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "SDL.h"
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+static void PrintStatus(int driveindex, SDL_CD *cdrom)
+{
+ CDstatus status;
+ char *status_str;
+
+ status = SDL_CDStatus(cdrom);
+ switch (status) {
+ case CD_TRAYEMPTY:
+ status_str = "tray empty";
+ break;
+ case CD_STOPPED:
+ status_str = "stopped";
+ break;
+ case CD_PLAYING:
+ status_str = "playing";
+ break;
+ case CD_PAUSED:
+ status_str = "paused";
+ break;
+ case CD_ERROR:
+ status_str = "error state";
+ break;
+ }
+ printf("Drive %d status: %s\n", driveindex, status_str);
+ if ( status >= CD_PLAYING ) {
+ int m, s, f;
+ FRAMES_TO_MSF(cdrom->cur_frame, &m, &s, &f);
+ printf("Currently playing track %d, %d:%2.2d\n",
+ cdrom->track[cdrom->cur_track].id, m, s);
+ }
+}
+
+static void ListTracks(SDL_CD *cdrom)
+{
+ int i;
+ int m, s, f;
+ char* trtype;
+
+ SDL_CDStatus(cdrom);
+ printf("Drive tracks: %d\n", cdrom->numtracks);
+ for ( i=0; i<cdrom->numtracks; ++i ) {
+ FRAMES_TO_MSF(cdrom->track[i].length, &m, &s, &f);
+ if ( f > 0 )
+ ++s;
+ switch(cdrom->track[i].type)
+ {
+ case SDL_AUDIO_TRACK:
+ trtype="audio";
+ break;
+ case SDL_DATA_TRACK:
+ trtype="data";
+ break;
+ default:
+ trtype="unknown";
+ break;
+ }
+ printf("\tTrack (index %d) %d: %d:%2.2d / %d [%s track]\n", i,
+ cdrom->track[i].id, m, s, cdrom->track[i].length, trtype);
+ }
+}
+
+static void PrintUsage(char *argv0)
+{
+ fprintf(stderr, "Usage: %s [drive#] [command] [command] ...\n", argv0);
+ fprintf(stderr, "Where 'command' is one of:\n");
+ fprintf(stderr, " -status\n");
+ fprintf(stderr, " -list\n");
+ fprintf(stderr, " -play [first_track] [first_frame] [num_tracks] [num_frames]\n");
+ fprintf(stderr, " -pause\n");
+ fprintf(stderr, " -resume\n");
+ fprintf(stderr, " -stop\n");
+ fprintf(stderr, " -eject\n");
+ fprintf(stderr, " -sleep <milliseconds>\n");
+}
+
+int main(int argc, char *argv[])
+{
+ int drive;
+ int i;
+ SDL_CD *cdrom;
+
+ /* Initialize SDL first */
+ if ( SDL_Init(SDL_INIT_CDROM) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ /* Find out how many CD-ROM drives are connected to the system */
+ if ( SDL_CDNumDrives() == 0 ) {
+ printf("No CD-ROM devices detected\n");
+ quit(0);
+ }
+ printf("Drives available: %d\n", SDL_CDNumDrives());
+ for ( i=0; i<SDL_CDNumDrives(); ++i ) {
+ printf("Drive %d: \"%s\"\n", i, SDL_CDName(i));
+ }
+
+ /* Open the CD-ROM */
+ drive = 0;
+ i=1;
+ if ( argv[i] && isdigit(argv[i][0]) ) {
+ drive = atoi(argv[i++]);
+ }
+ cdrom = SDL_CDOpen(drive);
+ if ( cdrom == NULL ) {
+ fprintf(stderr, "Couldn't open drive %d: %s\n", drive,
+ SDL_GetError());
+ quit(2);
+ }
+#ifdef TEST_NULLCD
+ cdrom = NULL;
+#endif
+
+ /* Find out which function to perform */
+ for ( ; argv[i]; ++i ) {
+ if ( strcmp(argv[i], "-status") == 0 ) {
+ /* PrintStatus(drive, cdrom); */
+ } else
+ if ( strcmp(argv[i], "-list") == 0 ) {
+ ListTracks(cdrom);
+ } else
+ if ( strcmp(argv[i], "-play") == 0 ) {
+ int strack, sframe;
+ int ntrack, nframe;
+
+ strack = 0;
+ if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+ strack = atoi(argv[++i]);
+ }
+ sframe = 0;
+ if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+ sframe = atoi(argv[++i]);
+ }
+ ntrack = 0;
+ if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+ ntrack = atoi(argv[++i]);
+ }
+ nframe = 0;
+ if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+ nframe = atoi(argv[++i]);
+ }
+ if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
+ if ( SDL_CDPlayTracks(cdrom, strack, sframe,
+ ntrack, nframe) < 0 ) {
+ fprintf(stderr,
+ "Couldn't play tracks %d/%d for %d/%d: %s\n",
+ strack, sframe, ntrack, nframe, SDL_GetError());
+ }
+ } else {
+ fprintf(stderr, "No CD in drive!\n");
+ }
+ } else
+ if ( strcmp(argv[i], "-pause") == 0 ) {
+ if ( SDL_CDPause(cdrom) < 0 ) {
+ fprintf(stderr, "Couldn't pause CD: %s\n",
+ SDL_GetError());
+ }
+ } else
+ if ( strcmp(argv[i], "-resume") == 0 ) {
+ if ( SDL_CDResume(cdrom) < 0 ) {
+ fprintf(stderr, "Couldn't resume CD: %s\n",
+ SDL_GetError());
+ }
+ } else
+ if ( strcmp(argv[i], "-stop") == 0 ) {
+ if ( SDL_CDStop(cdrom) < 0 ) {
+ fprintf(stderr, "Couldn't eject CD: %s\n",
+ SDL_GetError());
+ }
+ } else
+ if ( strcmp(argv[i], "-eject") == 0 ) {
+ if ( SDL_CDEject(cdrom) < 0 ) {
+ fprintf(stderr, "Couldn't eject CD: %s\n",
+ SDL_GetError());
+ }
+ } else
+ if ( (strcmp(argv[i], "-sleep") == 0) &&
+ (argv[i+1] && isdigit(argv[i+1][0])) ) {
+ SDL_Delay(atoi(argv[++i]));
+ printf("Delayed %d milliseconds\n", atoi(argv[i]));
+ } else {
+ PrintUsage(argv[0]);
+ SDL_CDClose(cdrom);
+ quit(1);
+ }
+ }
+ PrintStatus(drive, cdrom);
+ SDL_CDClose(cdrom);
+ SDL_Quit();
+
+ return(0);
+}
diff --git a/test/testcursor.c b/test/testcursor.c
new file mode 100644
index 0000000..010e0a6
--- /dev/null
+++ b/test/testcursor.c
@@ -0,0 +1,216 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL.h"
+
+/* This is an example 16x16 cursor
+ top left : black
+ top right : inverted color or black
+ bottom left: white
+ bottom right: transparent
+ (swap left and right for different endianness)
+*/
+
+Uint16 cursor_data[16]={
+ 0xffff,
+ 0xffff,
+ 0xffff,
+ 0xffff,
+
+ 0xffff,
+ 0xffff,
+ 0xffff,
+ 0xffff,
+
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000
+};
+
+Uint16 cursor_mask[16]={
+ 0xff00,
+ 0xff00,
+ 0xff00,
+ 0xff00,
+
+ 0xff00,
+ 0xff00,
+ 0xff00,
+ 0xff00,
+
+ 0xff00,
+ 0xff00,
+ 0xff00,
+ 0xff00,
+
+ 0xff00,
+ 0xff00,
+ 0xff00,
+ 0xff00
+};
+
+/* another test cursor: smaller than 16x16, and with an odd height */
+
+Uint8 small_cursor_data[11] = { 0x00, 0x18, 0x08, 0x38, 0x44, 0x54, 0x44, 0x38, 0x20, 0x20, 0x00 };
+Uint8 small_cursor_mask[11] = { 0x3C, 0x3C, 0x3C, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x78, 0x70, 0x70 };
+
+/* XPM */
+static const char *arrow[] = {
+ /* width height num_colors chars_per_pixel */
+ " 32 32 3 1",
+ /* colors */
+ "X c #000000",
+ ". c #ffffff",
+ " c None",
+ /* pixels */
+ "X ",
+ "XX ",
+ "X.X ",
+ "X..X ",
+ "X...X ",
+ "X....X ",
+ "X.....X ",
+ "X......X ",
+ "X.......X ",
+ "X........X ",
+ "X.....XXXXX ",
+ "X..X..X ",
+ "X.X X..X ",
+ "XX X..X ",
+ "X X..X ",
+ " X..X ",
+ " X..X ",
+ " X..X ",
+ " XX ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ "0,0"
+};
+
+static SDL_Cursor *create_arrow_cursor()
+{
+ int i, row, col;
+ Uint8 data[4*32];
+ Uint8 mask[4*32];
+ int hot_x, hot_y;
+
+ i = -1;
+ for ( row=0; row<32; ++row ) {
+ for ( col=0; col<32; ++col ) {
+ if ( col % 8 ) {
+ data[i] <<= 1;
+ mask[i] <<= 1;
+ } else {
+ ++i;
+ data[i] = mask[i] = 0;
+ }
+ switch (arrow[4+row][col]) {
+ case 'X':
+ data[i] |= 0x01;
+ mask[i] |= 0x01;
+ break;
+ case '.':
+ mask[i] |= 0x01;
+ break;
+ case ' ':
+ break;
+ }
+ }
+ }
+ sscanf(arrow[4+row], "%d,%d", &hot_x, &hot_y);
+ return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
+}
+
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+ SDL_bool quit = SDL_FALSE, first_time = SDL_TRUE;
+ SDL_Cursor *cursor[3];
+ int current;
+
+ /* Load the SDL library */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ screen = SDL_SetVideoMode(320,200,8,SDL_ANYFORMAT);
+ if (screen==NULL) {
+ fprintf(stderr, "Couldn't initialize video mode: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ SDL_FillRect(screen, NULL, 0x664422);
+
+ cursor[0] = SDL_CreateCursor((Uint8 *)cursor_data, (Uint8 *)cursor_mask,
+ 16, 16, 8, 8);
+ if (cursor[0]==NULL) {
+ fprintf(stderr, "Couldn't initialize test cursor: %s\n",SDL_GetError());
+ SDL_Quit();
+ return(1);
+ }
+ cursor[1] = create_arrow_cursor();
+ if (cursor[1]==NULL) {
+ fprintf(stderr, "Couldn't initialize arrow cursor: %s\n",SDL_GetError());
+ SDL_FreeCursor(cursor[0]);
+ SDL_Quit();
+ return(1);
+ }
+ cursor[2] = SDL_CreateCursor(small_cursor_data, small_cursor_mask,
+ 8, 11, 3, 5);
+ if (cursor[2]==NULL) {
+ fprintf(stderr, "Couldn't initialize test cursor: %s\n",SDL_GetError());
+ SDL_Quit();
+ return(1);
+ }
+
+ current = 0;
+ SDL_SetCursor(cursor[current]);
+
+ while (!quit) {
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ switch(event.type) {
+ case SDL_MOUSEBUTTONDOWN:
+ current = (current + 1)%3;
+ SDL_SetCursor(cursor[current]);
+ break;
+ case SDL_KEYDOWN:
+ if (event.key.keysym.sym == SDLK_ESCAPE) {
+ quit = SDL_TRUE;
+ }
+ break;
+ case SDL_QUIT:
+ quit = SDL_TRUE;
+ break;
+ }
+ }
+ SDL_Flip(screen);
+ SDL_Delay(1);
+ }
+
+ SDL_FreeCursor(cursor[0]);
+ SDL_FreeCursor(cursor[1]);
+ SDL_FreeCursor(cursor[2]);
+
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testdyngl.c b/test/testdyngl.c
new file mode 100644
index 0000000..a20bd1a
--- /dev/null
+++ b/test/testdyngl.c
@@ -0,0 +1,209 @@
+/*
+ * Small SDL example to demonstrate dynamically loading
+ * OpenGL lib and functions
+ *
+ * (FYI it was supposed to look like snow in the wind or something...)
+ *
+ * Compile with :
+ * gcc testdyngl.c `sdl-config --libs --cflags` -o testdyngl -DHAVE_OPENGL
+ *
+ * You can specify a different OpenGL lib on the command line, i.e. :
+ * ./testdyngl /usr/X11R6/lib/libGL.so.1.2
+ * or
+ * ./testdyngl /usr/lib/libGL.so.1.0.4496
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL.h"
+
+#ifdef __MACOS__
+#define HAVE_OPENGL
+#endif
+
+#ifdef HAVE_OPENGL
+
+#include "SDL_opengl.h"
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+void* get_funcaddr(const char* p)
+{
+ void* f=SDL_GL_GetProcAddress(p);
+ if (f)
+ {
+ return f;
+ }
+ else
+ {
+ printf("Unable to get function pointer for %s\n",p);
+ quit(1);
+ }
+ return NULL;
+}
+
+typedef struct
+{
+ void(APIENTRY*glBegin)(GLenum);
+ void(APIENTRY*glEnd)();
+ void(APIENTRY*glVertex3f)(GLfloat, GLfloat, GLfloat);
+ void(APIENTRY*glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);
+ void(APIENTRY*glClear)(GLbitfield);
+ void(APIENTRY*glDisable)(GLenum);
+ void(APIENTRY*glEnable)(GLenum);
+ void(APIENTRY*glColor4ub)(GLubyte,GLubyte,GLubyte,GLubyte);
+ void(APIENTRY*glPointSize)(GLfloat);
+ void(APIENTRY*glHint)(GLenum,GLenum);
+ void(APIENTRY*glBlendFunc)(GLenum,GLenum);
+ void(APIENTRY*glMatrixMode)(GLenum);
+ void(APIENTRY*glLoadIdentity)();
+ void(APIENTRY*glOrtho)(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble);
+ void(APIENTRY*glRotatef)(GLfloat,GLfloat,GLfloat,GLfloat);
+ void(APIENTRY*glViewport)(GLint,GLint,GLsizei,GLsizei);
+ void(APIENTRY*glFogf)(GLenum,GLfloat);
+}
+glfuncs;
+
+void init_glfuncs(glfuncs* f)
+{
+ f->glBegin=get_funcaddr("glBegin");
+ f->glEnd=get_funcaddr("glEnd");
+ f->glVertex3f=get_funcaddr("glVertex3f");
+ f->glClearColor=get_funcaddr("glClearColor");
+ f->glClear=get_funcaddr("glClear");
+ f->glDisable=get_funcaddr("glDisable");
+ f->glEnable=get_funcaddr("glEnable");
+ f->glColor4ub=get_funcaddr("glColor4ub");
+ f->glPointSize=get_funcaddr("glPointSize");
+ f->glHint=get_funcaddr("glHint");
+ f->glBlendFunc=get_funcaddr("glBlendFunc");
+ f->glMatrixMode=get_funcaddr("glMatrixMode");
+ f->glLoadIdentity=get_funcaddr("glLoadIdentity");
+ f->glOrtho=get_funcaddr("glOrtho");
+ f->glRotatef=get_funcaddr("glRotatef");
+ f->glViewport=get_funcaddr("glViewport");
+ f->glFogf=get_funcaddr("glFogf");
+}
+
+#define NB_PIXELS 1000
+
+int main(int argc,char *argv[])
+{
+ glfuncs f;
+ int i;
+ SDL_Event event;
+ int done=0;
+ GLfloat pixels[NB_PIXELS*3];
+ const char *gl_library = NULL; /* Use the default GL library */
+
+ if (argv[1]) {
+ gl_library = argv[1];
+ }
+
+ if (SDL_Init(SDL_INIT_VIDEO)<0)
+ {
+ printf("Unable to init SDL : %s\n",SDL_GetError());
+ return(1);
+ }
+
+ if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1)<0)
+ {
+ printf("Unable to set GL attribute : %s\n",SDL_GetError());
+ quit(1);
+ }
+
+ if (SDL_GL_LoadLibrary(gl_library)<0)
+ {
+ printf("Unable to dynamically open GL lib : %s\n",SDL_GetError());
+ quit(1);
+ }
+
+ if (SDL_SetVideoMode(640,480,0,SDL_OPENGL)==NULL)
+ {
+ printf("Unable to open video mode : %s\n",SDL_GetError());
+ quit(1);
+ }
+
+ /* Set the window manager title bar */
+ SDL_WM_SetCaption( "SDL Dynamic OpenGL Loading Test", "testdyngl" );
+
+ init_glfuncs(&f);
+
+ for(i=0;i<NB_PIXELS;i++)
+ {
+ pixels[3*i]=rand()%250-125;
+ pixels[3*i+1]=rand()%250-125;
+ pixels[3*i+2]=rand()%250-125;
+ }
+
+ f.glViewport(0,0,640,480);
+
+ f.glMatrixMode(GL_PROJECTION);
+ f.glLoadIdentity();
+ f.glOrtho(-100,100,-100,100,-500,500);
+
+ f.glMatrixMode(GL_MODELVIEW);
+ f.glLoadIdentity();
+
+ f.glEnable(GL_DEPTH_TEST);
+ f.glDisable(GL_TEXTURE_2D);
+ f.glEnable(GL_BLEND);
+ f.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ f.glClearColor(0.0f,0.0f,0.0f,0.0f);
+ f.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+
+ f.glEnable(GL_POINT_SMOOTH);
+ f.glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
+ f.glPointSize(5.0f);
+ f.glEnable(GL_FOG);
+ f.glFogf(GL_FOG_START,-500);
+ f.glFogf(GL_FOG_END,500);
+ f.glFogf(GL_FOG_DENSITY,0.005);
+
+ do
+ {
+ f.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+
+ f.glRotatef(2.0,1.0,1.0,1.0);
+ f.glRotatef(1.0,0.0,1.0,1.0);
+
+ f.glColor4ub(255,255,255,255);
+ f.glBegin(GL_POINTS);
+ for(i=0;i<NB_PIXELS;i++)
+ {
+ f.glVertex3f(pixels[3*i],pixels[3*i+1],pixels[3*i+2]);
+ }
+ f.glEnd();
+ SDL_GL_SwapBuffers();
+
+ while(SDL_PollEvent(&event))
+ {
+ if(event.type & SDL_KEYDOWN)
+ done=1;
+ }
+
+ SDL_Delay(20);
+ }
+ while(!done);
+
+ SDL_Quit();
+ return 0;
+}
+
+#else /* HAVE_OPENGL */
+
+int main(int argc, char *argv[])
+{
+ printf("No OpenGL support on this system\n");
+ return 1;
+}
+
+#endif /* HAVE_OPENGL */
diff --git a/test/testerror.c b/test/testerror.c
new file mode 100644
index 0000000..9211dfc
--- /dev/null
+++ b/test/testerror.c
@@ -0,0 +1,61 @@
+
+/* Simple test of the SDL threading code and error handling */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+static int alive = 0;
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+int SDLCALL ThreadFunc(void *data)
+{
+ /* Set the child thread error string */
+ SDL_SetError("Thread %s (%d) had a problem: %s",
+ (char *)data, SDL_ThreadID(), "nevermind");
+ while ( alive ) {
+ printf("Thread '%s' is alive!\n", (char *)data);
+ SDL_Delay(1*1000);
+ }
+ printf("Child thread error string: %s\n", SDL_GetError());
+ return(0);
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Thread *thread;
+
+ /* Load the SDL library */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ /* Set the error value for the main thread */
+ SDL_SetError("No worries");
+
+ alive = 1;
+ thread = SDL_CreateThread(ThreadFunc, "#1");
+ if ( thread == NULL ) {
+ fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ quit(1);
+ }
+ SDL_Delay(5*1000);
+ printf("Waiting for thread #1\n");
+ alive = 0;
+ SDL_WaitThread(thread, NULL);
+
+ printf("Main thread error string: %s\n", SDL_GetError());
+
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testfile.c b/test/testfile.c
new file mode 100644
index 0000000..ecebb7d
--- /dev/null
+++ b/test/testfile.c
@@ -0,0 +1,182 @@
+
+/* sanity tests on SDL_rwops.c (usefull for alternative implementations of stdio rwops) */
+
+#include <stdlib.h>
+
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+
+#include "SDL.h"
+#include "SDL_endian.h"
+
+
+#include <stdio.h>
+
+/* WARNING ! those 2 files will be destroyed by this test program */
+#define FBASENAME1 "sdldata1" /* this file will be created during tests */
+#define FBASENAME2 "sdldata2" /* this file should not exists before starting test */
+
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+static void cleanup( void ) {
+
+ unlink(FBASENAME1);
+ unlink(FBASENAME2);
+}
+
+static void rwops_error_quit( unsigned line, SDL_RWops *rwops) {
+
+ printf("testfile.c(%d): failed\n",line);
+ if (rwops) {
+ rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */
+ }
+ cleanup();
+ exit(1); /* quit with rwops error (test failed) */
+}
+
+#define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) )
+
+
+
+int main(int argc, char *argv[])
+{
+ SDL_RWops *rwops = NULL;
+ char test_buf[30];
+
+ cleanup();
+
+/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
+
+ rwops = SDL_RWFromFile(NULL,NULL);
+ if (rwops) RWOP_ERR_QUIT(rwops);
+ rwops = SDL_RWFromFile(NULL,"ab+");
+ if (rwops) RWOP_ERR_QUIT(rwops);
+ rwops = SDL_RWFromFile(NULL,"sldfkjsldkfj");
+ if (rwops) RWOP_ERR_QUIT(rwops);
+ rwops = SDL_RWFromFile("something","");
+ if (rwops) RWOP_ERR_QUIT(rwops);
+ rwops = SDL_RWFromFile("something",NULL);
+ if (rwops) RWOP_ERR_QUIT(rwops);
+ printf("test1 OK\n");
+
+/* test 2 : check that inexistant file is not successfully opened/created when required */
+/* modes : r, r+ implie that file MUST exist
+ modes : a, a+, w, w+ checks that it succeeds (file may not exists)
+
+ */
+ rwops = SDL_RWFromFile(FBASENAME2,"rb"); /* this file doesn't exist that call must fail */
+ if (rwops) RWOP_ERR_QUIT(rwops);
+ rwops = SDL_RWFromFile(FBASENAME2,"rb+"); /* this file doesn't exist that call must fail */
+ if (rwops) RWOP_ERR_QUIT(rwops);
+ rwops = SDL_RWFromFile(FBASENAME2,"wb");
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ rwops->close(rwops); unlink(FBASENAME2);
+ rwops = SDL_RWFromFile(FBASENAME2,"wb+");
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ rwops->close(rwops); unlink(FBASENAME2);
+ rwops = SDL_RWFromFile(FBASENAME2,"ab");
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ rwops->close(rwops); unlink(FBASENAME2);
+ rwops = SDL_RWFromFile(FBASENAME2,"ab+");
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ rwops->close(rwops); unlink(FBASENAME2);
+ printf("test2 OK\n");
+
+/* test 3 : creation, writing , reading, seeking,
+ test : w mode, r mode, w+ mode
+ */
+ rwops = SDL_RWFromFile(FBASENAME1,"wb"); /* write only */
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ if (1 != rwops->write(rwops,"1234567890",10,1) ) RWOP_ERR_QUIT(rwops);
+ if (10 != rwops->write(rwops,"1234567890",1,10) ) RWOP_ERR_QUIT(rwops);
+ if (7 != rwops->write(rwops,"1234567",1,7) ) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops); /* we are in write only mode */
+ rwops->close(rwops);
+
+ rwops = SDL_RWFromFile(FBASENAME1,"rb"); /* read mode, file must exists */
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+ if (20!=rwops->seek(rwops,-7,RW_SEEK_END)) RWOP_ERR_QUIT(rwops);
+ if (7!=rwops->read(rwops,test_buf,1,7)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"1234567",7)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,10,100)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR)) RWOP_ERR_QUIT(rwops);
+ if (2!=rwops->read(rwops,test_buf,10,3)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"12345678901234567890",20)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->write(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops); /* readonly mode */
+ rwops->close(rwops);
+
+/* test 3: same with w+ mode */
+ rwops = SDL_RWFromFile(FBASENAME1,"wb+"); /* write + read + truncation */
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ if (1 != rwops->write(rwops,"1234567890",10,1) ) RWOP_ERR_QUIT(rwops);
+ if (10 != rwops->write(rwops,"1234567890",1,10) ) RWOP_ERR_QUIT(rwops);
+ if (7 != rwops->write(rwops,"1234567",1,7) ) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+ if (1!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+ if (20!=rwops->seek(rwops,-7,RW_SEEK_END)) RWOP_ERR_QUIT(rwops);
+ if (7!=rwops->read(rwops,test_buf,1,7)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"1234567",7)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,10,100)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR)) RWOP_ERR_QUIT(rwops);
+ if (2!=rwops->read(rwops,test_buf,10,3)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"12345678901234567890",20)) RWOP_ERR_QUIT(rwops);
+ rwops->close(rwops);
+ printf("test3 OK\n");
+
+/* test 4: same in r+ mode */
+ rwops = SDL_RWFromFile(FBASENAME1,"rb+"); /* write + read + file must exists, no truncation */
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ if (1 != rwops->write(rwops,"1234567890",10,1) ) RWOP_ERR_QUIT(rwops);
+ if (10 != rwops->write(rwops,"1234567890",1,10) ) RWOP_ERR_QUIT(rwops);
+ if (7 != rwops->write(rwops,"1234567",1,7) ) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+ if (1!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+ if (20!=rwops->seek(rwops,-7,RW_SEEK_END)) RWOP_ERR_QUIT(rwops);
+ if (7!=rwops->read(rwops,test_buf,1,7)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"1234567",7)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,10,100)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR)) RWOP_ERR_QUIT(rwops);
+ if (2!=rwops->read(rwops,test_buf,10,3)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"12345678901234567890",20)) RWOP_ERR_QUIT(rwops);
+ rwops->close(rwops);
+ printf("test4 OK\n");
+
+/* test5 : append mode */
+ rwops = SDL_RWFromFile(FBASENAME1,"ab+"); /* write + read + append */
+ if (!rwops) RWOP_ERR_QUIT(rwops);
+ if (1 != rwops->write(rwops,"1234567890",10,1) ) RWOP_ERR_QUIT(rwops);
+ if (10 != rwops->write(rwops,"1234567890",1,10) ) RWOP_ERR_QUIT(rwops);
+ if (7 != rwops->write(rwops,"1234567",1,7) ) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+
+ if (1!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+
+ if (20+27!=rwops->seek(rwops,-7,RW_SEEK_END)) RWOP_ERR_QUIT(rwops);
+ if (7!=rwops->read(rwops,test_buf,1,7)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"1234567",7)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,1,1)) RWOP_ERR_QUIT(rwops);
+ if (0!=rwops->read(rwops,test_buf,10,100)) RWOP_ERR_QUIT(rwops);
+
+ if (27!=rwops->seek(rwops,-27,RW_SEEK_CUR)) RWOP_ERR_QUIT(rwops);
+
+ if (0!=rwops->seek(rwops,0L,RW_SEEK_SET)) RWOP_ERR_QUIT(rwops);
+ if (3!=rwops->read(rwops,test_buf,10,3)) RWOP_ERR_QUIT(rwops);
+ if (SDL_memcmp(test_buf,"123456789012345678901234567123",30))
+ RWOP_ERR_QUIT(rwops);
+ rwops->close(rwops);
+ printf("test5 OK\n");
+ cleanup();
+ return 0; /* all ok */
+}
diff --git a/test/testgamma.c b/test/testgamma.c
new file mode 100644
index 0000000..70f4b3c
--- /dev/null
+++ b/test/testgamma.c
@@ -0,0 +1,197 @@
+
+/* Bring up a window and manipulate the gamma on it */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include "SDL.h"
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+/* Turn a normal gamma value into an appropriate gamma ramp */
+void CalculateGamma(double gamma, Uint16 *ramp)
+{
+ int i, value;
+
+ gamma = 1.0 / gamma;
+ for ( i=0; i<256; ++i ) {
+ value = (int)(pow((double)i/256.0, gamma)*65535.0 + 0.5);
+ if ( value > 65535 ) {
+ value = 65535;
+ }
+ ramp[i] = (Uint16)value;
+ }
+}
+
+/* This can be used as a general routine for all of the test programs */
+int get_video_args(char *argv[], int *w, int *h, int *bpp, Uint32 *flags)
+{
+ int i;
+
+ *w = 640;
+ *h = 480;
+ *bpp = 0;
+ *flags = SDL_SWSURFACE;
+
+ for ( i=1; argv[i]; ++i ) {
+ if ( strcmp(argv[i], "-width") == 0 ) {
+ if ( argv[i+1] ) {
+ *w = atoi(argv[++i]);
+ }
+ } else
+ if ( strcmp(argv[i], "-height") == 0 ) {
+ if ( argv[i+1] ) {
+ *h = atoi(argv[++i]);
+ }
+ } else
+ if ( strcmp(argv[i], "-bpp") == 0 ) {
+ if ( argv[i+1] ) {
+ *bpp = atoi(argv[++i]);
+ }
+ } else
+ if ( strcmp(argv[i], "-fullscreen") == 0 ) {
+ *flags |= SDL_FULLSCREEN;
+ } else
+ if ( strcmp(argv[i], "-hw") == 0 ) {
+ *flags |= SDL_HWSURFACE;
+ } else
+ if ( strcmp(argv[i], "-hwpalette") == 0 ) {
+ *flags |= SDL_HWPALETTE;
+ } else
+ break;
+ }
+ return i;
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+ SDL_Surface *image;
+ float gamma;
+ int i;
+ int w, h, bpp;
+ Uint32 flags;
+ Uint16 ramp[256];
+ Uint16 red_ramp[256];
+ Uint32 then, timeout;
+
+ /* Check command line arguments */
+ argv += get_video_args(argv, &w, &h, &bpp, &flags);
+
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr,
+ "Couldn't initialize SDL: %s\n", SDL_GetError());
+ return(1);
+ }
+
+ /* Initialize the display, always use hardware palette */
+ screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE);
+ if ( screen == NULL ) {
+ fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
+ w, h, SDL_GetError());
+ quit(1);
+ }
+
+ /* Set the window manager title bar */
+ SDL_WM_SetCaption("SDL gamma test", "testgamma");
+
+ /* Set the desired gamma, if any */
+ gamma = 1.0f;
+ if ( *argv ) {
+ gamma = (float)atof(*argv);
+ }
+ if ( SDL_SetGamma(gamma, gamma, gamma) < 0 ) {
+ fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError());
+ quit(1);
+ }
+
+#if 0 /* This isn't supported. Integrating the gamma ramps isn't exact */
+ /* See what gamma was actually set */
+ float real[3];
+ if ( SDL_GetGamma(&real[0], &real[1], &real[2]) < 0 ) {
+ printf("Couldn't get gamma: %s\n", SDL_GetError());
+ } else {
+ printf("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n",
+ real[0], real[1], real[2]);
+ }
+#endif
+
+ /* Do all the drawing work */
+ image = SDL_LoadBMP("sample.bmp");
+ if ( image ) {
+ SDL_Rect dst;
+
+ dst.x = (screen->w - image->w)/2;
+ dst.y = (screen->h - image->h)/2;
+ dst.w = image->w;
+ dst.h = image->h;
+ SDL_BlitSurface(image, NULL, screen, &dst);
+ SDL_UpdateRects(screen, 1, &dst);
+ }
+
+ /* Wait a bit, handling events */
+ then = SDL_GetTicks();
+ timeout = (5*1000);
+ while ( (SDL_GetTicks()-then) < timeout ) {
+ SDL_Event event;
+
+ while ( SDL_PollEvent(&event) ) {
+ switch (event.type) {
+ case SDL_QUIT: /* Quit now */
+ timeout = 0;
+ break;
+ case SDL_KEYDOWN:
+ switch (event.key.keysym.sym) {
+ case SDLK_SPACE: /* Go longer.. */
+ timeout += (5*1000);
+ break;
+ case SDLK_UP:
+ gamma += 0.2f;
+ SDL_SetGamma(gamma, gamma, gamma);
+ break;
+ case SDLK_DOWN:
+ gamma -= 0.2f;
+ SDL_SetGamma(gamma, gamma, gamma);
+ break;
+ case SDLK_ESCAPE:
+ timeout = 0;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+ }
+
+ /* Perform a gamma flash to red using color ramps */
+ while ( gamma < 10.0 ) {
+ /* Increase the red gamma and decrease everything else... */
+ gamma += 0.1f;
+ CalculateGamma(gamma, red_ramp);
+ CalculateGamma(1.0/gamma, ramp);
+ SDL_SetGammaRamp(red_ramp, ramp, ramp);
+ }
+ /* Finish completely red */
+ memset(red_ramp, 255, sizeof(red_ramp));
+ memset(ramp, 0, sizeof(ramp));
+ SDL_SetGammaRamp(red_ramp, ramp, ramp);
+
+ /* Now fade out to black */
+ for ( i=(red_ramp[0] >> 8); i >= 0; --i ) {
+ memset(red_ramp, i, sizeof(red_ramp));
+ SDL_SetGammaRamp(red_ramp, NULL, NULL);
+ }
+ SDL_Delay(1*1000);
+
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testgl.c b/test/testgl.c
new file mode 100644
index 0000000..34b88cf
--- /dev/null
+++ b/test/testgl.c
@@ -0,0 +1,856 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include "SDL.h"
+
+#ifdef __MACOS__
+#define HAVE_OPENGL
+#endif
+
+#ifdef HAVE_OPENGL
+
+#include "SDL_opengl.h"
+
+/* Undefine this if you want a flat cube instead of a rainbow cube */
+#define SHADED_CUBE
+
+/* Define this to be the name of the logo image to use with -logo */
+#define LOGO_FILE "icon.bmp"
+
+/* The SDL_OPENGLBLIT interface is deprecated.
+ The code is still available for benchmark purposes though.
+*/
+
+static SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
+
+static SDL_Surface *global_image = NULL;
+static GLuint global_texture = 0;
+static GLuint cursor_texture = 0;
+
+/**********************************************************************/
+
+void HotKey_ToggleFullScreen(void)
+{
+ SDL_Surface *screen;
+
+ screen = SDL_GetVideoSurface();
+ if ( SDL_WM_ToggleFullScreen(screen) ) {
+ printf("Toggled fullscreen mode - now %s\n",
+ (screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed");
+ } else {
+ printf("Unable to toggle fullscreen mode\n");
+ }
+}
+
+void HotKey_ToggleGrab(void)
+{
+ SDL_GrabMode mode;
+
+ printf("Ctrl-G: toggling input grab!\n");
+ mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
+ if ( mode == SDL_GRAB_ON ) {
+ printf("Grab was on\n");
+ } else {
+ printf("Grab was off\n");
+ }
+ mode = SDL_WM_GrabInput(!mode);
+ if ( mode == SDL_GRAB_ON ) {
+ printf("Grab is now on\n");
+ } else {
+ printf("Grab is now off\n");
+ }
+}
+
+void HotKey_Iconify(void)
+{
+ printf("Ctrl-Z: iconifying window!\n");
+ SDL_WM_IconifyWindow();
+}
+
+int HandleEvent(SDL_Event *event)
+{
+ int done;
+
+ done = 0;
+ switch( event->type ) {
+ case SDL_ACTIVEEVENT:
+ /* See what happened */
+ printf( "app %s ", event->active.gain ? "gained" : "lost" );
+ if ( event->active.state & SDL_APPACTIVE ) {
+ printf( "active " );
+ } else if ( event->active.state & SDL_APPMOUSEFOCUS ) {
+ printf( "mouse " );
+ } else if ( event->active.state & SDL_APPINPUTFOCUS ) {
+ printf( "input " );
+ }
+ printf( "focus\n" );
+ break;
+
+
+ case SDL_KEYDOWN:
+ if ( event->key.keysym.sym == SDLK_ESCAPE ) {
+ done = 1;
+ }
+ if ( (event->key.keysym.sym == SDLK_g) &&
+ (event->key.keysym.mod & KMOD_CTRL) ) {
+ HotKey_ToggleGrab();
+ }
+ if ( (event->key.keysym.sym == SDLK_z) &&
+ (event->key.keysym.mod & KMOD_CTRL) ) {
+ HotKey_Iconify();
+ }
+ if ( (event->key.keysym.sym == SDLK_RETURN) &&
+ (event->key.keysym.mod & KMOD_ALT) ) {
+ HotKey_ToggleFullScreen();
+ }
+ printf("key '%s' pressed\n",
+ SDL_GetKeyName(event->key.keysym.sym));
+ break;
+ case SDL_QUIT:
+ done = 1;
+ break;
+ }
+ return(done);
+}
+
+void SDL_GL_Enter2DMode()
+{
+ SDL_Surface *screen = SDL_GetVideoSurface();
+
+ /* Note, there may be other things you need to change,
+ depending on how you have your OpenGL state set up.
+ */
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glEnable(GL_TEXTURE_2D);
+
+ /* This allows alpha blending of 2D textures with the scene */
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glViewport(0, 0, screen->w, screen->h);
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+}
+
+void SDL_GL_Leave2DMode()
+{
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+
+ glPopAttrib();
+}
+
+/* Quick utility function for texture creation */
+static int power_of_two(int input)
+{
+ int value = 1;
+
+ while ( value < input ) {
+ value <<= 1;
+ }
+ return value;
+}
+
+GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord)
+{
+ GLuint texture;
+ int w, h;
+ SDL_Surface *image;
+ SDL_Rect area;
+ Uint32 saved_flags;
+ Uint8 saved_alpha;
+
+ /* Use the surface width and height expanded to powers of 2 */
+ w = power_of_two(surface->w);
+ h = power_of_two(surface->h);
+ texcoord[0] = 0.0f; /* Min X */
+ texcoord[1] = 0.0f; /* Min Y */
+ texcoord[2] = (GLfloat)surface->w / w; /* Max X */
+ texcoord[3] = (GLfloat)surface->h / h; /* Max Y */
+
+ image = SDL_CreateRGBSurface(
+ SDL_SWSURFACE,
+ w, h,
+ 32,
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
+ 0x000000FF,
+ 0x0000FF00,
+ 0x00FF0000,
+ 0xFF000000
+#else
+ 0xFF000000,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF
+#endif
+ );
+ if ( image == NULL ) {
+ return 0;
+ }
+
+ /* Save the alpha blending attributes */
+ saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
+ saved_alpha = surface->format->alpha;
+ if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+ SDL_SetAlpha(surface, 0, 0);
+ }
+
+ /* Copy the surface into the GL texture image */
+ area.x = 0;
+ area.y = 0;
+ area.w = surface->w;
+ area.h = surface->h;
+ SDL_BlitSurface(surface, &area, image, &area);
+
+ /* Restore the alpha blending attributes */
+ if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+ SDL_SetAlpha(surface, saved_flags, saved_alpha);
+ }
+
+ /* Create an OpenGL texture for the image */
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ w, h,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ image->pixels);
+ SDL_FreeSurface(image); /* No longer needed */
+
+ return texture;
+}
+
+void DrawLogoCursor(void)
+{
+ static GLfloat texMinX, texMinY;
+ static GLfloat texMaxX, texMaxY;
+ static int w, h;
+ int x, y;
+
+ if ( ! cursor_texture ) {
+ SDL_Surface *image;
+ GLfloat texcoord[4];
+
+ /* Load the image (could use SDL_image library here) */
+ image = SDL_LoadBMP(LOGO_FILE);
+ if ( image == NULL ) {
+ return;
+ }
+ w = image->w;
+ h = image->h;
+
+ /* Convert the image into an OpenGL texture */
+ cursor_texture = SDL_GL_LoadTexture(image, texcoord);
+
+ /* Make texture coordinates easy to understand */
+ texMinX = texcoord[0];
+ texMinY = texcoord[1];
+ texMaxX = texcoord[2];
+ texMaxY = texcoord[3];
+
+ /* We don't need the original image anymore */
+ SDL_FreeSurface(image);
+
+ /* Make sure that the texture conversion is okay */
+ if ( ! cursor_texture ) {
+ return;
+ }
+ }
+
+ /* Move the image around */
+ SDL_GetMouseState(&x, &y);
+ x -= w/2;
+ y -= h/2;
+
+ /* Show the image on the screen */
+ SDL_GL_Enter2DMode();
+ glBindTexture(GL_TEXTURE_2D, cursor_texture);
+ glBegin(GL_TRIANGLE_STRIP);
+ glTexCoord2f(texMinX, texMinY); glVertex2i(x, y );
+ glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y );
+ glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h);
+ glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
+ glEnd();
+ SDL_GL_Leave2DMode();
+}
+
+void DrawLogoTexture(void)
+{
+ static GLfloat texMinX, texMinY;
+ static GLfloat texMaxX, texMaxY;
+ static int x = 0;
+ static int y = 0;
+ static int w, h;
+ static int delta_x = 1;
+ static int delta_y = 1;
+
+ SDL_Surface *screen = SDL_GetVideoSurface();
+
+ if ( ! global_texture ) {
+ SDL_Surface *image;
+ GLfloat texcoord[4];
+
+ /* Load the image (could use SDL_image library here) */
+ image = SDL_LoadBMP(LOGO_FILE);
+ if ( image == NULL ) {
+ return;
+ }
+ w = image->w;
+ h = image->h;
+
+ /* Convert the image into an OpenGL texture */
+ global_texture = SDL_GL_LoadTexture(image, texcoord);
+
+ /* Make texture coordinates easy to understand */
+ texMinX = texcoord[0];
+ texMinY = texcoord[1];
+ texMaxX = texcoord[2];
+ texMaxY = texcoord[3];
+
+ /* We don't need the original image anymore */
+ SDL_FreeSurface(image);
+
+ /* Make sure that the texture conversion is okay */
+ if ( ! global_texture ) {
+ return;
+ }
+ }
+
+ /* Move the image around */
+ x += delta_x;
+ if ( x < 0 ) {
+ x = 0;
+ delta_x = -delta_x;
+ } else
+ if ( (x+w) > screen->w ) {
+ x = screen->w-w;
+ delta_x = -delta_x;
+ }
+ y += delta_y;
+ if ( y < 0 ) {
+ y = 0;
+ delta_y = -delta_y;
+ } else
+ if ( (y+h) > screen->h ) {
+ y = screen->h-h;
+ delta_y = -delta_y;
+ }
+
+ /* Show the image on the screen */
+ SDL_GL_Enter2DMode();
+ glBindTexture(GL_TEXTURE_2D, global_texture);
+ glBegin(GL_TRIANGLE_STRIP);
+ glTexCoord2f(texMinX, texMinY); glVertex2i(x, y );
+ glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y );
+ glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h);
+ glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
+ glEnd();
+ SDL_GL_Leave2DMode();
+}
+
+/* This code is deprecated, but available for speed comparisons */
+void DrawLogoBlit(void)
+{
+ static int x = 0;
+ static int y = 0;
+ static int w, h;
+ static int delta_x = 1;
+ static int delta_y = 1;
+
+ SDL_Rect dst;
+ SDL_Surface *screen = SDL_GetVideoSurface();
+
+ if ( global_image == NULL ) {
+ SDL_Surface *temp;
+
+ /* Load the image (could use SDL_image library here) */
+ temp = SDL_LoadBMP(LOGO_FILE);
+ if ( temp == NULL ) {
+ return;
+ }
+ w = temp->w;
+ h = temp->h;
+
+ /* Convert the image into the screen format */
+ global_image = SDL_CreateRGBSurface(
+ SDL_SWSURFACE,
+ w, h,
+ screen->format->BitsPerPixel,
+ screen->format->Rmask,
+ screen->format->Gmask,
+ screen->format->Bmask,
+ screen->format->Amask);
+ if ( global_image ) {
+ SDL_BlitSurface(temp, NULL, global_image, NULL);
+ }
+ SDL_FreeSurface(temp);
+
+ /* Make sure that the texture conversion is okay */
+ if ( ! global_image ) {
+ return;
+ }
+ }
+
+ /* Move the image around
+ Note that we do not clear the old position. This is because we
+ perform a glClear() which clears the framebuffer and then only
+ update the new area.
+ Note that you can also achieve interesting effects by modifying
+ the screen surface alpha channel. It's set to 255 by default..
+ */
+ x += delta_x;
+ if ( x < 0 ) {
+ x = 0;
+ delta_x = -delta_x;
+ } else
+ if ( (x+w) > screen->w ) {
+ x = screen->w-w;
+ delta_x = -delta_x;
+ }
+ y += delta_y;
+ if ( y < 0 ) {
+ y = 0;
+ delta_y = -delta_y;
+ } else
+ if ( (y+h) > screen->h ) {
+ y = screen->h-h;
+ delta_y = -delta_y;
+ }
+ dst.x = x;
+ dst.y = y;
+ dst.w = w;
+ dst.h = h;
+ SDL_BlitSurface(global_image, NULL, screen, &dst);
+
+ /* Show the image on the screen */
+ SDL_UpdateRects(screen, 1, &dst);
+}
+
+int RunGLTest( int argc, char* argv[],
+ int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa, int sync, int accel )
+{
+ int i;
+ int rgb_size[3];
+ int w = 640;
+ int h = 480;
+ int done = 0;
+ int frames;
+ Uint32 start_time, this_time;
+ float color[8][3]= {{ 1.0, 1.0, 0.0},
+ { 1.0, 0.0, 0.0},
+ { 0.0, 0.0, 0.0},
+ { 0.0, 1.0, 0.0},
+ { 0.0, 1.0, 1.0},
+ { 1.0, 1.0, 1.0},
+ { 1.0, 0.0, 1.0},
+ { 0.0, 0.0, 1.0}};
+ float cube[8][3]= {{ 0.5, 0.5, -0.5},
+ { 0.5, -0.5, -0.5},
+ {-0.5, -0.5, -0.5},
+ {-0.5, 0.5, -0.5},
+ {-0.5, 0.5, 0.5},
+ { 0.5, 0.5, 0.5},
+ { 0.5, -0.5, 0.5},
+ {-0.5, -0.5, 0.5}};
+ Uint32 video_flags;
+ int value;
+
+ if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
+ fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
+ exit( 1 );
+ }
+
+ /* See if we should detect the display depth */
+ if ( bpp == 0 ) {
+ if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 ) {
+ bpp = 8;
+ } else {
+ bpp = 16; /* More doesn't seem to work */
+ }
+ }
+
+ /* Set the flags we want to use for setting the video mode */
+ if ( logo && USE_DEPRECATED_OPENGLBLIT ) {
+ video_flags = SDL_OPENGLBLIT;
+ } else {
+ video_flags = SDL_OPENGL;
+ }
+ for ( i=1; argv[i]; ++i ) {
+ if ( strcmp(argv[i], "-fullscreen") == 0 ) {
+ video_flags |= SDL_FULLSCREEN;
+ }
+ }
+
+ if (noframe) {
+ video_flags |= SDL_NOFRAME;
+ }
+
+ /* Initialize the display */
+ switch (bpp) {
+ case 8:
+ rgb_size[0] = 3;
+ rgb_size[1] = 3;
+ rgb_size[2] = 2;
+ break;
+ case 15:
+ case 16:
+ rgb_size[0] = 5;
+ rgb_size[1] = 5;
+ rgb_size[2] = 5;
+ break;
+ default:
+ rgb_size[0] = 8;
+ rgb_size[1] = 8;
+ rgb_size[2] = 8;
+ break;
+ }
+ SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
+ SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
+ SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
+ SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
+ SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
+ if ( fsaa ) {
+ SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
+ SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
+ }
+ if ( accel ) {
+ SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
+ }
+ if ( sync ) {
+ SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
+ } else {
+ SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
+ }
+ if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
+ fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
+ SDL_Quit();
+ exit(1);
+ }
+
+ printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
+ printf("\n");
+ printf( "Vendor : %s\n", glGetString( GL_VENDOR ) );
+ printf( "Renderer : %s\n", glGetString( GL_RENDERER ) );
+ printf( "Version : %s\n", glGetString( GL_VERSION ) );
+ printf( "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
+ printf("\n");
+
+ SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
+ printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
+ SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
+ printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
+ SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
+ printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
+ SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
+ printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
+ SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
+ printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
+ if ( fsaa ) {
+ SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
+ printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
+ SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
+ printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
+ }
+ if ( accel ) {
+ SDL_GL_GetAttribute( SDL_GL_ACCELERATED_VISUAL, &value );
+ printf( "SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value );
+ }
+ if ( sync ) {
+ SDL_GL_GetAttribute( SDL_GL_SWAP_CONTROL, &value );
+ printf( "SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value );
+ }
+
+ /* Set the window manager title bar */
+ SDL_WM_SetCaption( "SDL GL test", "testgl" );
+
+ /* Set the gamma for the window */
+ if ( gamma != 0.0 ) {
+ SDL_SetGamma(gamma, gamma, gamma);
+ }
+
+ glViewport( 0, 0, w, h );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity( );
+
+ glOrtho( -2.0, 2.0, -2.0, 2.0, -20.0, 20.0 );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity( );
+
+ glEnable(GL_DEPTH_TEST);
+
+ glDepthFunc(GL_LESS);
+
+ glShadeModel(GL_SMOOTH);
+
+ /* Loop until done. */
+ start_time = SDL_GetTicks();
+ frames = 0;
+ while( !done ) {
+ GLenum gl_error;
+ char* sdl_error;
+ SDL_Event event;
+
+ /* Do our drawing, too. */
+ glClearColor( 0.0, 0.0, 0.0, 1.0 );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glBegin( GL_QUADS );
+
+#ifdef SHADED_CUBE
+ glColor3fv(color[0]);
+ glVertex3fv(cube[0]);
+ glColor3fv(color[1]);
+ glVertex3fv(cube[1]);
+ glColor3fv(color[2]);
+ glVertex3fv(cube[2]);
+ glColor3fv(color[3]);
+ glVertex3fv(cube[3]);
+
+ glColor3fv(color[3]);
+ glVertex3fv(cube[3]);
+ glColor3fv(color[4]);
+ glVertex3fv(cube[4]);
+ glColor3fv(color[7]);
+ glVertex3fv(cube[7]);
+ glColor3fv(color[2]);
+ glVertex3fv(cube[2]);
+
+ glColor3fv(color[0]);
+ glVertex3fv(cube[0]);
+ glColor3fv(color[5]);
+ glVertex3fv(cube[5]);
+ glColor3fv(color[6]);
+ glVertex3fv(cube[6]);
+ glColor3fv(color[1]);
+ glVertex3fv(cube[1]);
+
+ glColor3fv(color[5]);
+ glVertex3fv(cube[5]);
+ glColor3fv(color[4]);
+ glVertex3fv(cube[4]);
+ glColor3fv(color[7]);
+ glVertex3fv(cube[7]);
+ glColor3fv(color[6]);
+ glVertex3fv(cube[6]);
+
+ glColor3fv(color[5]);
+ glVertex3fv(cube[5]);
+ glColor3fv(color[0]);
+ glVertex3fv(cube[0]);
+ glColor3fv(color[3]);
+ glVertex3fv(cube[3]);
+ glColor3fv(color[4]);
+ glVertex3fv(cube[4]);
+
+ glColor3fv(color[6]);
+ glVertex3fv(cube[6]);
+ glColor3fv(color[1]);
+ glVertex3fv(cube[1]);
+ glColor3fv(color[2]);
+ glVertex3fv(cube[2]);
+ glColor3fv(color[7]);
+ glVertex3fv(cube[7]);
+#else /* flat cube */
+ glColor3f(1.0, 0.0, 0.0);
+ glVertex3fv(cube[0]);
+ glVertex3fv(cube[1]);
+ glVertex3fv(cube[2]);
+ glVertex3fv(cube[3]);
+
+ glColor3f(0.0, 1.0, 0.0);
+ glVertex3fv(cube[3]);
+ glVertex3fv(cube[4]);
+ glVertex3fv(cube[7]);
+ glVertex3fv(cube[2]);
+
+ glColor3f(0.0, 0.0, 1.0);
+ glVertex3fv(cube[0]);
+ glVertex3fv(cube[5]);
+ glVertex3fv(cube[6]);
+ glVertex3fv(cube[1]);
+
+ glColor3f(0.0, 1.0, 1.0);
+ glVertex3fv(cube[5]);
+ glVertex3fv(cube[4]);
+ glVertex3fv(cube[7]);
+ glVertex3fv(cube[6]);
+
+ glColor3f(1.0, 1.0, 0.0);
+ glVertex3fv(cube[5]);
+ glVertex3fv(cube[0]);
+ glVertex3fv(cube[3]);
+ glVertex3fv(cube[4]);
+
+ glColor3f(1.0, 0.0, 1.0);
+ glVertex3fv(cube[6]);
+ glVertex3fv(cube[1]);
+ glVertex3fv(cube[2]);
+ glVertex3fv(cube[7]);
+#endif /* SHADED_CUBE */
+
+ glEnd( );
+
+ glMatrixMode(GL_MODELVIEW);
+ glRotatef(5.0, 1.0, 1.0, 1.0);
+
+ /* Draw 2D logo onto the 3D display */
+ if ( logo ) {
+ if ( USE_DEPRECATED_OPENGLBLIT ) {
+ DrawLogoBlit();
+ } else {
+ DrawLogoTexture();
+ }
+ }
+ if ( logocursor ) {
+ DrawLogoCursor();
+ }
+
+ SDL_GL_SwapBuffers( );
+
+ /* Check for error conditions. */
+ gl_error = glGetError( );
+
+ if( gl_error != GL_NO_ERROR ) {
+ fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error );
+ }
+
+ sdl_error = SDL_GetError( );
+
+ if( sdl_error[0] != '\0' ) {
+ fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
+ SDL_ClearError();
+ }
+
+ /* Allow the user to see what's happening */
+ if ( slowly ) {
+ SDL_Delay( 20 );
+ }
+
+ /* Check if there's a pending event. */
+ while( SDL_PollEvent( &event ) ) {
+ done = HandleEvent(&event);
+ }
+ ++frames;
+ }
+
+ /* Print out the frames per second */
+ this_time = SDL_GetTicks();
+ if ( this_time != start_time ) {
+ printf("%2.2f FPS\n",
+ ((float)frames/(this_time-start_time))*1000.0);
+ }
+
+ if ( global_image ) {
+ SDL_FreeSurface(global_image);
+ global_image = NULL;
+ }
+ if ( global_texture ) {
+ glDeleteTextures( 1, &global_texture );
+ global_texture = 0;
+ }
+ if ( cursor_texture ) {
+ glDeleteTextures( 1, &cursor_texture );
+ cursor_texture = 0;
+ }
+
+ /* Destroy our GL context, etc. */
+ SDL_Quit( );
+ return(0);
+}
+
+int main(int argc, char *argv[])
+{
+ int i, logo, logocursor = 0;
+ int numtests;
+ int bpp = 0;
+ int slowly;
+ float gamma = 0.0;
+ int noframe = 0;
+ int fsaa = 0;
+ int accel = 0;
+ int sync = 0;
+
+ logo = 0;
+ slowly = 0;
+ numtests = 1;
+ for ( i=1; argv[i]; ++i ) {
+ if ( strcmp(argv[i], "-twice") == 0 ) {
+ ++numtests;
+ }
+ if ( strcmp(argv[i], "-logo") == 0 ) {
+ logo = 1;
+ USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
+ }
+ if ( strcmp(argv[i], "-logoblit") == 0 ) {
+ logo = 1;
+ USE_DEPRECATED_OPENGLBLIT = SDL_TRUE;
+ }
+ if ( strcmp(argv[i], "-logocursor") == 0 ) {
+ logocursor = 1;
+ }
+ if ( strcmp(argv[i], "-slow") == 0 ) {
+ slowly = 1;
+ }
+ if ( strcmp(argv[i], "-bpp") == 0 ) {
+ bpp = atoi(argv[++i]);
+ }
+ if ( strcmp(argv[i], "-gamma") == 0 ) {
+ gamma = (float)atof(argv[++i]);
+ }
+ if ( strcmp(argv[i], "-noframe") == 0 ) {
+ noframe = 1;
+ }
+ if ( strcmp(argv[i], "-fsaa") == 0 ) {
+ ++fsaa;
+ }
+ if ( strcmp(argv[i], "-accel") == 0 ) {
+ ++accel;
+ }
+ if ( strcmp(argv[i], "-sync") == 0 ) {
+ ++sync;
+ }
+ if ( strncmp(argv[i], "-h", 2) == 0 ) {
+ printf(
+"Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n",
+ argv[0]);
+ exit(0);
+ }
+ }
+ for ( i=0; i<numtests; ++i ) {
+ RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa, sync, accel);
+ }
+ return 0;
+}
+
+#else /* HAVE_OPENGL */
+
+int main(int argc, char *argv[])
+{
+ printf("No OpenGL support on this system\n");
+ return 1;
+}
+
+#endif /* HAVE_OPENGL */
diff --git a/test/testhread.c b/test/testhread.c
new file mode 100644
index 0000000..f87f374
--- /dev/null
+++ b/test/testhread.c
@@ -0,0 +1,82 @@
+
+/* Simple test of the SDL threading code */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+static int alive = 0;
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+int SDLCALL ThreadFunc(void *data)
+{
+ printf("Started thread %s: My thread id is %u\n",
+ (char *)data, SDL_ThreadID());
+ while ( alive ) {
+ printf("Thread '%s' is alive!\n", (char *)data);
+ SDL_Delay(1*1000);
+ }
+ printf("Thread '%s' exiting!\n", (char *)data);
+ return(0);
+}
+
+static void killed(int sig)
+{
+ printf("Killed with SIGTERM, waiting 5 seconds to exit\n");
+ SDL_Delay(5*1000);
+ alive = 0;
+ quit(0);
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Thread *thread;
+
+ /* Load the SDL library */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ alive = 1;
+ thread = SDL_CreateThread(ThreadFunc, "#1");
+ if ( thread == NULL ) {
+ fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ quit(1);
+ }
+ SDL_Delay(5*1000);
+ printf("Waiting for thread #1\n");
+ alive = 0;
+ SDL_WaitThread(thread, NULL);
+
+ alive = 1;
+ thread = SDL_CreateThread(ThreadFunc, "#2");
+ if ( thread == NULL ) {
+ fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ quit(1);
+ }
+ SDL_Delay(5*1000);
+ printf("Killing thread #2\n");
+ SDL_KillThread(thread);
+
+ alive = 1;
+ signal(SIGTERM, killed);
+ thread = SDL_CreateThread(ThreadFunc, "#3");
+ if ( thread == NULL ) {
+ fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ quit(1);
+ }
+ raise(SIGTERM);
+
+ SDL_Quit(); /* Never reached */
+ return(0); /* Never reached */
+}
diff --git a/test/testiconv.c b/test/testiconv.c
new file mode 100644
index 0000000..53415d0
--- /dev/null
+++ b/test/testiconv.c
@@ -0,0 +1,73 @@
+
+#include <stdio.h>
+
+#include "SDL.h"
+
+static size_t widelen(char *data)
+{
+ size_t len = 0;
+ Uint32 *p = (Uint32 *)data;
+ while(*p++) {
+ ++len;
+ }
+ return len;
+}
+
+int main(int argc, char *argv[])
+{
+ const char * formats[] = {
+ "UTF8",
+ "UTF-8",
+ "UTF16BE",
+ "UTF-16BE",
+ "UTF16LE",
+ "UTF-16LE",
+ "UTF32BE",
+ "UTF-32BE",
+ "UTF32LE",
+ "UTF-32LE",
+ "UCS4",
+ "UCS-4",
+ };
+ char buffer[BUFSIZ];
+ char *ucs4;
+ char *test[2];
+ int i, index = 0;
+ FILE *file;
+ int errors = 0;
+
+ if ( !argv[1] ) {
+ argv[1] = "utf8.txt";
+ }
+ file = fopen(argv[1], "rb");
+ if ( !file ) {
+ fprintf(stderr, "Unable to open %s\n", argv[1]);
+ return (1);
+ }
+
+ while ( fgets(buffer, sizeof(buffer), file) ) {
+ /* Convert to UCS-4 */
+ size_t len;
+ ucs4 = SDL_iconv_string("UCS-4", "UTF-8", buffer, SDL_strlen(buffer)+1);
+ len = (widelen(ucs4)+1)*4;
+ for ( i = 0; i < SDL_arraysize(formats); ++i ) {
+ test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
+ test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
+ if ( !test[1] || SDL_memcmp(test[1], ucs4, len) != 0 ) {
+ fprintf(stderr, "FAIL: %s\n", formats[i]);
+ ++errors;
+ }
+ if ( test[0] ) {
+ SDL_free(test[0]);
+ }
+ if ( test[1] ) {
+ SDL_free(test[1]);
+ }
+ }
+ test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
+ SDL_free(ucs4);
+ fputs(test[0], stdout);
+ SDL_free(test[0]);
+ }
+ return (errors ? errors + 1 : 0);
+}
diff --git a/test/testjoystick.c b/test/testjoystick.c
new file mode 100644
index 0000000..1cd8234
--- /dev/null
+++ b/test/testjoystick.c
@@ -0,0 +1,188 @@
+
+/* Simple program to test the SDL joystick routines */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+#define SCREEN_WIDTH 640
+#define SCREEN_HEIGHT 480
+
+void WatchJoystick(SDL_Joystick *joystick)
+{
+ SDL_Surface *screen;
+ const char *name;
+ int i, done;
+ SDL_Event event;
+ int x, y, draw;
+ SDL_Rect axis_area[2];
+
+ /* Set a video mode to display joystick axis position */
+ screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0);
+ if ( screen == NULL ) {
+ fprintf(stderr, "Couldn't set video mode: %s\n",SDL_GetError());
+ return;
+ }
+
+ /* Print info about the joystick we are watching */
+ name = SDL_JoystickName(SDL_JoystickIndex(joystick));
+ printf("Watching joystick %d: (%s)\n", SDL_JoystickIndex(joystick),
+ name ? name : "Unknown Joystick");
+ printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
+ SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
+ SDL_JoystickNumBalls(joystick),SDL_JoystickNumButtons(joystick));
+
+ /* Initialize drawing rectangles */
+ memset(axis_area, 0, (sizeof axis_area));
+ draw = 0;
+
+ /* Loop, getting joystick events! */
+ done = 0;
+ while ( ! done ) {
+ while ( SDL_PollEvent(&event) ) {
+ switch (event.type) {
+ case SDL_JOYAXISMOTION:
+ printf("Joystick %d axis %d value: %d\n",
+ event.jaxis.which,
+ event.jaxis.axis,
+ event.jaxis.value);
+ break;
+ case SDL_JOYHATMOTION:
+ printf("Joystick %d hat %d value:",
+ event.jhat.which,
+ event.jhat.hat);
+ if ( event.jhat.value == SDL_HAT_CENTERED )
+ printf(" centered");
+ if ( event.jhat.value & SDL_HAT_UP )
+ printf(" up");
+ if ( event.jhat.value & SDL_HAT_RIGHT )
+ printf(" right");
+ if ( event.jhat.value & SDL_HAT_DOWN )
+ printf(" down");
+ if ( event.jhat.value & SDL_HAT_LEFT )
+ printf(" left");
+ printf("\n");
+ break;
+ case SDL_JOYBALLMOTION:
+ printf("Joystick %d ball %d delta: (%d,%d)\n",
+ event.jball.which,
+ event.jball.ball,
+ event.jball.xrel,
+ event.jball.yrel);
+ break;
+ case SDL_JOYBUTTONDOWN:
+ printf("Joystick %d button %d down\n",
+ event.jbutton.which,
+ event.jbutton.button);
+ break;
+ case SDL_JOYBUTTONUP:
+ printf("Joystick %d button %d up\n",
+ event.jbutton.which,
+ event.jbutton.button);
+ break;
+ case SDL_KEYDOWN:
+ if ( event.key.keysym.sym != SDLK_ESCAPE ) {
+ break;
+ }
+ /* Fall through to signal quit */
+ case SDL_QUIT:
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ /* Update visual joystick state */
+ for ( i=0; i<SDL_JoystickNumButtons(joystick); ++i ) {
+ SDL_Rect area;
+
+ area.x = i*34;
+ area.y = SCREEN_HEIGHT-34;
+ area.w = 32;
+ area.h = 32;
+ if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
+ SDL_FillRect(screen, &area, 0xFFFF);
+ } else {
+ SDL_FillRect(screen, &area, 0x0000);
+ }
+ SDL_UpdateRects(screen, 1, &area);
+ }
+
+ /* Erase previous axes */
+ SDL_FillRect(screen, &axis_area[draw], 0x0000);
+
+ /* Draw the X/Y axis */
+ draw = !draw;
+ x = (((int)SDL_JoystickGetAxis(joystick, 0))+32768);
+ x *= SCREEN_WIDTH;
+ x /= 65535;
+ if ( x < 0 ) {
+ x = 0;
+ } else
+ if ( x > (SCREEN_WIDTH-16) ) {
+ x = SCREEN_WIDTH-16;
+ }
+ y = (((int)SDL_JoystickGetAxis(joystick, 1))+32768);
+ y *= SCREEN_HEIGHT;
+ y /= 65535;
+ if ( y < 0 ) {
+ y = 0;
+ } else
+ if ( y > (SCREEN_HEIGHT-16) ) {
+ y = SCREEN_HEIGHT-16;
+ }
+ axis_area[draw].x = (Sint16)x;
+ axis_area[draw].y = (Sint16)y;
+ axis_area[draw].w = 16;
+ axis_area[draw].h = 16;
+ SDL_FillRect(screen, &axis_area[draw], 0xFFFF);
+
+ SDL_UpdateRects(screen, 2, axis_area);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ const char *name;
+ int i;
+ SDL_Joystick *joystick;
+
+ /* Initialize SDL (Note: video is required to start event loop) */
+ if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ exit(1);
+ }
+
+ /* Print information about the joysticks */
+ printf("There are %d joysticks attached\n", SDL_NumJoysticks());
+ for ( i=0; i<SDL_NumJoysticks(); ++i ) {
+ name = SDL_JoystickName(i);
+ printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick");
+ joystick = SDL_JoystickOpen(i);
+ if (joystick == NULL) {
+ fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError());
+ } else {
+ printf(" axes: %d\n", SDL_JoystickNumAxes(joystick));
+ printf(" balls: %d\n", SDL_JoystickNumBalls(joystick));
+ printf(" hats: %d\n", SDL_JoystickNumHats(joystick));
+ printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
+ SDL_JoystickClose(joystick);
+ }
+ }
+
+ if ( argv[1] ) {
+ joystick = SDL_JoystickOpen(atoi(argv[1]));
+ if ( joystick == NULL ) {
+ printf("Couldn't open joystick %d: %s\n", atoi(argv[1]),
+ SDL_GetError());
+ } else {
+ WatchJoystick(joystick);
+ SDL_JoystickClose(joystick);
+ }
+ }
+ SDL_QuitSubSystem(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK);
+
+ return(0);
+}
diff --git a/test/testkeys.c b/test/testkeys.c
new file mode 100644
index 0000000..e320c6d
--- /dev/null
+++ b/test/testkeys.c
@@ -0,0 +1,25 @@
+
+/* Print out all the keysyms we have, just to verify them */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{
+ SDLKey key;
+
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",
+ SDL_GetError());
+ exit(1);
+ }
+ for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) {
+ printf("Key #%d, \"%s\"\n", key, SDL_GetKeyName(key));
+ }
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testloadso.c b/test/testloadso.c
new file mode 100644
index 0000000..39c14c6
--- /dev/null
+++ b/test/testloadso.c
@@ -0,0 +1,71 @@
+
+/* Test program to test dynamic loading with the loadso subsystem.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL.h"
+
+typedef int (*fntype)(const char *);
+
+int main(int argc, char *argv[])
+{
+ int retval = 0;
+ int hello = 0;
+ const char *libname = NULL;
+ const char *symname = NULL;
+ void *lib = NULL;
+ fntype fn = NULL;
+
+ if (argc != 3) {
+ const char *app = argv[0];
+ fprintf(stderr, "USAGE: %s <library> <functionname>\n", app);
+ fprintf(stderr, " %s --hello <lib with puts()>\n", app);
+ return 1;
+ }
+
+ /* Initialize SDL */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return 2;
+ }
+
+ if (strcmp(argv[1], "--hello") == 0) {
+ hello = 1;
+ libname = argv[2];
+ symname = "puts";
+ } else {
+ libname = argv[1];
+ symname = argv[2];
+ }
+
+ lib = SDL_LoadObject(libname);
+ if (lib == NULL) {
+ fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n",
+ libname, SDL_GetError());
+ retval = 3;
+ } else {
+ fn = (fntype) SDL_LoadFunction(lib, symname);
+ if (fn == NULL) {
+ fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n",
+ symname, SDL_GetError());
+ retval = 4;
+ } else {
+ printf("Found %s in %s at %p\n", symname, libname, fn);
+ if (hello) {
+ printf("Calling function...\n");
+ fflush(stdout);
+ fn(" HELLO, WORLD!\n");
+ printf("...apparently, we survived. :)\n");
+ printf("Unloading library...\n");
+ fflush(stdout);
+ }
+ }
+ SDL_UnloadObject(lib);
+ }
+ SDL_Quit();
+ return(0);
+}
+
+
diff --git a/test/testlock.c b/test/testlock.c
new file mode 100644
index 0000000..bda4b55
--- /dev/null
+++ b/test/testlock.c
@@ -0,0 +1,102 @@
+
+/* Test the thread and mutex locking functions
+ Also exercises the system's signal/thread interaction
+*/
+
+#include <signal.h>
+#include <stdio.h>
+
+#include "SDL.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+
+static SDL_mutex *mutex = NULL;
+static Uint32 mainthread;
+static SDL_Thread *threads[6];
+static volatile int doterminate = 0;
+
+/*
+ * SDL_Quit() shouldn't be used with atexit() directly because
+ * calling conventions may differ...
+ */
+static void SDL_Quit_Wrapper(void)
+{
+ SDL_Quit();
+}
+
+void printid(void)
+{
+ printf("Process %u: exiting\n", SDL_ThreadID());
+}
+
+void terminate(int sig)
+{
+ signal(SIGINT, terminate);
+ doterminate = 1;
+}
+void closemutex(int sig)
+{
+ Uint32 id = SDL_ThreadID();
+ int i;
+ printf("Process %u: Cleaning up...\n", id == mainthread ? 0 : id);
+ for ( i=0; i<6; ++i )
+ SDL_KillThread(threads[i]);
+ SDL_DestroyMutex(mutex);
+ exit(sig);
+}
+int SDLCALL Run(void *data)
+{
+ if ( SDL_ThreadID() == mainthread )
+ signal(SIGTERM, closemutex);
+ while ( 1 ) {
+ printf("Process %u ready to work\n", SDL_ThreadID());
+ if ( SDL_mutexP(mutex) < 0 ) {
+ fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
+ exit(1);
+ }
+ printf("Process %u, working!\n", SDL_ThreadID());
+ SDL_Delay(1*1000);
+ printf("Process %u, done!\n", SDL_ThreadID());
+ if ( SDL_mutexV(mutex) < 0 ) {
+ fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
+ exit(1);
+ }
+ /* If this sleep isn't done, then threads may starve */
+ SDL_Delay(10);
+ if (SDL_ThreadID() == mainthread && doterminate) {
+ printf("Process %u: raising SIGTERM\n", SDL_ThreadID());
+ raise(SIGTERM);
+ }
+ }
+ return(0);
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ int maxproc = 6;
+
+ /* Load the SDL library */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ exit(1);
+ }
+ atexit(SDL_Quit_Wrapper);
+
+ if ( (mutex=SDL_CreateMutex()) == NULL ) {
+ fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError());
+ exit(1);
+ }
+
+ mainthread = SDL_ThreadID();
+ printf("Main thread: %u\n", mainthread);
+ atexit(printid);
+ for ( i=0; i<maxproc; ++i ) {
+ if ( (threads[i]=SDL_CreateThread(Run, NULL)) == NULL )
+ fprintf(stderr, "Couldn't create thread!\n");
+ }
+ signal(SIGINT, terminate);
+ Run(NULL);
+
+ return(0); /* Never reached */
+}
diff --git a/test/testoverlay.c b/test/testoverlay.c
new file mode 100644
index 0000000..da53f9e
--- /dev/null
+++ b/test/testoverlay.c
@@ -0,0 +1,594 @@
+
+/* Bring up a window and play with it */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define BENCHMARK_SDL
+
+#define NOTICE(X) printf("%s", X);
+
+#define WINDOW_WIDTH 640
+#define WINDOW_HEIGHT 480
+
+#include "SDL.h"
+
+SDL_Surface *screen, *pic;
+SDL_Overlay *overlay;
+int scale;
+int monochrome;
+int luminance;
+int w, h;
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+/* NOTE: These RGB conversion functions are not intended for speed,
+ only as examples.
+*/
+
+void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
+{
+ if (monochrome)
+ {
+#if 1 /* these are the two formulas that I found on the FourCC site... */
+ yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
+ yuv[1] = 128;
+ yuv[2] = 128;
+#else
+ yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
+ yuv[1] = 128;
+ yuv[2] = 128;
+#endif
+ }
+ else
+ {
+#if 1 /* these are the two formulas that I found on the FourCC site... */
+ yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
+ yuv[1] = (rgb[2]-yuv[0])*0.565 + 128;
+ yuv[2] = (rgb[0]-yuv[0])*0.713 + 128;
+#else
+ yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
+ yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
+ yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
+#endif
+ }
+
+ if (luminance!=100)
+ {
+ yuv[0]=yuv[0]*luminance/100;
+ if (yuv[0]>255)
+ yuv[0]=255;
+ }
+
+ /* clamp values...if you need to, we don't seem to have a need */
+ /*
+ for(i=0;i<3;i++)
+ {
+ if(yuv[i]<0)
+ yuv[i]=0;
+ if(yuv[i]>255)
+ yuv[i]=255;
+ }
+ */
+}
+
+void ConvertRGBtoYV12(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op[3];
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ /* Black initialization */
+ /*
+ memset(o->pixels[0],0,o->pitches[0]*o->h);
+ memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
+ memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
+ */
+
+ /* Convert */
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op[0]=o->pixels[0]+o->pitches[0]*y;
+ op[1]=o->pixels[1]+o->pitches[1]*(y/2);
+ op[2]=o->pixels[2]+o->pitches[2]*(y/2);
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p, yuv, monochrome, luminance);
+ *(op[0]++)=yuv[0];
+ if(x%2==0 && y%2==0)
+ {
+ *(op[1]++)=yuv[2];
+ *(op[2]++)=yuv[1];
+ }
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoIYUV(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op[3];
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ /* Black initialization */
+ /*
+ memset(o->pixels[0],0,o->pitches[0]*o->h);
+ memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
+ memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
+ */
+
+ /* Convert */
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op[0]=o->pixels[0]+o->pitches[0]*y;
+ op[1]=o->pixels[1]+o->pitches[1]*(y/2);
+ op[2]=o->pixels[2]+o->pitches[2]*(y/2);
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p,yuv, monochrome, luminance);
+ *(op[0]++)=yuv[0];
+ if(x%2==0 && y%2==0)
+ {
+ *(op[1]++)=yuv[1];
+ *(op[2]++)=yuv[2];
+ }
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoUYVY(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op;
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op=o->pixels[0]+o->pitches[0]*y;
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p, yuv, monochrome, luminance);
+ if(x%2==0)
+ {
+ *(op++)=yuv[1];
+ *(op++)=yuv[0];
+ *(op++)=yuv[2];
+ }
+ else
+ *(op++)=yuv[0];
+
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoYVYU(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op;
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op=o->pixels[0]+o->pitches[0]*y;
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p,yuv, monochrome, luminance);
+ if(x%2==0)
+ {
+ *(op++)=yuv[0];
+ *(op++)=yuv[2];
+ op[1]=yuv[1];
+ }
+ else
+ {
+ *op=yuv[0];
+ op+=2;
+ }
+
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op;
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op=o->pixels[0]+o->pitches[0]*y;
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p,yuv, monochrome, luminance);
+ if(x%2==0)
+ {
+ *(op++)=yuv[0];
+ *(op++)=yuv[1];
+ op[1]=yuv[2];
+ }
+ else
+ {
+ *op=yuv[0];
+ op+=2;
+ }
+
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void Draw()
+{
+ SDL_Rect rect;
+ int i;
+ int disp;
+
+ if(!scale)
+ {
+ rect.w=overlay->w;
+ rect.h=overlay->h;
+ for(i=0; i<h-rect.h && i<w-rect.w; i++)
+ {
+ rect.x=i;
+ rect.y=i;
+ SDL_DisplayYUVOverlay(overlay,&rect);
+ }
+ }
+ else
+ {
+ rect.w=overlay->w/2;
+ rect.h=overlay->h/2;
+ rect.x=(w-rect.w)/2;
+ rect.y=(h-rect.h)/2;
+ disp=rect.y-1;
+ for(i=0; i<disp; i++)
+ {
+ rect.w+=2;
+ rect.h+=2;
+ rect.x--;
+ rect.y--;
+ SDL_DisplayYUVOverlay(overlay,&rect);
+ }
+ }
+ printf("Displayed %d times.\n",i);
+}
+
+static void PrintUsage(char *argv0)
+{
+ fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
+ fprintf(stderr, "Where 'arg' is one of:\n");
+ fprintf(stderr, " -delay <seconds>\n");
+ fprintf(stderr, " -width <pixels>\n");
+ fprintf(stderr, " -height <pixels>\n");
+ fprintf(stderr, " -bpp <bits>\n");
+ fprintf(stderr, " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
+ fprintf(stderr, " -hw\n");
+ fprintf(stderr, " -flip\n");
+ fprintf(stderr, " -scale (test scaling features, from 50%% upto window size)\n");
+ fprintf(stderr, " -mono (use monochromatic RGB2YUV conversion)\n");
+ fprintf(stderr, " -lum <perc> (use luminance correction during RGB2YUV conversion,\n");
+ fprintf(stderr, " from 0%% to unlimited, normal is 100%%)\n");
+ fprintf(stderr, " -help (shows this help)\n");
+ fprintf(stderr, " -fullscreen (test overlay in fullscreen mode)\n");
+}
+
+int main(int argc, char **argv)
+{
+ char *argv0 = argv[0];
+ int flip;
+ int delay;
+ int desired_bpp;
+ Uint32 video_flags, overlay_format;
+ char *bmpfile;
+#ifdef BENCHMARK_SDL
+ Uint32 then, now;
+#endif
+ int i;
+
+ /* Set default options and check command-line */
+ flip = 0;
+ scale=0;
+ monochrome=0;
+ luminance=100;
+ delay = 1;
+ w = WINDOW_WIDTH;
+ h = WINDOW_HEIGHT;
+ desired_bpp = 0;
+ video_flags = 0;
+ overlay_format = SDL_YV12_OVERLAY;
+
+ while ( argc > 1 ) {
+ if ( strcmp(argv[1], "-delay") == 0 ) {
+ if ( argv[2] ) {
+ delay = atoi(argv[2]);
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -delay option requires an argument\n");
+ return(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-width") == 0 ) {
+ if ( argv[2] && ((w = atoi(argv[2])) > 0) ) {
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -width option requires an argument\n");
+ return(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-height") == 0 ) {
+ if ( argv[2] && ((h = atoi(argv[2])) > 0) ) {
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -height option requires an argument\n");
+ return(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-bpp") == 0 ) {
+ if ( argv[2] ) {
+ desired_bpp = atoi(argv[2]);
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -bpp option requires an argument\n");
+ return(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-lum") == 0 ) {
+ if ( argv[2] ) {
+ luminance = atoi(argv[2]);
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -lum option requires an argument\n");
+ return(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-format") == 0 ) {
+ if ( argv[2] ) {
+ if(!strcmp(argv[2],"YV12"))
+ overlay_format = SDL_YV12_OVERLAY;
+ else if(!strcmp(argv[2],"IYUV"))
+ overlay_format = SDL_IYUV_OVERLAY;
+ else if(!strcmp(argv[2],"YUY2"))
+ overlay_format = SDL_YUY2_OVERLAY;
+ else if(!strcmp(argv[2],"UYVY"))
+ overlay_format = SDL_UYVY_OVERLAY;
+ else if(!strcmp(argv[2],"YVYU"))
+ overlay_format = SDL_YVYU_OVERLAY;
+ else
+ {
+ fprintf(stderr, "The -format option %s is not recognized\n",argv[2]);
+ return(1);
+ }
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -format option requires an argument\n");
+ return(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-hw") == 0 ) {
+ video_flags |= SDL_HWSURFACE;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-flip") == 0 ) {
+ video_flags |= SDL_DOUBLEBUF;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-scale") == 0 ) {
+ scale = 1;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-mono") == 0 ) {
+ monochrome = 1;
+ argv += 1;
+ argc -= 1;
+ } else
+ if (( strcmp(argv[1], "-help") == 0 ) || (strcmp(argv[1], "-h") == 0)) {
+ PrintUsage(argv0);
+ return(1);
+ } else
+ if ( strcmp(argv[1], "-fullscreen") == 0 ) {
+ video_flags |= SDL_FULLSCREEN;
+ argv += 1;
+ argc -= 1;
+ } else
+ break;
+ }
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr,
+ "Couldn't initialize SDL: %s\n", SDL_GetError());
+ return(1);
+ }
+
+ /* Initialize the display */
+ screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
+ if ( screen == NULL ) {
+ fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
+ w, h, desired_bpp, SDL_GetError());
+ quit(1);
+ }
+ printf("Set%s %dx%dx%d mode\n",
+ screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
+ screen->w, screen->h, screen->format->BitsPerPixel);
+ printf("(video surface located in %s memory)\n",
+ (screen->flags&SDL_HWSURFACE) ? "video" : "system");
+ if ( screen->flags & SDL_DOUBLEBUF ) {
+ printf("Double-buffering enabled\n");
+ flip = 1;
+ }
+
+ /* Set the window manager title bar */
+ SDL_WM_SetCaption("SDL test overlay", "testoverlay");
+
+ /* Load picture */
+ bmpfile=(argv[1]?argv[1]:"sample.bmp");
+ pic = SDL_LoadBMP(bmpfile);
+ if ( pic == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s\n", bmpfile,
+ SDL_GetError());
+ quit(1);
+ }
+
+ /* Convert the picture to 32bits, for easy conversion */
+ {
+ SDL_Surface *newsurf;
+ SDL_PixelFormat format;
+
+ format.palette=NULL;
+ format.BitsPerPixel=32;
+ format.BytesPerPixel=4;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ format.Rshift=0;
+ format.Gshift=8;
+ format.Bshift=16;
+#else
+ format.Rshift=24;
+ format.Gshift=16;
+ format.Bshift=8;
+#endif
+ format.Ashift=0;
+ format.Rmask=0xff<<format.Rshift;
+ format.Gmask=0xff<<format.Gshift;
+ format.Bmask=0xff<<format.Bshift;
+ format.Amask=0;
+ format.Rloss=0;
+ format.Gloss=0;
+ format.Bloss=0;
+ format.Aloss=8;
+ format.colorkey=0;
+ format.alpha=0;
+
+ newsurf=SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
+ if(!newsurf)
+ {
+ fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n",
+ SDL_GetError());
+ quit(1);
+ }
+ SDL_FreeSurface(pic);
+ pic=newsurf;
+ }
+
+ /* Create the overlay */
+ overlay = SDL_CreateYUVOverlay(pic->w, pic->h, overlay_format, screen);
+ if ( overlay == NULL ) {
+ fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
+ quit(1);
+ }
+ printf("Created %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes,
+ overlay->hw_overlay?"hardware":"software",
+ overlay->format==SDL_YV12_OVERLAY?"YV12":
+ overlay->format==SDL_IYUV_OVERLAY?"IYUV":
+ overlay->format==SDL_YUY2_OVERLAY?"YUY2":
+ overlay->format==SDL_UYVY_OVERLAY?"UYVY":
+ overlay->format==SDL_YVYU_OVERLAY?"YVYU":
+ "Unknown");
+ for(i=0; i<overlay->planes; i++)
+ {
+ printf(" plane %d: pitch=%d\n", i, overlay->pitches[i]);
+ }
+
+ /* Convert to YUV, and draw to the overlay */
+#ifdef BENCHMARK_SDL
+ then = SDL_GetTicks();
+#endif
+ switch(overlay->format)
+ {
+ case SDL_YV12_OVERLAY:
+ ConvertRGBtoYV12(pic,overlay,monochrome,luminance);
+ break;
+ case SDL_UYVY_OVERLAY:
+ ConvertRGBtoUYVY(pic,overlay,monochrome,luminance);
+ break;
+ case SDL_YVYU_OVERLAY:
+ ConvertRGBtoYVYU(pic,overlay,monochrome,luminance);
+ break;
+ case SDL_YUY2_OVERLAY:
+ ConvertRGBtoYUY2(pic,overlay,monochrome,luminance);
+ break;
+ case SDL_IYUV_OVERLAY:
+ ConvertRGBtoIYUV(pic,overlay,monochrome,luminance);
+ break;
+ default:
+ printf("cannot convert RGB picture to obtained YUV format!\n");
+ quit(1);
+ break;
+ }
+#ifdef BENCHMARK_SDL
+ now = SDL_GetTicks();
+ printf("Conversion Time: %d milliseconds\n", now-then);
+#endif
+
+ /* Do all the drawing work */
+#ifdef BENCHMARK_SDL
+ then = SDL_GetTicks();
+#endif
+ Draw();
+#ifdef BENCHMARK_SDL
+ now = SDL_GetTicks();
+ printf("Time: %d milliseconds\n", now-then);
+#endif
+ SDL_Delay(delay*1000);
+ SDL_Quit();
+ return(0);
+}
+
diff --git a/test/testoverlay2.c b/test/testoverlay2.c
new file mode 100644
index 0000000..5f491f2
--- /dev/null
+++ b/test/testoverlay2.c
@@ -0,0 +1,600 @@
+/********************************************************************************
+ * *
+ * Test of the overlay used for moved pictures, test more closed to real life. *
+ * Running trojan moose :) Coded by Mike Gorchak. *
+ * *
+ ********************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL.h"
+
+#define MOOSEPIC_W 64
+#define MOOSEPIC_H 88
+
+#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H)
+#define MOOSEFRAMES_COUNT 10
+
+SDL_Color MooseColors[84]={
+ { 49, 49, 49}, { 66, 24, 0}, { 66, 33, 0}, { 66, 66, 66},
+ { 66, 115, 49}, { 74, 33, 0}, { 74, 41, 16}, { 82, 33, 8},
+ { 82, 41, 8}, { 82, 49, 16}, { 82, 82, 82}, { 90, 41, 8},
+ { 90, 41, 16}, { 90, 57, 24}, { 99, 49, 16}, { 99, 66, 24},
+ { 99, 66, 33}, { 99, 74, 33}, {107, 57, 24}, {107, 82, 41},
+ {115, 57, 33}, {115, 66, 33}, {115, 66, 41}, {115, 74, 0},
+ {115, 90, 49}, {115, 115, 115}, {123, 82, 0}, {123, 99, 57},
+ {132, 66, 41}, {132, 74, 41}, {132, 90, 8}, {132, 99, 33},
+ {132, 99, 66}, {132, 107, 66}, {140, 74, 49}, {140, 99, 16},
+ {140, 107, 74}, {140, 115, 74}, {148, 107, 24}, {148, 115, 82},
+ {148, 123, 74}, {148, 123, 90}, {156, 115, 33}, {156, 115, 90},
+ {156, 123, 82}, {156, 132, 82}, {156, 132, 99}, {156, 156, 156},
+ {165, 123, 49}, {165, 123, 90}, {165, 132, 82}, {165, 132, 90},
+ {165, 132, 99}, {165, 140, 90}, {173, 132, 57}, {173, 132, 99},
+ {173, 140, 107}, {173, 140, 115}, {173, 148, 99}, {173, 173, 173},
+ {181, 140, 74}, {181, 148, 115}, {181, 148, 123}, {181, 156, 107},
+ {189, 148, 123}, {189, 156, 82}, {189, 156, 123}, {189, 156, 132},
+ {189, 189, 189}, {198, 156, 123}, {198, 165, 132}, {206, 165, 99},
+ {206, 165, 132}, {206, 173, 140}, {206, 206, 206}, {214, 173, 115},
+ {214, 173, 140}, {222, 181, 148}, {222, 189, 132}, {222, 189, 156},
+ {222, 222, 222}, {231, 198, 165}, {231, 231, 231}, {239, 206, 173}
+};
+
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+/* All RGB2YUV conversion code and some other parts of code has been taken from testoverlay.c */
+
+/* NOTE: These RGB conversion functions are not intended for speed,
+ only as examples.
+*/
+
+void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
+{
+ if (monochrome)
+ {
+#if 1 /* these are the two formulas that I found on the FourCC site... */
+ yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
+ yuv[1] = 128;
+ yuv[2] = 128;
+#else
+ yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
+ yuv[1] = 128;
+ yuv[2] = 128;
+#endif
+ }
+ else
+ {
+#if 1 /* these are the two formulas that I found on the FourCC site... */
+ yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
+ yuv[1] = (rgb[2]-yuv[0])*0.565 + 128;
+ yuv[2] = (rgb[0]-yuv[0])*0.713 + 128;
+#else
+ yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
+ yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
+ yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
+#endif
+ }
+
+ if (luminance!=100)
+ {
+ yuv[0]=yuv[0]*luminance/100;
+ if (yuv[0]>255)
+ yuv[0]=255;
+ }
+}
+
+void ConvertRGBtoYV12(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op[3];
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ /* Convert */
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op[0]=o->pixels[0]+o->pitches[0]*y;
+ op[1]=o->pixels[1]+o->pitches[1]*(y/2);
+ op[2]=o->pixels[2]+o->pitches[2]*(y/2);
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p, yuv, monochrome, luminance);
+ *(op[0]++)=yuv[0];
+ if(x%2==0 && y%2==0)
+ {
+ *(op[1]++)=yuv[2];
+ *(op[2]++)=yuv[1];
+ }
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoIYUV(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op[3];
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ /* Convert */
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op[0]=o->pixels[0]+o->pitches[0]*y;
+ op[1]=o->pixels[1]+o->pitches[1]*(y/2);
+ op[2]=o->pixels[2]+o->pitches[2]*(y/2);
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p,yuv, monochrome, luminance);
+ *(op[0]++)=yuv[0];
+ if(x%2==0 && y%2==0)
+ {
+ *(op[1]++)=yuv[1];
+ *(op[2]++)=yuv[2];
+ }
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoUYVY(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op;
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op=o->pixels[0]+o->pitches[0]*y;
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p, yuv, monochrome, luminance);
+ if(x%2==0)
+ {
+ *(op++)=yuv[1];
+ *(op++)=yuv[0];
+ *(op++)=yuv[2];
+ }
+ else
+ *(op++)=yuv[0];
+
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoYVYU(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op;
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op=o->pixels[0]+o->pitches[0]*y;
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p,yuv, monochrome, luminance);
+ if(x%2==0)
+ {
+ *(op++)=yuv[0];
+ *(op++)=yuv[2];
+ op[1]=yuv[1];
+ }
+ else
+ {
+ *op=yuv[0];
+ op+=2;
+ }
+
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+void ConvertRGBtoYUY2(SDL_Surface *s, SDL_Overlay *o, int monochrome, int luminance)
+{
+ int x,y;
+ int yuv[3];
+ Uint8 *p,*op;
+
+ SDL_LockSurface(s);
+ SDL_LockYUVOverlay(o);
+
+ for(y=0; y<s->h && y<o->h; y++)
+ {
+ p=((Uint8 *) s->pixels)+s->pitch*y;
+ op=o->pixels[0]+o->pitches[0]*y;
+ for(x=0; x<s->w && x<o->w; x++)
+ {
+ RGBtoYUV(p,yuv, monochrome, luminance);
+ if(x%2==0)
+ {
+ *(op++)=yuv[0];
+ *(op++)=yuv[1];
+ op[1]=yuv[2];
+ }
+ else
+ {
+ *op=yuv[0];
+ op+=2;
+ }
+
+ p+=s->format->BytesPerPixel;
+ }
+ }
+
+ SDL_UnlockYUVOverlay(o);
+ SDL_UnlockSurface(s);
+}
+
+static void PrintUsage(char *argv0)
+{
+ fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Where 'arg' is any of the following options:\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " -fps <frames per second>\n");
+ fprintf(stderr, " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
+ fprintf(stderr, " -scale <scale factor> (initial scale of the overlay)\n");
+ fprintf(stderr, " -help (shows this help)\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Press ESC to exit, or SPACE to freeze the movie while application running.\n");
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, char **argv)
+{
+ Uint8* RawMooseData;
+ SDL_RWops* handle;
+ SDL_Surface* screen;
+ SDL_Surface* MooseFrame[MOOSEFRAMES_COUNT];
+ SDL_Overlay* overlay;
+ SDL_Rect overlayrect;
+ SDL_Event event;
+ Uint32 lastftick;
+ int paused=0;
+ int resized=0;
+ int i;
+ int fps=12;
+ int fpsdelay;
+ int overlay_format=SDL_YUY2_OVERLAY;
+ int scale=5;
+
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
+ {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ return 3;
+ }
+
+ while ( argc > 1 )
+ {
+ if (strcmp(argv[1], "-fps")== 0)
+ {
+ if (argv[2])
+ {
+ fps = atoi(argv[2]);
+ if (fps==0)
+ {
+ fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
+ quit(10);
+ }
+ if ((fps<0) || (fps>1000))
+ {
+ fprintf(stderr, "The -fps option must be in range from 1 to 1000, default is 12.\n");
+ quit(10);
+ }
+ argv += 2;
+ argc -= 2;
+ }
+ else
+ {
+ fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
+ quit(10);
+ }
+ } else
+ if (strcmp(argv[1], "-format") == 0)
+ {
+ if (argv[2])
+ {
+ if (!strcmp(argv[2],"YV12"))
+ overlay_format = SDL_YV12_OVERLAY;
+ else if(!strcmp(argv[2],"IYUV"))
+ overlay_format = SDL_IYUV_OVERLAY;
+ else if(!strcmp(argv[2],"YUY2"))
+ overlay_format = SDL_YUY2_OVERLAY;
+ else if(!strcmp(argv[2],"UYVY"))
+ overlay_format = SDL_UYVY_OVERLAY;
+ else if(!strcmp(argv[2],"YVYU"))
+ overlay_format = SDL_YVYU_OVERLAY;
+ else
+ {
+ fprintf(stderr, "The -format option %s is not recognized, see help for info.\n", argv[2]);
+ quit(10);
+ }
+ argv += 2;
+ argc -= 2;
+ }
+ else
+ {
+ fprintf(stderr, "The -format option requires an argument, default is YUY2.\n");
+ quit(10);
+ }
+ } else
+ if (strcmp(argv[1], "-scale") == 0)
+ {
+ if (argv[2])
+ {
+ scale = atoi(argv[2]);
+ if (scale==0)
+ {
+ fprintf(stderr, "The -scale option requires an argument [from 1 to 50], default is 5.\n");
+ quit(10);
+ }
+ if ((scale<0) || (scale>50))
+ {
+ fprintf(stderr, "The -scale option must be in range from 1 to 50, default is 5.\n");
+ quit(10);
+ }
+ argv += 2;
+ argc -= 2;
+ }
+ else
+ {
+ fprintf(stderr, "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
+ quit(10);
+ }
+ } else
+ if ((strcmp(argv[1], "-help") == 0 ) || (strcmp(argv[1], "-h") == 0))
+ {
+ PrintUsage(argv[0]);
+ quit(0);
+ } else
+ {
+ fprintf(stderr, "Unrecognized option: %s.\n", argv[1]);
+ quit(10);
+ }
+ break;
+ }
+
+ RawMooseData=(Uint8*)malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
+ if (RawMooseData==NULL)
+ {
+ fprintf(stderr, "Can't allocate memory for movie !\n");
+ free(RawMooseData);
+ quit(1);
+ }
+
+ /* load the trojan moose images */
+ handle=SDL_RWFromFile("moose.dat", "rb");
+ if (handle==NULL)
+ {
+ fprintf(stderr, "Can't find the file moose.dat !\n");
+ free(RawMooseData);
+ quit(2);
+ }
+
+ SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
+
+ SDL_RWclose(handle);
+
+ /* Set video mode */
+ if ( (screen=SDL_SetVideoMode(MOOSEPIC_W*scale, MOOSEPIC_H*scale, 0, SDL_RESIZABLE | SDL_SWSURFACE)) == NULL )
+ {
+ fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
+ free(RawMooseData);
+ quit(4);
+ }
+
+ /* Set the window manager title bar */
+ SDL_WM_SetCaption("SDL test overlay: running moose", "testoverlay2");
+
+ for (i=0; i<MOOSEFRAMES_COUNT; i++)
+ {
+ MooseFrame[i]=SDL_CreateRGBSurfaceFrom(RawMooseData+i*MOOSEFRAME_SIZE, MOOSEPIC_W,
+ MOOSEPIC_H, 8, MOOSEPIC_W, 0, 0, 0, 0);
+ if (MooseFrame[i]==NULL)
+ {
+ fprintf(stderr, "Couldn't create SDL_Surfaces:%s\n", SDL_GetError());
+ free(RawMooseData);
+ quit(5);
+ }
+ SDL_SetColors(MooseFrame[i], MooseColors, 0, 84);
+
+ {
+ SDL_Surface *newsurf;
+ SDL_PixelFormat format;
+
+ format.palette=NULL;
+ format.BitsPerPixel=32;
+ format.BytesPerPixel=4;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ format.Rshift=0;
+ format.Gshift=8;
+ format.Bshift=16;
+#else
+ format.Rshift=24;
+ format.Gshift=16;
+ format.Bshift=8;
+#endif
+ format.Ashift=0;
+ format.Rmask=0xff<<format.Rshift;
+ format.Gmask=0xff<<format.Gshift;
+ format.Bmask=0xff<<format.Bshift;
+ format.Amask=0;
+ format.Rloss=0;
+ format.Gloss=0;
+ format.Bloss=0;
+ format.Aloss=8;
+ format.colorkey=0;
+ format.alpha=0;
+
+ newsurf=SDL_ConvertSurface(MooseFrame[i], &format, SDL_SWSURFACE);
+ if(!newsurf)
+ {
+ fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n", SDL_GetError());
+ quit(6);
+ }
+ SDL_FreeSurface(MooseFrame[i]);
+ MooseFrame[i]=newsurf;
+ }
+ }
+
+ free(RawMooseData);
+
+ overlay=SDL_CreateYUVOverlay(MOOSEPIC_W, MOOSEPIC_H, overlay_format, screen);
+ if (!overlay)
+ {
+ fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
+ quit(7);
+ }
+
+ printf("Created %dx%dx%d %s %s overlay\n",overlay->w,overlay->h,overlay->planes,
+ overlay->hw_overlay?"hardware":"software",
+ overlay->format==SDL_YV12_OVERLAY?"YV12":
+ overlay->format==SDL_IYUV_OVERLAY?"IYUV":
+ overlay->format==SDL_YUY2_OVERLAY?"YUY2":
+ overlay->format==SDL_UYVY_OVERLAY?"UYVY":
+ overlay->format==SDL_YVYU_OVERLAY?"YVYU":
+ "Unknown");
+
+ for(i=0; i<overlay->planes; i++)
+ {
+ printf(" plane %d: pitch=%d\n", i, overlay->pitches[i]);
+ }
+
+ overlayrect.x=0;
+ overlayrect.y=0;
+ overlayrect.w=MOOSEPIC_W*scale;
+ overlayrect.h=MOOSEPIC_H*scale;
+
+ /* set the start frame */
+ i=0;
+ fpsdelay=1000/fps;
+
+ /* Ignore key up events, they don't even get filtered */
+ SDL_EventState(SDL_KEYUP, SDL_IGNORE);
+
+ lastftick=SDL_GetTicks();
+
+ /* Loop, waiting for QUIT or RESIZE */
+ while (1)
+ {
+ if (SDL_PollEvent(&event))
+ {
+ switch (event.type)
+ {
+ case SDL_VIDEORESIZE:
+ screen=SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_RESIZABLE | SDL_SWSURFACE);
+ overlayrect.w=event.resize.w;
+ overlayrect.h=event.resize.h;
+ if (paused)
+ {
+ resized=1;
+ }
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ overlayrect.x = event.button.x - overlayrect.w/2;
+ overlayrect.y = event.button.y - overlayrect.h/2;
+ break;
+ case SDL_KEYDOWN:
+ if (event.key.keysym.sym == SDLK_SPACE)
+ {
+ paused=!paused;
+ break;
+ }
+ if (event.key.keysym.sym != SDLK_ESCAPE)
+ {
+ break;
+ }
+ case SDL_QUIT:
+ SDL_FreeYUVOverlay(overlay);
+ for (i=0; i<MOOSEFRAMES_COUNT; i++)
+ {
+ SDL_FreeSurface(MooseFrame[i]);
+ }
+ quit(0);
+ }
+ }
+
+ if ((!paused)||(resized))
+ {
+ if (((SDL_GetTicks()-lastftick)>fpsdelay)||(resized))
+ {
+ lastftick=SDL_GetTicks();
+
+ switch (overlay_format)
+ {
+ case SDL_YUY2_OVERLAY:
+ ConvertRGBtoYUY2(MooseFrame[i], overlay, 0, 100);
+ break;
+ case SDL_YV12_OVERLAY:
+ ConvertRGBtoYV12(MooseFrame[i], overlay, 0, 100);
+ break;
+ case SDL_UYVY_OVERLAY:
+ ConvertRGBtoUYVY(MooseFrame[i], overlay, 0, 100);
+ break;
+ case SDL_YVYU_OVERLAY:
+ ConvertRGBtoYVYU(MooseFrame[i], overlay, 0, 100);
+ break;
+ case SDL_IYUV_OVERLAY:
+ ConvertRGBtoIYUV(MooseFrame[i], overlay, 0, 100);
+ break;
+ }
+
+ SDL_DisplayYUVOverlay(overlay, &overlayrect);
+ if (!resized)
+ {
+ i++;
+ if (i==10)
+ {
+ i=0;
+ }
+ }
+ else
+ {
+ resized=0;
+ }
+ }
+ }
+ /* kind of timeslice to OS */
+ SDL_Delay(1);
+ }
+
+ SDL_Quit();
+ return 0;
+}
+
diff --git a/test/testpalette.c b/test/testpalette.c
new file mode 100644
index 0000000..2ad4916
--- /dev/null
+++ b/test/testpalette.c
@@ -0,0 +1,342 @@
+/*
+ * testpalette.c
+ *
+ * A simple test of runtime palette modification for animation
+ * (using the SDL_SetPalette() API).
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+/* This isn't in the Windows headers */
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#include "SDL.h"
+
+/* screen size */
+#define SCRW 640
+#define SCRH 480
+
+#define NBOATS 5
+#define SPEED 2
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+/*
+ * wave colours: Made by taking a narrow cross-section of a wave picture
+ * in Gimp, saving in PPM ascii format and formatting with Emacs macros.
+ */
+static SDL_Color wavemap[] = {
+ {0,2,103}, {0,7,110}, {0,13,117}, {0,19,125},
+ {0,25,133}, {0,31,141}, {0,37,150}, {0,43,158},
+ {0,49,166}, {0,55,174}, {0,61,182}, {0,67,190},
+ {0,73,198}, {0,79,206}, {0,86,214}, {0,96,220},
+ {5,105,224}, {12,112,226}, {19,120,227}, {26,128,229},
+ {33,135,230}, {40,143,232}, {47,150,234}, {54,158,236},
+ {61,165,238}, {68,173,239}, {75,180,241}, {82,188,242},
+ {89,195,244}, {96,203,246}, {103,210,248}, {112,218,250},
+ {124,224,250}, {135,226,251}, {146,229,251}, {156,231,252},
+ {167,233,252}, {178,236,252}, {189,238,252}, {200,240,252},
+ {211,242,252}, {222,244,252}, {233,247,252}, {242,249,252},
+ {237,250,252}, {209,251,252}, {174,251,252}, {138,252,252},
+ {102,251,252}, {63,250,252}, {24,243,252}, {7,225,252},
+ {4,203,252}, {3,181,252}, {2,158,252}, {1,136,251},
+ {0,111,248}, {0,82,234}, {0,63,213}, {0,50,192},
+ {0,39,172}, {0,28,152}, {0,17,132}, {0,7,114}
+};
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+static void sdlerr(char *when)
+{
+ fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError());
+ quit(1);
+}
+
+/* create a background surface */
+static SDL_Surface *make_bg(SDL_Surface *screen, int startcol)
+{
+ int i;
+ SDL_Surface *bg = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, screen->h,
+ 8, 0, 0, 0, 0);
+ if(!bg)
+ sdlerr("creating background surface");
+
+ /* set the palette to the logical screen palette so that blits
+ won't be translated */
+ SDL_SetColors(bg, screen->format->palette->colors, 0, 256);
+
+ /* Make a wavy background pattern using colours 0-63 */
+ if(SDL_LockSurface(bg) < 0)
+ sdlerr("locking background");
+ for(i = 0; i < SCRH; i++) {
+ Uint8 *p = (Uint8 *)bg->pixels + i * bg->pitch;
+ int j, d;
+ d = 0;
+ for(j = 0; j < SCRW; j++) {
+ int v = MAX(d, -2);
+ v = MIN(v, 2);
+ if(i > 0)
+ v += p[-bg->pitch] + 65 - startcol;
+ p[j] = startcol + (v & 63);
+ d += ((rand() >> 3) % 3) - 1;
+ }
+ }
+ SDL_UnlockSurface(bg);
+ return(bg);
+}
+
+/*
+ * Return a surface flipped horisontally. Only works for 8bpp;
+ * extension to arbitrary bitness is left as an exercise for the reader.
+ */
+static SDL_Surface *hflip(SDL_Surface *s)
+{
+ int i;
+ SDL_Surface *z = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h, 8,
+ 0, 0, 0, 0);
+ /* copy palette */
+ SDL_SetColors(z, s->format->palette->colors,
+ 0, s->format->palette->ncolors);
+ if(SDL_LockSurface(s) < 0 || SDL_LockSurface(z) < 0)
+ sdlerr("locking flip images");
+
+ for(i = 0; i < s->h; i++) {
+ int j;
+ Uint8 *from = (Uint8 *)s->pixels + i * s->pitch;
+ Uint8 *to = (Uint8 *)z->pixels + i * z->pitch + s->w - 1;
+ for(j = 0; j < s->w; j++)
+ to[-j] = from[j];
+ }
+
+ SDL_UnlockSurface(z);
+ SDL_UnlockSurface(s);
+ return z;
+}
+
+int main(int argc, char **argv)
+{
+ SDL_Color cmap[256];
+ SDL_Surface *screen;
+ SDL_Surface *bg;
+ SDL_Surface *boat[2];
+ unsigned vidflags = 0;
+ unsigned start;
+ int fade_max = 400;
+ int fade_level, fade_dir;
+ int boatcols, frames, i, red;
+ int boatx[NBOATS], boaty[NBOATS], boatdir[NBOATS];
+ int gamma_fade = 0;
+ int gamma_ramp = 0;
+
+ if(SDL_Init(SDL_INIT_VIDEO) < 0)
+ sdlerr("initialising SDL");
+
+ while(--argc) {
+ ++argv;
+ if(strcmp(*argv, "-hw") == 0)
+ vidflags |= SDL_HWSURFACE;
+ else if(strcmp(*argv, "-fullscreen") == 0)
+ vidflags |= SDL_FULLSCREEN;
+ else if(strcmp(*argv, "-nofade") == 0)
+ fade_max = 1;
+ else if(strcmp(*argv, "-gamma") == 0)
+ gamma_fade = 1;
+ else if(strcmp(*argv, "-gammaramp") == 0)
+ gamma_ramp = 1;
+ else {
+ fprintf(stderr,
+ "usage: testpalette "
+ " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n");
+ quit(1);
+ }
+ }
+
+ /* Ask explicitly for 8bpp and a hardware palette */
+ if((screen = SDL_SetVideoMode(SCRW, SCRH, 8, vidflags | SDL_HWPALETTE)) == NULL) {
+ fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n",
+ SCRW, SCRH, SDL_GetError());
+ quit(1);
+ }
+
+ if (vidflags & SDL_FULLSCREEN) SDL_ShowCursor (SDL_FALSE);
+
+ if((boat[0] = SDL_LoadBMP("sail.bmp")) == NULL)
+ sdlerr("loading sail.bmp");
+ /* We've chosen magenta (#ff00ff) as colour key for the boat */
+ SDL_SetColorKey(boat[0], SDL_SRCCOLORKEY | SDL_RLEACCEL,
+ SDL_MapRGB(boat[0]->format, 0xff, 0x00, 0xff));
+ boatcols = boat[0]->format->palette->ncolors;
+ boat[1] = hflip(boat[0]);
+ SDL_SetColorKey(boat[1], SDL_SRCCOLORKEY | SDL_RLEACCEL,
+ SDL_MapRGB(boat[1]->format, 0xff, 0x00, 0xff));
+
+ /*
+ * First set the physical screen palette to black, so the user won't
+ * see our initial drawing on the screen.
+ */
+ memset(cmap, 0, sizeof(cmap));
+ SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, 256);
+
+ /*
+ * Proper palette management is important when playing games with the
+ * colormap. We have divided the palette as follows:
+ *
+ * index 0..(boatcols-1): used for the boat
+ * index boatcols..(boatcols+63): used for the waves
+ */
+ SDL_SetPalette(screen, SDL_LOGPAL,
+ boat[0]->format->palette->colors, 0, boatcols);
+ SDL_SetPalette(screen, SDL_LOGPAL, wavemap, boatcols, 64);
+
+ /*
+ * Now the logical screen palette is set, and will remain unchanged.
+ * The boats already have the same palette so fast blits can be used.
+ */
+ memcpy(cmap, screen->format->palette->colors, 256 * sizeof(SDL_Color));
+
+ /* save the index of the red colour for later */
+ red = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00);
+
+ bg = make_bg(screen, boatcols); /* make a nice wavy background surface */
+
+ /* initial screen contents */
+ if(SDL_BlitSurface(bg, NULL, screen, NULL) < 0)
+ sdlerr("blitting background to screen");
+ SDL_Flip(screen); /* actually put the background on screen */
+
+ /* determine initial boat placements */
+ for(i = 0; i < NBOATS; i++) {
+ boatx[i] = (rand() % (SCRW + boat[0]->w)) - boat[0]->w;
+ boaty[i] = i * (SCRH - boat[0]->h) / (NBOATS - 1);
+ boatdir[i] = ((rand() >> 5) & 1) * 2 - 1;
+ }
+
+ start = SDL_GetTicks();
+ frames = 0;
+ fade_dir = 1;
+ fade_level = 0;
+ do {
+ SDL_Event e;
+ SDL_Rect updates[NBOATS];
+ SDL_Rect r;
+ int redphase;
+
+ /* A small event loop: just exit on any key or mouse button event */
+ while(SDL_PollEvent(&e)) {
+ if(e.type == SDL_KEYDOWN || e.type == SDL_QUIT
+ || e.type == SDL_MOUSEBUTTONDOWN) {
+ if(fade_dir < 0)
+ fade_level = 0;
+ fade_dir = -1;
+ }
+ }
+
+ /* move boats */
+ for(i = 0; i < NBOATS; i++) {
+ int old_x = boatx[i];
+ /* update boat position */
+ boatx[i] += boatdir[i] * SPEED;
+ if(boatx[i] <= -boat[0]->w || boatx[i] >= SCRW)
+ boatdir[i] = -boatdir[i];
+
+ /* paint over the old boat position */
+ r.x = old_x;
+ r.y = boaty[i];
+ r.w = boat[0]->w;
+ r.h = boat[0]->h;
+ if(SDL_BlitSurface(bg, &r, screen, &r) < 0)
+ sdlerr("blitting background");
+
+ /* construct update rectangle (bounding box of old and new pos) */
+ updates[i].x = MIN(old_x, boatx[i]);
+ updates[i].y = boaty[i];
+ updates[i].w = boat[0]->w + SPEED;
+ updates[i].h = boat[0]->h;
+ /* clip update rectangle to screen */
+ if(updates[i].x < 0) {
+ updates[i].w += updates[i].x;
+ updates[i].x = 0;
+ }
+ if(updates[i].x + updates[i].w > SCRW)
+ updates[i].w = SCRW - updates[i].x;
+ }
+
+ for(i = 0; i < NBOATS; i++) {
+ /* paint boat on new position */
+ r.x = boatx[i];
+ r.y = boaty[i];
+ if(SDL_BlitSurface(boat[(boatdir[i] + 1) / 2], NULL,
+ screen, &r) < 0)
+ sdlerr("blitting boat");
+ }
+
+ /* cycle wave palette */
+ for(i = 0; i < 64; i++)
+ cmap[boatcols + ((i + frames) & 63)] = wavemap[i];
+
+ if(fade_dir) {
+ /* Fade the entire palette in/out */
+ fade_level += fade_dir;
+
+ if(gamma_fade) {
+ /* Fade linearly in gamma level (lousy) */
+ float level = (float)fade_level / fade_max;
+ if(SDL_SetGamma(level, level, level) < 0)
+ sdlerr("setting gamma");
+
+ } else if(gamma_ramp) {
+ /* Fade using gamma ramp (better) */
+ Uint16 ramp[256];
+ for(i = 0; i < 256; i++)
+ ramp[i] = (i * fade_level / fade_max) << 8;
+ if(SDL_SetGammaRamp(ramp, ramp, ramp) < 0)
+ sdlerr("setting gamma ramp");
+
+ } else {
+ /* Fade using direct palette manipulation (best) */
+ memcpy(cmap, screen->format->palette->colors,
+ boatcols * sizeof(SDL_Color));
+ for(i = 0; i < boatcols + 64; i++) {
+ cmap[i].r = cmap[i].r * fade_level / fade_max;
+ cmap[i].g = cmap[i].g * fade_level / fade_max;
+ cmap[i].b = cmap[i].b * fade_level / fade_max;
+ }
+ }
+ if(fade_level == fade_max)
+ fade_dir = 0;
+ }
+
+ /* pulse the red colour (done after the fade, for a night effect) */
+ redphase = frames % 64;
+ cmap[red].r = (int)(255 * sin(redphase * M_PI / 63));
+
+ SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, boatcols + 64);
+
+ /* update changed areas of the screen */
+ SDL_UpdateRects(screen, NBOATS, updates);
+ frames++;
+ } while(fade_level > 0);
+
+ printf("%d frames, %.2f fps\n",
+ frames, 1000.0 * frames / (SDL_GetTicks() - start));
+
+ if (vidflags & SDL_FULLSCREEN) SDL_ShowCursor (SDL_TRUE);
+ SDL_Quit();
+ return 0;
+}
+
diff --git a/test/testplatform.c b/test/testplatform.c
new file mode 100644
index 0000000..6edfd17
--- /dev/null
+++ b/test/testplatform.c
@@ -0,0 +1,210 @@
+
+#include <stdio.h>
+
+#include "SDL.h"
+#include "SDL_endian.h"
+#include "SDL_cpuinfo.h"
+
+/*
+ * Watcom C flags these as Warning 201: "Unreachable code" if you just
+ * compare them directly, so we push it through a function to keep the
+ * compiler quiet. --ryan.
+ */
+static int badsize(size_t sizeoftype, size_t hardcodetype)
+{
+ return sizeoftype != hardcodetype;
+}
+
+int TestTypes(SDL_bool verbose)
+{
+ int error = 0;
+
+ if ( badsize(sizeof(Uint8), 1) ) {
+ if ( verbose )
+ printf("sizeof(Uint8) != 1, instead = %ul\n",
+ sizeof(Uint8));
+ ++error;
+ }
+ if ( badsize(sizeof(Uint16), 2) ) {
+ if ( verbose )
+ printf("sizeof(Uint16) != 2, instead = %ul\n",
+ sizeof(Uint16));
+ ++error;
+ }
+ if ( badsize(sizeof(Uint32), 4) ) {
+ if ( verbose )
+ printf("sizeof(Uint32) != 4, instead = %ul\n",
+ sizeof(Uint32));
+ ++error;
+ }
+#ifdef SDL_HAS_64BIT_TYPE
+ if ( badsize(sizeof(Uint64), 8) ) {
+ if ( verbose )
+ printf("sizeof(Uint64) != 8, instead = %ul\n",
+ sizeof(Uint64));
+ ++error;
+ }
+#else
+ if ( verbose ) {
+ printf("WARNING: No 64-bit datatype on this platform\n");
+ }
+#endif
+ if ( verbose && !error )
+ printf("All data types are the expected size.\n");
+
+ return( error ? 1 : 0 );
+}
+
+int TestEndian(SDL_bool verbose)
+{
+ int error = 0;
+ Uint16 value = 0x1234;
+ int real_byteorder;
+ Uint16 value16 = 0xCDAB;
+ Uint16 swapped16 = 0xABCD;
+ Uint32 value32 = 0xEFBEADDE;
+ Uint32 swapped32 = 0xDEADBEEF;
+#ifdef SDL_HAS_64BIT_TYPE
+ Uint64 value64, swapped64;
+ value64 = 0xEFBEADDE;
+ value64 <<= 32;
+ value64 |= 0xCDAB3412;
+ swapped64 = 0x1234ABCD;
+ swapped64 <<= 32;
+ swapped64 |= 0xDEADBEEF;
+#endif
+
+ if ( verbose ) {
+ printf("Detected a %s endian machine.\n",
+ (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
+ }
+ if ( (*((char *)&value) >> 4) == 0x1 ) {
+ real_byteorder = SDL_BIG_ENDIAN;
+ } else {
+ real_byteorder = SDL_LIL_ENDIAN;
+ }
+ if ( real_byteorder != SDL_BYTEORDER ) {
+ if ( verbose ) {
+ printf("Actually a %s endian machine!\n",
+ (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
+ }
+ ++error;
+ }
+ if ( verbose ) {
+ printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16));
+ }
+ if ( SDL_Swap16(value16) != swapped16 ) {
+ if ( verbose ) {
+ printf("16 bit value swapped incorrectly!\n");
+ }
+ ++error;
+ }
+ if ( verbose ) {
+ printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32));
+ }
+ if ( SDL_Swap32(value32) != swapped32 ) {
+ if ( verbose ) {
+ printf("32 bit value swapped incorrectly!\n");
+ }
+ ++error;
+ }
+#ifdef SDL_HAS_64BIT_TYPE
+ if ( verbose ) {
+#ifdef _MSC_VER
+ printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, SDL_Swap64(value64));
+#else
+ printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, SDL_Swap64(value64));
+#endif
+ }
+ if ( SDL_Swap64(value64) != swapped64 ) {
+ if ( verbose ) {
+ printf("64 bit value swapped incorrectly!\n");
+ }
+ ++error;
+ }
+#endif
+ return( error ? 1 : 0 );
+}
+
+
+int TestCPUInfo(SDL_bool verbose)
+{
+ if ( verbose ) {
+ printf("RDTSC %s\n", SDL_HasRDTSC() ? "detected" : "not detected");
+ printf("MMX %s\n", SDL_HasMMX() ? "detected" : "not detected");
+ printf("MMX Ext %s\n", SDL_HasMMXExt() ? "detected" : "not detected");
+ printf("3DNow %s\n", SDL_Has3DNow() ? "detected" : "not detected");
+ printf("3DNow Ext %s\n", SDL_Has3DNowExt() ? "detected" : "not detected");
+ printf("SSE %s\n", SDL_HasSSE() ? "detected" : "not detected");
+ printf("SSE2 %s\n", SDL_HasSSE2() ? "detected" : "not detected");
+ printf("AltiVec %s\n", SDL_HasAltiVec() ? "detected" : "not detected");
+ }
+ return(0);
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_bool verbose = SDL_TRUE;
+ int status = 0;
+
+ if ( argv[1] && (SDL_strcmp(argv[1], "-q") == 0) ) {
+ verbose = SDL_FALSE;
+ }
+ if ( verbose ) {
+ printf("This system is running %s\n",
+#if __AIX__
+ "AIX"
+#elif __HAIKU__
+/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
+ "Haiku"
+#elif __BEOS__
+ "BeOS"
+#elif __BSDI__
+ "BSDI"
+#elif __DREAMCAST__
+ "Dreamcast"
+#elif __FREEBSD__
+ "FreeBSD"
+#elif __HPUX__
+ "HP-UX"
+#elif __IRIX__
+ "Irix"
+#elif __LINUX__
+ "Linux"
+#elif __MINT__
+ "Atari MiNT"
+#elif __MACOS__
+ "MacOS Classic"
+#elif __MACOSX__
+ "Mac OS X"
+#elif __NETBSD__
+ "NetBSD"
+#elif __OPENBSD__
+ "OpenBSD"
+#elif __OS2__
+ "OS/2"
+#elif __OSF__
+ "OSF/1"
+#elif __QNXNTO__
+ "QNX Neutrino"
+#elif __RISCOS__
+ "RISC OS"
+#elif __SOLARIS__
+ "Solaris"
+#elif __WIN32__
+#ifdef _WIN32_WCE
+ "Windows CE"
+#else
+ "Windows"
+#endif
+#else
+ "an unknown operating system! (see SDL_platform.h)"
+#endif
+ );
+ }
+
+ status += TestTypes(verbose);
+ status += TestEndian(verbose);
+ status += TestCPUInfo(verbose);
+ return status;
+}
diff --git a/test/testsem.c b/test/testsem.c
new file mode 100644
index 0000000..9c0940e
--- /dev/null
+++ b/test/testsem.c
@@ -0,0 +1,78 @@
+
+/* Simple test of the SDL semaphore code */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+#define NUM_THREADS 10
+
+static SDL_sem *sem;
+int alive = 1;
+
+int SDLCALL ThreadFunc(void *data)
+{
+ int threadnum = (int)(uintptr_t)data;
+ while ( alive ) {
+ SDL_SemWait(sem);
+ fprintf(stderr, "Thread number %d has got the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem));
+ SDL_Delay(200);
+ SDL_SemPost(sem);
+ fprintf(stderr, "Thread number %d has released the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem));
+ SDL_Delay(1); /* For the scheduler */
+ }
+ printf("Thread number %d exiting.\n", threadnum);
+ return 0;
+}
+
+static void killed(int sig)
+{
+ alive = 0;
+}
+
+int main(int argc, char **argv)
+{
+ SDL_Thread *threads[NUM_THREADS];
+ uintptr_t i;
+ int init_sem;
+
+ if(argc < 2) {
+ fprintf(stderr,"Usage: %s init_value\n", argv[0]);
+ return(1);
+ }
+
+ /* Load the SDL library */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+ signal(SIGTERM, killed);
+ signal(SIGINT, killed);
+
+ init_sem = atoi(argv[1]);
+ sem = SDL_CreateSemaphore(init_sem);
+
+ printf("Running %d threads, semaphore value = %d\n", NUM_THREADS, init_sem);
+ /* Create all the threads */
+ for( i = 0; i < NUM_THREADS; ++i ) {
+ threads[i] = SDL_CreateThread(ThreadFunc, (void*)i);
+ }
+
+ /* Wait 10 seconds */
+ SDL_Delay(10 * 1000);
+
+ /* Wait for all threads to finish */
+ printf("Waiting for threads to finish\n");
+ alive = 0;
+ for( i = 0; i < NUM_THREADS; ++i ) {
+ SDL_WaitThread(threads[i], NULL);
+ }
+ printf("Finished waiting for threads\n");
+
+ SDL_DestroySemaphore(sem);
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testsprite.c b/test/testsprite.c
new file mode 100644
index 0000000..6d9e0a8
--- /dev/null
+++ b/test/testsprite.c
@@ -0,0 +1,323 @@
+/* Simple program: Move N sprites around on the screen as fast as possible */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#include <time.h>
+
+#include "SDL.h"
+
+#define NUM_SPRITES 100
+#define MAX_SPEED 1
+
+SDL_Surface *sprite;
+int numsprites;
+SDL_Rect *sprite_rects;
+SDL_Rect *positions;
+SDL_Rect *velocities;
+int sprites_visible;
+int debug_flip;
+Uint16 sprite_w, sprite_h;
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+int LoadSprite(char *file)
+{
+ SDL_Surface *temp;
+
+ /* Load the sprite image */
+ sprite = SDL_LoadBMP(file);
+ if ( sprite == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+ return(-1);
+ }
+
+ /* Set transparent pixel as the pixel at (0,0) */
+ if ( sprite->format->palette ) {
+ SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL),
+ *(Uint8 *)sprite->pixels);
+ }
+
+ /* Convert sprite to video format */
+ temp = SDL_DisplayFormat(sprite);
+ SDL_FreeSurface(sprite);
+ if ( temp == NULL ) {
+ fprintf(stderr, "Couldn't convert background: %s\n",
+ SDL_GetError());
+ return(-1);
+ }
+ sprite = temp;
+
+ /* We're ready to roll. :) */
+ return(0);
+}
+
+void MoveSprites(SDL_Surface *screen, Uint32 background)
+{
+ int i, nupdates;
+ SDL_Rect area, *position, *velocity;
+
+ nupdates = 0;
+ /* Erase all the sprites if necessary */
+ if ( sprites_visible ) {
+ SDL_FillRect(screen, NULL, background);
+ }
+
+ /* Move the sprite, bounce at the wall, and draw */
+ for ( i=0; i<numsprites; ++i ) {
+ position = &positions[i];
+ velocity = &velocities[i];
+ position->x += velocity->x;
+ if ( (position->x < 0) || (position->x >= (screen->w - sprite_w)) ) {
+ velocity->x = -velocity->x;
+ position->x += velocity->x;
+ }
+ position->y += velocity->y;
+ if ( (position->y < 0) || (position->y >= (screen->h - sprite_w)) ) {
+ velocity->y = -velocity->y;
+ position->y += velocity->y;
+ }
+
+ /* Blit the sprite onto the screen */
+ area = *position;
+ SDL_BlitSurface(sprite, NULL, screen, &area);
+ sprite_rects[nupdates++] = area;
+ }
+
+ if (debug_flip) {
+ if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+ static int t = 0;
+
+ Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0);
+ SDL_Rect r;
+ r.x = (sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20);
+ r.y = 0;
+ r.w = 20;
+ r.h = screen->h;
+
+ SDL_FillRect (screen, &r, color);
+ t+=2;
+ }
+ }
+
+ /* Update the screen! */
+ if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+ SDL_Flip(screen);
+ } else {
+ SDL_UpdateRects(screen, nupdates, sprite_rects);
+ }
+ sprites_visible = 1;
+}
+
+/* This is a way of telling whether or not to use hardware surfaces */
+Uint32 FastestFlags(Uint32 flags, int width, int height, int bpp)
+{
+ const SDL_VideoInfo *info;
+
+ /* Hardware acceleration is only used in fullscreen mode */
+ flags |= SDL_FULLSCREEN;
+
+ /* Check for various video capabilities */
+ info = SDL_GetVideoInfo();
+ if ( info->blit_hw_CC && info->blit_fill ) {
+ /* We use accelerated colorkeying and color filling */
+ flags |= SDL_HWSURFACE;
+ }
+ /* If we have enough video memory, and will use accelerated
+ blits directly to it, then use page flipping.
+ */
+ if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+ /* Direct hardware blitting without double-buffering
+ causes really bad flickering.
+ */
+ if ( info->video_mem*1024 > (height*width*bpp/8) ) {
+ flags |= SDL_DOUBLEBUF;
+ } else {
+ flags &= ~SDL_HWSURFACE;
+ }
+ }
+
+ /* Return the flags */
+ return(flags);
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+ Uint8 *mem;
+ int width, height;
+ Uint8 video_bpp;
+ Uint32 videoflags;
+ Uint32 background;
+ int i, done;
+ SDL_Event event;
+ Uint32 then, now, frames;
+
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ numsprites = NUM_SPRITES;
+ videoflags = SDL_SWSURFACE|SDL_ANYFORMAT;
+ width = 640;
+ height = 480;
+ video_bpp = 8;
+ debug_flip = 0;
+ while ( argc > 1 ) {
+ --argc;
+ if ( strcmp(argv[argc-1], "-width") == 0 ) {
+ width = atoi(argv[argc]);
+ --argc;
+ } else
+ if ( strcmp(argv[argc-1], "-height") == 0 ) {
+ height = atoi(argv[argc]);
+ --argc;
+ } else
+ if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
+ video_bpp = atoi(argv[argc]);
+ videoflags &= ~SDL_ANYFORMAT;
+ --argc;
+ } else
+ if ( strcmp(argv[argc], "-fast") == 0 ) {
+ videoflags = FastestFlags(videoflags, width, height, video_bpp);
+ } else
+ if ( strcmp(argv[argc], "-hw") == 0 ) {
+ videoflags ^= SDL_HWSURFACE;
+ } else
+ if ( strcmp(argv[argc], "-flip") == 0 ) {
+ videoflags ^= SDL_DOUBLEBUF;
+ } else
+ if ( strcmp(argv[argc], "-debugflip") == 0 ) {
+ debug_flip ^= 1;
+ } else
+ if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
+ videoflags ^= SDL_FULLSCREEN;
+ } else
+ if ( isdigit(argv[argc][0]) ) {
+ numsprites = atoi(argv[argc]);
+ } else {
+ fprintf(stderr,
+ "Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n",
+ argv[0]);
+ quit(1);
+ }
+ }
+
+ /* Set video mode */
+ screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
+ if ( ! screen ) {
+ fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
+ width, height, SDL_GetError());
+ quit(2);
+ }
+
+ /* Load the sprite */
+ if ( LoadSprite("icon.bmp") < 0 ) {
+ quit(1);
+ }
+
+ /* Allocate memory for the sprite info */
+ mem = (Uint8 *)malloc(4*sizeof(SDL_Rect)*numsprites);
+ if ( mem == NULL ) {
+ SDL_FreeSurface(sprite);
+ fprintf(stderr, "Out of memory!\n");
+ quit(2);
+ }
+ sprite_rects = (SDL_Rect *)mem;
+ positions = sprite_rects;
+ sprite_rects += numsprites;
+ velocities = sprite_rects;
+ sprite_rects += numsprites;
+ sprite_w = sprite->w;
+ sprite_h = sprite->h;
+ srand(time(NULL));
+ for ( i=0; i<numsprites; ++i ) {
+ positions[i].x = rand()%(screen->w - sprite_w);
+ positions[i].y = rand()%(screen->h - sprite_h);
+ positions[i].w = sprite->w;
+ positions[i].h = sprite->h;
+ velocities[i].x = 0;
+ velocities[i].y = 0;
+ while ( ! velocities[i].x && ! velocities[i].y ) {
+ velocities[i].x = (rand()%(MAX_SPEED*2+1))-MAX_SPEED;
+ velocities[i].y = (rand()%(MAX_SPEED*2+1))-MAX_SPEED;
+ }
+ }
+ background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
+
+ /* Print out information about our surfaces */
+ printf("Screen is at %d bits per pixel\n",screen->format->BitsPerPixel);
+ if ( (screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+ printf("Screen is in video memory\n");
+ } else {
+ printf("Screen is in system memory\n");
+ }
+ if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+ printf("Screen has double-buffering enabled\n");
+ }
+ if ( (sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+ printf("Sprite is in video memory\n");
+ } else {
+ printf("Sprite is in system memory\n");
+ }
+ /* Run a sample blit to trigger blit acceleration */
+ { SDL_Rect dst;
+ dst.x = 0;
+ dst.y = 0;
+ dst.w = sprite->w;
+ dst.h = sprite->h;
+ SDL_BlitSurface(sprite, NULL, screen, &dst);
+ SDL_FillRect(screen, &dst, background);
+ }
+ if ( (sprite->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
+ printf("Sprite blit uses hardware acceleration\n");
+ }
+ if ( (sprite->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+ printf("Sprite blit uses RLE acceleration\n");
+ }
+
+ /* Loop, blitting sprites and waiting for a keystroke */
+ frames = 0;
+ then = SDL_GetTicks();
+ done = 0;
+ sprites_visible = 0;
+ while ( !done ) {
+ /* Check for events */
+ ++frames;
+ while ( SDL_PollEvent(&event) ) {
+ switch (event.type) {
+ case SDL_MOUSEBUTTONDOWN:
+ SDL_WarpMouse(screen->w/2, screen->h/2);
+ break;
+ case SDL_KEYDOWN:
+ /* Any keypress quits the app... */
+ case SDL_QUIT:
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ MoveSprites(screen, background);
+ }
+ SDL_FreeSurface(sprite);
+ free(mem);
+
+ /* Print out some timing information */
+ now = SDL_GetTicks();
+ if ( now > then ) {
+ printf("%2.2f frames per second\n",
+ ((double)frames*1000)/(now-then));
+ }
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testtimer.c b/test/testtimer.c
new file mode 100644
index 0000000..95608c1
--- /dev/null
+++ b/test/testtimer.c
@@ -0,0 +1,87 @@
+
+/* Test program to check the resolution of the SDL timer on the current
+ platform
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "SDL.h"
+
+#define DEFAULT_RESOLUTION 1
+
+static int ticks = 0;
+
+static Uint32 SDLCALL ticktock(Uint32 interval)
+{
+ ++ticks;
+ return(interval);
+}
+
+static Uint32 SDLCALL callback(Uint32 interval, void *param)
+{
+ printf("Timer %d : param = %d\n", interval, (int)(uintptr_t)param);
+ return interval;
+}
+
+int main(int argc, char *argv[])
+{
+ int desired;
+ SDL_TimerID t1, t2, t3;
+
+ if ( SDL_Init(SDL_INIT_TIMER) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ return(1);
+ }
+
+ /* Start the timer */
+ desired = 0;
+ if ( argv[1] ) {
+ desired = atoi(argv[1]);
+ }
+ if ( desired == 0 ) {
+ desired = DEFAULT_RESOLUTION;
+ }
+ SDL_SetTimer(desired, ticktock);
+
+ /* Wait 10 seconds */
+ printf("Waiting 10 seconds\n");
+ SDL_Delay(10*1000);
+
+ /* Stop the timer */
+ SDL_SetTimer(0, NULL);
+
+ /* Print the results */
+ if ( ticks ) {
+ fprintf(stderr,
+ "Timer resolution: desired = %d ms, actual = %f ms\n",
+ desired, (double)(10*1000)/ticks);
+ }
+
+ /* Test multiple timers */
+ printf("Testing multiple timers...\n");
+ t1 = SDL_AddTimer(100, callback, (void*)1);
+ if(!t1)
+ fprintf(stderr,"Could not create timer 1: %s\n", SDL_GetError());
+ t2 = SDL_AddTimer(50, callback, (void*)2);
+ if(!t2)
+ fprintf(stderr,"Could not create timer 2: %s\n", SDL_GetError());
+ t3 = SDL_AddTimer(233, callback, (void*)3);
+ if(!t3)
+ fprintf(stderr,"Could not create timer 3: %s\n", SDL_GetError());
+
+ /* Wait 10 seconds */
+ printf("Waiting 10 seconds\n");
+ SDL_Delay(10*1000);
+
+ printf("Removing timer 1 and waiting 5 more seconds\n");
+ SDL_RemoveTimer(t1);
+
+ SDL_Delay(5*1000);
+
+ SDL_RemoveTimer(t2);
+ SDL_RemoveTimer(t3);
+
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testver.c b/test/testver.c
new file mode 100644
index 0000000..4f45ffe
--- /dev/null
+++ b/test/testver.c
@@ -0,0 +1,37 @@
+
+/* Test program to compare the compile-time version of SDL with the linked
+ version of SDL
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{
+ SDL_version compiled;
+
+ /* Initialize SDL */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ exit(1);
+ }
+#ifdef DEBUG
+ fprintf(stderr, "SDL initialized\n");
+#endif
+#if SDL_VERSION_ATLEAST(1, 2, 0)
+ printf("Compiled with SDL 1.2 or newer\n");
+#else
+ printf("Compiled with SDL older than 1.2\n");
+#endif
+ SDL_VERSION(&compiled);
+ printf("Compiled version: %d.%d.%d\n",
+ compiled.major, compiled.minor, compiled.patch);
+ printf("Linked version: %d.%d.%d\n",
+ SDL_Linked_Version()->major,
+ SDL_Linked_Version()->minor,
+ SDL_Linked_Version()->patch);
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testvidinfo.c b/test/testvidinfo.c
new file mode 100644
index 0000000..bbafeb8
--- /dev/null
+++ b/test/testvidinfo.c
@@ -0,0 +1,465 @@
+
+/* Simple program -- figure out what kind of video display we have */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+#define NUM_BLITS 10
+#define NUM_UPDATES 500
+
+#define FLAG_MASK (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF | \
+ SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCEL | \
+ SDL_RLEACCELOK)
+
+void PrintFlags(Uint32 flags)
+{
+ printf("0x%8.8x", (flags & FLAG_MASK));
+ if ( flags & SDL_HWSURFACE ) {
+ printf(" SDL_HWSURFACE");
+ } else {
+ printf(" SDL_SWSURFACE");
+ }
+ if ( flags & SDL_FULLSCREEN ) {
+ printf(" | SDL_FULLSCREEN");
+ }
+ if ( flags & SDL_DOUBLEBUF ) {
+ printf(" | SDL_DOUBLEBUF");
+ }
+ if ( flags & SDL_SRCCOLORKEY ) {
+ printf(" | SDL_SRCCOLORKEY");
+ }
+ if ( flags & SDL_SRCALPHA ) {
+ printf(" | SDL_SRCALPHA");
+ }
+ if ( flags & SDL_RLEACCEL ) {
+ printf(" | SDL_RLEACCEL");
+ }
+ if ( flags & SDL_RLEACCELOK ) {
+ printf(" | SDL_RLEACCELOK");
+ }
+}
+
+int RunBlitTests(SDL_Surface *screen, SDL_Surface *bmp, int blitcount)
+{
+ int i, j;
+ int maxx;
+ int maxy;
+ SDL_Rect dst;
+
+ maxx = (int)screen->w - bmp->w + 1;
+ maxy = (int)screen->h - bmp->h + 1;
+ for ( i = 0; i < NUM_UPDATES; ++i ) {
+ for ( j = 0; j < blitcount; ++j ) {
+ if ( maxx ) {
+ dst.x = rand() % maxx;
+ } else {
+ dst.x = 0;
+ }
+ if ( maxy ) {
+ dst.y = rand() % maxy;
+ } else {
+ dst.y = 0;
+ }
+ dst.w = bmp->w;
+ dst.h = bmp->h;
+ SDL_BlitSurface(bmp, NULL, screen, &dst);
+ }
+ SDL_Flip(screen);
+ }
+
+ return i;
+}
+
+int RunModeTests(SDL_Surface *screen)
+{
+ Uint32 then, now;
+ Uint32 frames;
+ float seconds;
+ int i;
+ Uint8 r, g, b;
+ SDL_Surface *bmp, *bmpcc, *tmp;
+ SDL_Event event;
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+
+ /* First test fills and screen update speed */
+ printf("Running color fill and fullscreen update test\n");
+ then = SDL_GetTicks();
+ frames = 0;
+ for ( i = 0; i < 256; ++i ) {
+ r = i;
+ g = 0;
+ b = 0;
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
+ SDL_Flip(screen);
+ ++frames;
+ }
+ for ( i = 0; i < 256; ++i ) {
+ r = 0;
+ g = i;
+ b = 0;
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
+ SDL_Flip(screen);
+ ++frames;
+ }
+ for ( i = 0; i < 256; ++i ) {
+ r = 0;
+ g = 0;
+ b = i;
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
+ SDL_Flip(screen);
+ ++frames;
+ }
+ now = SDL_GetTicks();
+ seconds = (float)(now - then) / 1000.0f;
+ if ( seconds > 0.0f ) {
+ printf("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames, seconds, (float)frames / seconds);
+ } else {
+ printf("%d fills and flips in zero seconds!n", frames);
+ }
+
+ /* clear the screen after fill test */
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_Flip(screen);
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+
+ /* run the generic blit test */
+ bmp = SDL_LoadBMP("sample.bmp");
+ if ( ! bmp ) {
+ printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
+ return 0;
+ }
+ printf("Running freshly loaded blit test: %dx%d at %d bpp, flags: ",
+ bmp->w, bmp->h, bmp->format->BitsPerPixel);
+ PrintFlags(bmp->flags);
+ printf("\n");
+ then = SDL_GetTicks();
+ frames = RunBlitTests(screen, bmp, NUM_BLITS);
+ now = SDL_GetTicks();
+ seconds = (float)(now - then) / 1000.0f;
+ if ( seconds > 0.0f ) {
+ printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
+ } else {
+ printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
+ }
+
+ /* clear the screen after blit test */
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_Flip(screen);
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+
+ /* run the colorkeyed blit test */
+ bmpcc = SDL_LoadBMP("sample.bmp");
+ if ( ! bmpcc ) {
+ printf("Couldn't load sample.bmp: %s\n", SDL_GetError());
+ return 0;
+ }
+ printf("Running freshly loaded cc blit test: %dx%d at %d bpp, flags: ",
+ bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
+ SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels);
+
+ PrintFlags(bmpcc->flags);
+ printf("\n");
+ then = SDL_GetTicks();
+ frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
+ now = SDL_GetTicks();
+ seconds = (float)(now - then) / 1000.0f;
+ if ( seconds > 0.0f ) {
+ printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
+ } else {
+ printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
+ }
+
+ /* clear the screen after cc blit test */
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_Flip(screen);
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+
+ /* run the generic blit test */
+ tmp = bmp;
+ bmp = SDL_DisplayFormat(bmp);
+ SDL_FreeSurface(tmp);
+ if ( ! bmp ) {
+ printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
+ return 0;
+ }
+ printf("Running display format blit test: %dx%d at %d bpp, flags: ",
+ bmp->w, bmp->h, bmp->format->BitsPerPixel);
+ PrintFlags(bmp->flags);
+ printf("\n");
+ then = SDL_GetTicks();
+ frames = RunBlitTests(screen, bmp, NUM_BLITS);
+ now = SDL_GetTicks();
+ seconds = (float)(now - then) / 1000.0f;
+ if ( seconds > 0.0f ) {
+ printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
+ } else {
+ printf("%d blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
+ }
+
+ /* clear the screen after blit test */
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_Flip(screen);
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+
+ /* run the colorkeyed blit test */
+ tmp = bmpcc;
+ bmpcc = SDL_DisplayFormat(bmpcc);
+ SDL_FreeSurface(tmp);
+ if ( ! bmpcc ) {
+ printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
+ return 0;
+ }
+ printf("Running display format cc blit test: %dx%d at %d bpp, flags: ",
+ bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
+ PrintFlags(bmpcc->flags);
+ printf("\n");
+ then = SDL_GetTicks();
+ frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
+ now = SDL_GetTicks();
+ seconds = (float)(now - then) / 1000.0f;
+ if ( seconds > 0.0f ) {
+ printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
+ } else {
+ printf("%d cc blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
+ }
+
+ /* clear the screen after cc blit test */
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_Flip(screen);
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+
+ /* run the alpha blit test only if screen bpp>8 */
+ if (bmp->format->BitsPerPixel>8)
+ {
+ SDL_FreeSurface(bmp);
+ bmp = SDL_LoadBMP("sample.bmp");
+ SDL_SetAlpha(bmp, SDL_SRCALPHA, 85); /* 85 - 33% alpha */
+ tmp = bmp;
+ bmp = SDL_DisplayFormat(bmp);
+ SDL_FreeSurface(tmp);
+ if ( ! bmp ) {
+ printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
+ return 0;
+ }
+ printf("Running display format alpha blit test: %dx%d at %d bpp, flags: ",
+ bmp->w, bmp->h, bmp->format->BitsPerPixel);
+ PrintFlags(bmp->flags);
+ printf("\n");
+ then = SDL_GetTicks();
+ frames = RunBlitTests(screen, bmp, NUM_BLITS);
+ now = SDL_GetTicks();
+ seconds = (float)(now - then) / 1000.0f;
+ if ( seconds > 0.0f ) {
+ printf("%d alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
+ } else {
+ printf("%d alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
+ }
+ }
+
+ /* clear the screen after alpha blit test */
+ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_Flip(screen);
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+
+ /* run the cc+alpha blit test only if screen bpp>8 */
+ if (bmp->format->BitsPerPixel>8)
+ {
+ SDL_FreeSurface(bmpcc);
+ bmpcc = SDL_LoadBMP("sample.bmp");
+ SDL_SetAlpha(bmpcc, SDL_SRCALPHA, 85); /* 85 - 33% alpha */
+ SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, *(Uint8 *)bmpcc->pixels);
+ tmp = bmpcc;
+ bmpcc = SDL_DisplayFormat(bmpcc);
+ SDL_FreeSurface(tmp);
+ if ( ! bmpcc ) {
+ printf("Couldn't convert sample.bmp: %s\n", SDL_GetError());
+ return 0;
+ }
+ printf("Running display format cc+alpha blit test: %dx%d at %d bpp, flags: ",
+ bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel);
+ PrintFlags(bmpcc->flags);
+ printf("\n");
+ then = SDL_GetTicks();
+ frames = RunBlitTests(screen, bmpcc, NUM_BLITS);
+ now = SDL_GetTicks();
+ seconds = (float)(now - then) / 1000.0f;
+ if ( seconds > 0.0f ) {
+ printf("%d cc+alpha blits / %d updates in %2.2f seconds, %2.2f FPS\n", NUM_BLITS*frames, frames, seconds, (float)frames / seconds);
+ } else {
+ printf("%d cc+alpha blits / %d updates in zero seconds!\n", NUM_BLITS*frames, frames);
+ }
+ }
+
+ SDL_FreeSurface(bmpcc);
+ SDL_FreeSurface(bmp);
+
+ while ( SDL_PollEvent(&event) ) {
+ if ( event.type == SDL_KEYDOWN )
+ return 0;
+ }
+ return 1;
+}
+
+void RunVideoTests()
+{
+ static const struct {
+ int w, h, bpp;
+ } mode_list[] = {
+ { 640, 480, 8 }, { 640, 480, 16 }, { 640, 480, 32 },
+ { 800, 600, 8 }, { 800, 600, 16 }, { 800, 600, 32 },
+ { 1024, 768, 8 }, { 1024, 768, 16 }, { 1024, 768, 32 }
+ };
+ static const Uint32 flags[] = {
+ (SDL_SWSURFACE),
+ (SDL_SWSURFACE | SDL_FULLSCREEN),
+ (SDL_HWSURFACE | SDL_FULLSCREEN),
+ (SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF)
+ };
+ int i, j;
+ SDL_Surface *screen;
+
+ /* Test out several different video mode combinations */
+ SDL_WM_SetCaption("SDL Video Benchmark", "vidtest");
+ SDL_ShowCursor(0);
+ for ( i = 0; i < SDL_TABLESIZE(mode_list); ++i ) {
+ for ( j = 0; j < SDL_TABLESIZE(flags); ++j ) {
+ printf("===================================\n");
+ printf("Setting video mode: %dx%d at %d bpp, flags: ",
+ mode_list[i].w,
+ mode_list[i].h,
+ mode_list[i].bpp);
+ PrintFlags(flags[j]);
+ printf("\n");
+ screen = SDL_SetVideoMode(mode_list[i].w,
+ mode_list[i].h,
+ mode_list[i].bpp,
+ flags[j]);
+ if ( ! screen ) {
+ printf("Setting video mode failed: %s\n", SDL_GetError());
+ continue;
+ }
+ if ( (screen->flags & FLAG_MASK) != flags[j] ) {
+ printf("Flags didn't match: ");
+ PrintFlags(screen->flags);
+ printf("\n");
+ continue;
+ }
+ if ( ! RunModeTests(screen) ) {
+ return;
+ }
+ }
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ const SDL_VideoInfo *info;
+ int i;
+ SDL_Rect **modes;
+ char driver[128];
+
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr,
+ "Couldn't initialize SDL: %s\n", SDL_GetError());
+ exit(1);
+ }
+ if ( SDL_VideoDriverName(driver, sizeof(driver)) ) {
+ printf("Video driver: %s\n", driver);
+ }
+ info = SDL_GetVideoInfo();
+ printf(
+"Current display: %dx%d, %d bits-per-pixel\n",
+ info->current_w, info->current_h, info->vfmt->BitsPerPixel);
+ if ( info->vfmt->palette == NULL ) {
+ printf(" Red Mask = 0x%.8x\n", info->vfmt->Rmask);
+ printf(" Green Mask = 0x%.8x\n", info->vfmt->Gmask);
+ printf(" Blue Mask = 0x%.8x\n", info->vfmt->Bmask);
+ }
+ /* Print available fullscreen video modes */
+ modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
+ if ( modes == (SDL_Rect **)0 ) {
+ printf("No available fullscreen video modes\n");
+ } else
+ if ( modes == (SDL_Rect **)-1 ) {
+ printf("No special fullscreen video modes\n");
+ } else {
+ printf("Fullscreen video modes:\n");
+ for ( i=0; modes[i]; ++i ) {
+ printf("\t%dx%dx%d\n", modes[i]->w, modes[i]->h, info->vfmt->BitsPerPixel);
+ }
+ }
+ if ( info->wm_available ) {
+ printf("A window manager is available\n");
+ }
+ if ( info->hw_available ) {
+ printf("Hardware surfaces are available (%dK video memory)\n",
+ info->video_mem);
+ }
+ if ( info->blit_hw ) {
+ printf(
+"Copy blits between hardware surfaces are accelerated\n");
+ }
+ if ( info->blit_hw_CC ) {
+ printf(
+"Colorkey blits between hardware surfaces are accelerated\n");
+ }
+ if ( info->blit_hw_A ) {
+ printf(
+"Alpha blits between hardware surfaces are accelerated\n");
+ }
+ if ( info->blit_sw ) {
+ printf(
+"Copy blits from software surfaces to hardware surfaces are accelerated\n");
+ }
+ if ( info->blit_sw_CC ) {
+ printf(
+"Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
+ }
+ if ( info->blit_sw_A ) {
+ printf(
+"Alpha blits from software surfaces to hardware surfaces are accelerated\n");
+ }
+ if ( info->blit_fill ) {
+ printf(
+"Color fills on hardware surfaces are accelerated\n");
+ }
+
+ if ( argv[1] && (strcmp(argv[1], "-benchmark") == 0) ) {
+ RunVideoTests();
+ }
+
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testwin.c b/test/testwin.c
new file mode 100644
index 0000000..261ea99
--- /dev/null
+++ b/test/testwin.c
@@ -0,0 +1,377 @@
+
+/* Bring up a window and play with it */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define BENCHMARK_SDL
+
+#define NOTICE(X) printf("%s", X);
+
+#include "SDL.h"
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+void DrawPict(SDL_Surface *screen, char *bmpfile,
+ int speedy, int flip, int nofade)
+{
+ SDL_Surface *picture;
+ SDL_Rect dest, update;
+ int i, centered;
+ int ncolors;
+ SDL_Color *colors, *cmap;
+
+ /* Load the image into a surface */
+ if ( bmpfile == NULL ) {
+ bmpfile = "sample.bmp"; /* Sample image */
+ }
+fprintf(stderr, "Loading picture: %s\n", bmpfile);
+ picture = SDL_LoadBMP(bmpfile);
+ if ( picture == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s\n", bmpfile,
+ SDL_GetError());
+ return;
+ }
+
+ /* Set the display colors -- on a hicolor display this is a no-op */
+ if ( picture->format->palette ) {
+ ncolors = picture->format->palette->ncolors;
+ colors = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+ cmap = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+ memcpy(colors, picture->format->palette->colors,
+ ncolors*sizeof(SDL_Color));
+ } else {
+ int r, g, b;
+
+ /* Allocate 256 color palette */
+ ncolors = 256;
+ colors = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+ cmap = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+
+ /* Set a 3,3,2 color cube */
+ for ( r=0; r<8; ++r ) {
+ for ( g=0; g<8; ++g ) {
+ for ( b=0; b<4; ++b ) {
+ i = ((r<<5)|(g<<2)|b);
+ colors[i].r = r<<5;
+ colors[i].g = g<<5;
+ colors[i].b = b<<6;
+ }
+ }
+ }
+ }
+NOTICE("testwin: setting colors\n");
+ if ( ! SDL_SetColors(screen, colors, 0, ncolors) &&
+ (screen->format->palette != NULL) ) {
+ fprintf(stderr,
+"Warning: Couldn't set all of the colors, but SDL will map the image\n"
+" (colormap fading will suffer - try the -warp option)\n"
+ );
+ }
+
+ /* Set the screen to black (not really necessary) */
+ if ( SDL_LockSurface(screen) == 0 ) {
+ Uint32 black;
+ Uint8 *pixels;
+
+ black = SDL_MapRGB(screen->format, 0, 0, 0);
+ pixels = (Uint8 *)screen->pixels;
+ for ( i=0; i<screen->h; ++i ) {
+ memset(pixels, black,
+ screen->w*screen->format->BytesPerPixel);
+ pixels += screen->pitch;
+ }
+ SDL_UnlockSurface(screen);
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+ }
+
+ /* Display the picture */
+ if ( speedy ) {
+ SDL_Surface *displayfmt;
+
+fprintf(stderr, "Converting picture\n");
+ displayfmt = SDL_DisplayFormat(picture);
+ if ( displayfmt == NULL ) {
+ fprintf(stderr,
+ "Couldn't convert image: %s\n", SDL_GetError());
+ goto done;
+ }
+ SDL_FreeSurface(picture);
+ picture = displayfmt;
+ }
+ printf("(image surface located in %s memory)\n",
+ (picture->flags&SDL_HWSURFACE) ? "video" : "system");
+ centered = (screen->w - picture->w)/2;
+ if ( centered < 0 ) {
+ centered = 0;
+ }
+ dest.y = (screen->h - picture->h)/2;
+ dest.w = picture->w;
+ dest.h = picture->h;
+NOTICE("testwin: moving image\n");
+ for ( i=0; i<=centered; ++i ) {
+ dest.x = i;
+ update = dest;
+ if ( SDL_BlitSurface(picture, NULL, screen, &update) < 0 ) {
+ fprintf(stderr, "Blit failed: %s\n", SDL_GetError());
+ break;
+ }
+ if ( flip ) {
+ SDL_Flip(screen);
+ } else {
+ SDL_UpdateRects(screen, 1, &update);
+ }
+ }
+
+#ifdef SCREENSHOT
+ if ( SDL_SaveBMP(screen, "screen.bmp") < 0 )
+ printf("Couldn't save screen: %s\n", SDL_GetError());
+#endif
+
+#ifndef BENCHMARK_SDL
+ /* Let it sit there for a while */
+ SDL_Delay(5*1000);
+#endif
+ /* Fade the colormap */
+ if ( ! nofade ) {
+ int maxstep;
+ SDL_Color final;
+ SDL_Color palcolors[256];
+ struct {
+ Sint16 r, g, b;
+ } cdist[256];
+
+NOTICE("testwin: fading out...\n");
+ memcpy(cmap, colors, ncolors*sizeof(SDL_Color));
+ maxstep = 32-1;
+ final.r = 0xFF;
+ final.g = 0x00;
+ final.b = 0x00;
+ memcpy(palcolors, colors, ncolors*sizeof(SDL_Color));
+ for ( i=0; i<ncolors; ++i ) {
+ cdist[i].r = final.r-palcolors[i].r;
+ cdist[i].g = final.g-palcolors[i].g;
+ cdist[i].b = final.b-palcolors[i].b;
+ }
+ for ( i=0; i<=maxstep/2; ++i ) { /* halfway fade */
+ int c;
+ for ( c=0; c<ncolors; ++c ) {
+ colors[c].r =
+ palcolors[c].r+((cdist[c].r*i))/maxstep;
+ colors[c].g =
+ palcolors[c].g+((cdist[c].g*i))/maxstep;
+ colors[c].b =
+ palcolors[c].b+((cdist[c].b*i))/maxstep;
+ }
+ SDL_SetColors(screen, colors, 0, ncolors);
+ SDL_Delay(1);
+ }
+ final.r = 0x00;
+ final.g = 0x00;
+ final.b = 0x00;
+ memcpy(palcolors, colors, ncolors*sizeof(SDL_Color));
+ for ( i=0; i<ncolors; ++i ) {
+ cdist[i].r = final.r-palcolors[i].r;
+ cdist[i].g = final.g-palcolors[i].g;
+ cdist[i].b = final.b-palcolors[i].b;
+ }
+ maxstep /= 2;
+ for ( i=0; i<=maxstep; ++i ) { /* finish fade out */
+ int c;
+ for ( c=0; c<ncolors; ++c ) {
+ colors[c].r =
+ palcolors[c].r+((cdist[c].r*i))/maxstep;
+ colors[c].g =
+ palcolors[c].g+((cdist[c].g*i))/maxstep;
+ colors[c].b =
+ palcolors[c].b+((cdist[c].b*i))/maxstep;
+ }
+ SDL_SetColors(screen, colors, 0, ncolors);
+ SDL_Delay(1);
+ }
+ for ( i=0; i<ncolors; ++i ) {
+ colors[i].r = final.r;
+ colors[i].g = final.g;
+ colors[i].b = final.b;
+ }
+ SDL_SetColors(screen, colors, 0, ncolors);
+NOTICE("testwin: fading in...\n");
+ memcpy(palcolors, colors, ncolors*sizeof(SDL_Color));
+ for ( i=0; i<ncolors; ++i ) {
+ cdist[i].r = cmap[i].r-palcolors[i].r;
+ cdist[i].g = cmap[i].g-palcolors[i].g;
+ cdist[i].b = cmap[i].b-palcolors[i].b;
+ }
+ for ( i=0; i<=maxstep; ++i ) { /* 32 step fade in */
+ int c;
+ for ( c=0; c<ncolors; ++c ) {
+ colors[c].r =
+ palcolors[c].r+((cdist[c].r*i))/maxstep;
+ colors[c].g =
+ palcolors[c].g+((cdist[c].g*i))/maxstep;
+ colors[c].b =
+ palcolors[c].b+((cdist[c].b*i))/maxstep;
+ }
+ SDL_SetColors(screen, colors, 0, ncolors);
+ SDL_Delay(1);
+ }
+NOTICE("testwin: fading over\n");
+ }
+
+done:
+ /* Free the picture and return */
+ SDL_FreeSurface(picture);
+ free(colors); free(cmap);
+ return;
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+ /* Options */
+ int speedy, flip, nofade;
+ int delay;
+ int w, h;
+ int desired_bpp;
+ Uint32 video_flags;
+#ifdef BENCHMARK_SDL
+ Uint32 then, now;
+#endif
+ /* Set default options and check command-line */
+ speedy = 0;
+ flip = 0;
+ nofade = 0;
+ delay = 1;
+
+#ifdef _WIN32_WCE
+ w = 240;
+ h = 320;
+ desired_bpp = 8;
+ video_flags = SDL_FULLSCREEN;
+#else
+ w = 640;
+ h = 480;
+ desired_bpp = 0;
+ video_flags = 0;
+#endif
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr,
+ "Couldn't initialize SDL: %s\n", SDL_GetError());
+ return(1);
+ }
+
+ while ( argc > 1 ) {
+ if ( strcmp(argv[1], "-speedy") == 0 ) {
+ speedy = 1;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-nofade") == 0 ) {
+ nofade = 1;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-delay") == 0 ) {
+ if ( argv[2] ) {
+ delay = atoi(argv[2]);
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -delay option requires an argument\n");
+ quit(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-width") == 0 ) {
+ if ( argv[2] && ((w = atoi(argv[2])) > 0) ) {
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -width option requires an argument\n");
+ quit(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-height") == 0 ) {
+ if ( argv[2] && ((h = atoi(argv[2])) > 0) ) {
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -height option requires an argument\n");
+ quit(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-bpp") == 0 ) {
+ if ( argv[2] ) {
+ desired_bpp = atoi(argv[2]);
+ argv += 2;
+ argc -= 2;
+ } else {
+ fprintf(stderr,
+ "The -bpp option requires an argument\n");
+ quit(1);
+ }
+ } else
+ if ( strcmp(argv[1], "-warp") == 0 ) {
+ video_flags |= SDL_HWPALETTE;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-hw") == 0 ) {
+ video_flags |= SDL_HWSURFACE;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-flip") == 0 ) {
+ video_flags |= SDL_DOUBLEBUF;
+ argv += 1;
+ argc -= 1;
+ } else
+ if ( strcmp(argv[1], "-fullscreen") == 0 ) {
+ video_flags |= SDL_FULLSCREEN;
+ argv += 1;
+ argc -= 1;
+ } else
+ break;
+ }
+
+ /* Initialize the display */
+ screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
+ if ( screen == NULL ) {
+ fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
+ w, h, desired_bpp, SDL_GetError());
+ quit(1);
+ }
+ printf("Set%s %dx%dx%d mode\n",
+ screen->flags & SDL_FULLSCREEN ? " fullscreen" : "",
+ screen->w, screen->h, screen->format->BitsPerPixel);
+ printf("(video surface located in %s memory)\n",
+ (screen->flags&SDL_HWSURFACE) ? "video" : "system");
+ if ( screen->flags & SDL_DOUBLEBUF ) {
+ printf("Double-buffering enabled\n");
+ flip = 1;
+ }
+
+ /* Set the window manager title bar */
+ SDL_WM_SetCaption("SDL test window", "testwin");
+
+ /* Do all the drawing work */
+#ifdef BENCHMARK_SDL
+ then = SDL_GetTicks();
+ DrawPict(screen, argv[1], speedy, flip, nofade);
+ now = SDL_GetTicks();
+ printf("Time: %d milliseconds\n", now-then);
+#else
+ DrawPict(screen, argv[1], speedy, flip, nofade);
+#endif
+ SDL_Delay(delay*1000);
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/testwm.c b/test/testwm.c
new file mode 100644
index 0000000..9c3c050
--- /dev/null
+++ b/test/testwm.c
@@ -0,0 +1,443 @@
+
+/* Test out the window manager interaction functions */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+/* Is the cursor visible? */
+static int visible = 1;
+
+static Uint8 video_bpp;
+static Uint32 video_flags;
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+int SetVideoMode(int w, int h)
+{
+ SDL_Surface *screen;
+ int i;
+ Uint8 *buffer;
+ SDL_Color palette[256];
+
+ screen = SDL_SetVideoMode(w, h, video_bpp, video_flags);
+ if ( screen == NULL ) {
+ fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
+ w, h, video_bpp, SDL_GetError());
+ return(-1);
+ }
+ printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
+ "fullscreen" : "windowed");
+
+ /* Set the surface pixels and refresh! */
+ for ( i=0; i<256; ++i ) {
+ palette[i].r = 255-i;
+ palette[i].g = 255-i;
+ palette[i].b = 255-i;
+ }
+ SDL_SetColors(screen, palette, 0, 256);
+ if ( SDL_LockSurface(screen) < 0 ) {
+ fprintf(stderr, "Couldn't lock display surface: %s\n",
+ SDL_GetError());
+ return(-1);
+ }
+ buffer = (Uint8 *)screen->pixels;
+ for ( i=0; i<screen->h; ++i ) {
+ memset(buffer,(i*255)/screen->h,
+ screen->w*screen->format->BytesPerPixel);
+ buffer += screen->pitch;
+ }
+ SDL_UnlockSurface(screen);
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+ return(0);
+}
+
+SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
+{
+ SDL_Surface *icon;
+ Uint8 *pixels;
+ Uint8 *mask;
+ int mlen, i, j;
+
+ *maskp = NULL;
+
+ /* Load the icon surface */
+ icon = SDL_LoadBMP(file);
+ if ( icon == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+ return(NULL);
+ }
+
+ /* Check width and height
+ if ( (icon->w%8) != 0 ) {
+ fprintf(stderr, "Icon width must be a multiple of 8!\n");
+ SDL_FreeSurface(icon);
+ return(NULL);
+ }
+*/
+
+
+ if ( icon->format->palette == NULL ) {
+ fprintf(stderr, "Icon must have a palette!\n");
+ SDL_FreeSurface(icon);
+ return(NULL);
+ }
+
+ /* Set the colorkey */
+ SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *)icon->pixels));
+
+ /* Create the mask */
+ pixels = (Uint8 *)icon->pixels;
+ printf("Transparent pixel: (%d,%d,%d)\n",
+ icon->format->palette->colors[*pixels].r,
+ icon->format->palette->colors[*pixels].g,
+ icon->format->palette->colors[*pixels].b);
+ mlen = (icon->w*icon->h + 7) / 8;
+ mask = (Uint8 *)malloc(mlen);
+ if ( mask == NULL ) {
+ fprintf(stderr, "Out of memory!\n");
+ SDL_FreeSurface(icon);
+ return(NULL);
+ }
+ memset(mask, 0, mlen);
+ for ( i=0; i < icon->h; i++)
+ for (j=0; j < icon->w; j++) {
+ int pindex = i * icon->pitch + j;
+ int mindex = i * icon->w + j;
+ if ( pixels[pindex] != *pixels )
+ mask[mindex>>3] |= 1 << (7 - (mindex & 7));
+ }
+ *maskp = mask;
+ return(icon);
+}
+
+void HotKey_ToggleFullScreen(void)
+{
+ SDL_Surface *screen;
+
+ screen = SDL_GetVideoSurface();
+ if ( SDL_WM_ToggleFullScreen(screen) ) {
+ printf("Toggled fullscreen mode - now %s\n",
+ (screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed");
+ } else {
+ printf("Unable to toggle fullscreen mode\n");
+ video_flags ^= SDL_FULLSCREEN;
+ SetVideoMode(screen->w, screen->h);
+ }
+}
+
+void HotKey_ToggleGrab(void)
+{
+ SDL_GrabMode mode;
+
+ printf("Ctrl-G: toggling input grab!\n");
+ mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
+ if ( mode == SDL_GRAB_ON ) {
+ printf("Grab was on\n");
+ } else {
+ printf("Grab was off\n");
+ }
+ mode = SDL_WM_GrabInput(mode ? SDL_GRAB_OFF : SDL_GRAB_ON);
+ if ( mode == SDL_GRAB_ON ) {
+ printf("Grab is now on\n");
+ } else {
+ printf("Grab is now off\n");
+ }
+}
+
+void HotKey_Iconify(void)
+{
+ printf("Ctrl-Z: iconifying window!\n");
+ SDL_WM_IconifyWindow();
+}
+
+void HotKey_Quit(void)
+{
+ SDL_Event event;
+
+ printf("Posting internal quit request\n");
+ event.type = SDL_USEREVENT;
+ SDL_PushEvent(&event);
+}
+
+static void print_modifiers(void)
+{
+ int mod;
+ printf(" modifiers:");
+ mod = SDL_GetModState();
+ if(!mod) {
+ printf(" (none)");
+ return;
+ }
+ if(mod & KMOD_LSHIFT)
+ printf(" LSHIFT");
+ if(mod & KMOD_RSHIFT)
+ printf(" RSHIFT");
+ if(mod & KMOD_LCTRL)
+ printf(" LCTRL");
+ if(mod & KMOD_RCTRL)
+ printf(" RCTRL");
+ if(mod & KMOD_LALT)
+ printf(" LALT");
+ if(mod & KMOD_RALT)
+ printf(" RALT");
+ if(mod & KMOD_LMETA)
+ printf(" LMETA");
+ if(mod & KMOD_RMETA)
+ printf(" RMETA");
+ if(mod & KMOD_NUM)
+ printf(" NUM");
+ if(mod & KMOD_CAPS)
+ printf(" CAPS");
+ if(mod & KMOD_MODE)
+ printf(" MODE");
+}
+
+static void PrintKey(const SDL_keysym *sym, int pressed)
+{
+ /* Print the keycode, name and state */
+ if ( sym->sym ) {
+ printf("Key %s: %d-%s ", pressed ? "pressed" : "released",
+ sym->sym, SDL_GetKeyName(sym->sym));
+ } else {
+ printf("Unknown Key (scancode = %d) %s ", sym->scancode,
+ pressed ? "pressed" : "released");
+ }
+
+ /* Print the translated character, if one exists */
+ if ( sym->unicode ) {
+ /* Is it a control-character? */
+ if ( sym->unicode < ' ' ) {
+ printf(" (^%c)", sym->unicode+'@');
+ } else {
+#ifdef UNICODE
+ printf(" (%c)", sym->unicode);
+#else
+ /* This is a Latin-1 program, so only show 8-bits */
+ if ( !(sym->unicode & 0xFF00) )
+ printf(" (%c)", sym->unicode);
+ else
+ printf(" (0x%X)", sym->unicode);
+#endif
+ }
+ }
+ print_modifiers();
+ printf("\n");
+}
+
+int SDLCALL FilterEvents(const SDL_Event *event)
+{
+ static int reallyquit = 0;
+
+ switch (event->type) {
+
+ case SDL_ACTIVEEVENT:
+ /* See what happened */
+ printf("App %s ",
+ event->active.gain ? "gained" : "lost");
+ if ( event->active.state & SDL_APPACTIVE )
+ printf("active ");
+ if ( event->active.state & SDL_APPINPUTFOCUS )
+ printf("input ");
+ if ( event->active.state & SDL_APPMOUSEFOCUS )
+ printf("mouse ");
+ printf("focus\n");
+
+ /* See if we are iconified or restored */
+ if ( event->active.state & SDL_APPACTIVE ) {
+ printf("App has been %s\n",
+ event->active.gain ?
+ "restored" : "iconified");
+ }
+ return(0);
+
+ /* We want to toggle visibility on buttonpress */
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ if ( event->button.state == SDL_PRESSED ) {
+ visible = !visible;
+ SDL_ShowCursor(visible);
+ }
+ printf("Mouse button %d has been %s\n",
+ event->button.button,
+ (event->button.state == SDL_PRESSED) ?
+ "pressed" : "released");
+ return(0);
+
+ /* Show relative mouse motion */
+ case SDL_MOUSEMOTION:
+#if 0
+ printf("Mouse motion: {%d,%d} (%d,%d)\n",
+ event->motion.x, event->motion.y,
+ event->motion.xrel, event->motion.yrel);
+#endif
+ return(0);
+
+ case SDL_KEYDOWN:
+ PrintKey(&event->key.keysym, 1);
+ if ( event->key.keysym.sym == SDLK_ESCAPE ) {
+ HotKey_Quit();
+ }
+ if ( (event->key.keysym.sym == SDLK_g) &&
+ (event->key.keysym.mod & KMOD_CTRL) ) {
+ HotKey_ToggleGrab();
+ }
+ if ( (event->key.keysym.sym == SDLK_z) &&
+ (event->key.keysym.mod & KMOD_CTRL) ) {
+ HotKey_Iconify();
+ }
+ if ( (event->key.keysym.sym == SDLK_RETURN) &&
+ (event->key.keysym.mod & KMOD_ALT) ) {
+ HotKey_ToggleFullScreen();
+ }
+ return(0);
+
+ case SDL_KEYUP:
+ PrintKey(&event->key.keysym, 0);
+ return(0);
+
+ /* Pass the video resize event through .. */
+ case SDL_VIDEORESIZE:
+ return(1);
+
+ /* This is important! Queue it if we want to quit. */
+ case SDL_QUIT:
+ if ( ! reallyquit ) {
+ reallyquit = 1;
+ printf("Quit requested\n");
+ return(0);
+ }
+ printf("Quit demanded\n");
+ return(1);
+
+ /* This will never happen because events queued directly
+ to the event queue are not filtered.
+ */
+ case SDL_USEREVENT:
+ return(1);
+
+ /* Drop all other events */
+ default:
+ return(0);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Event event;
+ char *title;
+ SDL_Surface *icon;
+ Uint8 *icon_mask;
+ int parsed;
+ int w, h;
+
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+ fprintf(stderr,
+ "Couldn't initialize SDL: %s\n", SDL_GetError());
+ return(1);
+ }
+
+ /* Check command line arguments */
+ w = 640;
+ h = 480;
+ video_bpp = 8;
+ video_flags = SDL_SWSURFACE;
+ parsed = 1;
+ while ( parsed ) {
+ if ( (argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0) ) {
+ video_flags |= SDL_FULLSCREEN;
+ argc -= 1;
+ argv += 1;
+ } else
+ if ( (argc >= 2) && (strcmp(argv[1], "-resize") == 0) ) {
+ video_flags |= SDL_RESIZABLE;
+ argc -= 1;
+ argv += 1;
+ } else
+ if ( (argc >= 2) && (strcmp(argv[1], "-noframe") == 0) ) {
+ video_flags |= SDL_NOFRAME;
+ argc -= 1;
+ argv += 1;
+ } else
+ if ( (argc >= 3) && (strcmp(argv[1], "-width") == 0) ) {
+ w = atoi(argv[2]);
+ argc -= 2;
+ argv += 2;
+ } else
+ if ( (argc >= 3) && (strcmp(argv[1], "-height") == 0) ) {
+ h = atoi(argv[2]);
+ argc -= 2;
+ argv += 2;
+ } else
+ if ( (argc >= 3) && (strcmp(argv[1], "-bpp") == 0) ) {
+ video_bpp = atoi(argv[2]);
+ argc -= 2;
+ argv += 2;
+ } else {
+ parsed = 0;
+ }
+ }
+
+ /* Set the icon -- this must be done before the first mode set */
+ icon = LoadIconSurface("icon.bmp", &icon_mask);
+ if ( icon != NULL ) {
+ SDL_WM_SetIcon(icon, icon_mask);
+ }
+ if ( icon_mask != NULL )
+ free(icon_mask);
+
+ /* Set the title bar */
+ if ( argv[1] == NULL )
+ title = "Testing 1.. 2.. 3...";
+ else
+ title = argv[1];
+ SDL_WM_SetCaption(title, "testwm");
+
+ /* See if it's really set */
+ SDL_WM_GetCaption(&title, NULL);
+ if ( title )
+ printf("Title was set to: %s\n", title);
+ else
+ printf("No window title was set!\n");
+
+ /* Initialize the display */
+ if ( SetVideoMode(w, h) < 0 ) {
+ quit(1);
+ }
+
+ /* Set an event filter that discards everything but QUIT */
+ SDL_SetEventFilter(FilterEvents);
+
+ /* Loop, waiting for QUIT */
+ while ( SDL_WaitEvent(&event) ) {
+ switch (event.type) {
+ case SDL_VIDEORESIZE:
+ printf("Got a resize event: %dx%d\n",
+ event.resize.w, event.resize.h);
+ SetVideoMode(event.resize.w, event.resize.h);
+ break;
+ case SDL_USEREVENT:
+ printf("Handling internal quit request\n");
+ /* Fall through to the quit handler */
+ case SDL_QUIT:
+ printf("Bye bye..\n");
+ quit(0);
+ default:
+ /* This should never happen */
+ printf("Warning: Event %d wasn't filtered\n",
+ event.type);
+ break;
+ }
+ }
+ printf("SDL_WaitEvent() error: %s\n", SDL_GetError());
+ SDL_Quit();
+ return(255);
+}
diff --git a/test/threadwin.c b/test/threadwin.c
new file mode 100644
index 0000000..c704b30
--- /dev/null
+++ b/test/threadwin.c
@@ -0,0 +1,338 @@
+
+/* Test out the multi-threaded event handling functions */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+/* Are we done yet? */
+static int done = 0;
+
+/* Is the cursor visible? */
+static int visible = 1;
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
+{
+ SDL_Surface *icon;
+ Uint8 *pixels;
+ Uint8 *mask;
+ int mlen, i;
+
+ *maskp = NULL;
+
+ /* Load the icon surface */
+ icon = SDL_LoadBMP(file);
+ if ( icon == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+ return(NULL);
+ }
+
+ /* Check width and height */
+ if ( (icon->w%8) != 0 ) {
+ fprintf(stderr, "Icon width must be a multiple of 8!\n");
+ SDL_FreeSurface(icon);
+ return(NULL);
+ }
+ if ( icon->format->palette == NULL ) {
+ fprintf(stderr, "Icon must have a palette!\n");
+ SDL_FreeSurface(icon);
+ return(NULL);
+ }
+
+ /* Set the colorkey */
+ SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *)icon->pixels));
+
+ /* Create the mask */
+ pixels = (Uint8 *)icon->pixels;
+ printf("Transparent pixel: (%d,%d,%d)\n",
+ icon->format->palette->colors[*pixels].r,
+ icon->format->palette->colors[*pixels].g,
+ icon->format->palette->colors[*pixels].b);
+ mlen = icon->w*icon->h;
+ mask = (Uint8 *)malloc(mlen/8);
+ if ( mask == NULL ) {
+ fprintf(stderr, "Out of memory!\n");
+ SDL_FreeSurface(icon);
+ return(NULL);
+ }
+ memset(mask, 0, mlen/8);
+ for ( i=0; i<mlen; ) {
+ if ( pixels[i] != *pixels )
+ mask[i/8] |= 0x01;
+ ++i;
+ if ( (i%8) != 0 )
+ mask[i/8] <<= 1;
+ }
+ *maskp = mask;
+ return(icon);
+}
+
+int SDLCALL FilterEvents(const SDL_Event *event)
+{
+ static int reallyquit = 0;
+
+ switch (event->type) {
+
+ case SDL_ACTIVEEVENT:
+ /* See what happened */
+ printf("App %s ",
+ event->active.gain ? "gained" : "lost");
+ if ( event->active.state & SDL_APPACTIVE )
+ printf("active ");
+ if ( event->active.state & SDL_APPMOUSEFOCUS )
+ printf("mouse ");
+ if ( event->active.state & SDL_APPINPUTFOCUS )
+ printf("input ");
+ printf("focus\n");
+
+ /* See if we are iconified or restored */
+ if ( event->active.state & SDL_APPACTIVE ) {
+ printf("App has been %s\n",
+ event->active.gain ?
+ "restored" : "iconified");
+ }
+ return(0);
+
+ /* This is important! Queue it if we want to quit. */
+ case SDL_QUIT:
+ if ( ! reallyquit ) {
+ reallyquit = 1;
+ printf("Quit requested\n");
+ return(0);
+ }
+ printf("Quit demanded\n");
+ return(1);
+
+ /* Mouse and keyboard events go to threads */
+ case SDL_MOUSEMOTION:
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ return(1);
+
+ /* Drop all other events */
+ default:
+ return(0);
+ }
+}
+
+int SDLCALL HandleMouse(void *unused)
+{
+ SDL_Event events[10];
+ int i, found;
+ Uint32 mask;
+
+ /* Handle mouse events here */
+ mask = (SDL_MOUSEMOTIONMASK|SDL_MOUSEBUTTONDOWNMASK|SDL_MOUSEBUTTONUPMASK);
+ while ( ! done ) {
+ found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask);
+ for ( i=0; i<found; ++i ) {
+ switch(events[i].type) {
+ /* We want to toggle visibility on buttonpress */
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ if ( events[i].button.state == SDL_PRESSED ) {
+ visible = !visible;
+ SDL_ShowCursor(visible);
+ }
+ printf("Mouse button %d has been %s\n",
+ events[i].button.button,
+ (events[i].button.state == SDL_PRESSED) ?
+ "pressed" : "released");
+ break;
+ /* Show relative mouse motion */
+ case SDL_MOUSEMOTION:
+ printf("Mouse relative motion: {%d,%d}\n",
+ events[i].motion.xrel, events[i].motion.yrel);
+ break;
+ }
+ }
+ /* Give up some CPU to allow events to arrive */
+ SDL_Delay(20);
+ }
+ return(0);
+}
+
+int SDLCALL HandleKeyboard(void *unused)
+{
+ SDL_Event events[10];
+ int i, found;
+ Uint32 mask;
+
+ /* Handle mouse events here */
+ mask = (SDL_KEYDOWNMASK|SDL_KEYUPMASK);
+ while ( ! done ) {
+ found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask);
+ for ( i=0; i<found; ++i ) {
+ switch(events[i].type) {
+ /* We want to toggle visibility on buttonpress */
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ printf("Key '%c' (keysym==%d) has been %s\n",
+ events[i].key.keysym.unicode,
+ (int) events[i].key.keysym.sym,
+ (events[i].key.state == SDL_PRESSED) ?
+ "pressed" : "released");
+
+ /* Allow hitting <ESC> to quit the app */
+ if ( events[i].key.keysym.sym == SDLK_ESCAPE ) {
+ done = 1;
+ }
+
+ /* skip events now that aren't KEYUPs... */
+ if (events[i].key.state == SDL_PRESSED)
+ break;
+
+ if ( events[i].key.keysym.sym == SDLK_f ) {
+ int rc = 0;
+ printf("attempting to toggle fullscreen...\n");
+ rc = SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
+ printf("SDL_WM_ToggleFullScreen returned %d.\n", rc);
+ }
+
+ if ( events[i].key.keysym.sym == SDLK_g ) {
+ SDL_GrabMode m;
+ m = SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON ?
+ SDL_GRAB_OFF : SDL_GRAB_ON;
+ printf("attempting to toggle input grab to %s...\n",
+ m == SDL_GRAB_ON ? "ON" : "OFF");
+ SDL_WM_GrabInput(m);
+ printf("attempt finished.\n");
+ }
+
+ break;
+ }
+ }
+ /* Give up some CPU to allow events to arrive */
+ SDL_Delay(20);
+ }
+ return(0);
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen;
+ SDL_Surface *icon;
+ Uint8 *icon_mask;
+ int i, parsed;
+ Uint8 *buffer;
+ SDL_Color palette[256];
+ Uint32 init_flags;
+ Uint8 video_bpp;
+ Uint32 video_flags;
+ SDL_Thread *mouse_thread;
+ SDL_Thread *keybd_thread;
+
+ /* Set the options, based on command line arguments */
+ init_flags = SDL_INIT_VIDEO;
+ video_bpp = 8;
+ video_flags = SDL_SWSURFACE;
+ parsed = 1;
+ while ( parsed ) {
+ /* If the threaded option is enabled, and the SDL library hasn't
+ been compiled with threaded events enabled, then the mouse and
+ keyboard won't respond.
+ */
+ if ( (argc >= 2) && (strcmp(argv[1], "-threaded") == 0) ) {
+ init_flags |= SDL_INIT_EVENTTHREAD;
+ argc -= 1;
+ argv += 1;
+ printf("Running with threaded events\n");
+ } else
+ if ( (argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0) ) {
+ video_flags |= SDL_FULLSCREEN;
+ argc -= 1;
+ argv += 1;
+ } else
+ if ( (argc >= 3) && (strcmp(argv[1], "-bpp") == 0) ) {
+ video_bpp = atoi(argv[2]);
+ argc -= 2;
+ argv += 2;
+ } else {
+ parsed = 0;
+ }
+ }
+
+ /* Initialize SDL with the requested flags */
+ if ( SDL_Init(init_flags) < 0 ) {
+ fprintf(stderr,
+ "Couldn't initialize SDL: %s\n", SDL_GetError());
+ return(1);
+ }
+
+ /* Set the icon -- this must be done before the first mode set */
+ icon = LoadIconSurface("icon.bmp", &icon_mask);
+ if ( icon != NULL ) {
+ SDL_WM_SetIcon(icon, icon_mask);
+ }
+ if ( icon_mask != NULL )
+ free(icon_mask);
+
+ /* Initialize the display */
+ screen = SDL_SetVideoMode(640, 480, video_bpp, video_flags);
+ if ( screen == NULL ) {
+ fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
+ video_bpp, SDL_GetError());
+ quit(1);
+ }
+ printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
+ "fullscreen" : "windowed");
+
+ /* Enable printable characters */
+ SDL_EnableUNICODE(1);
+
+ /* Set an event filter that discards everything but QUIT */
+ SDL_SetEventFilter(FilterEvents);
+
+ /* Create the event handling threads */
+ mouse_thread = SDL_CreateThread(HandleMouse, NULL);
+ keybd_thread = SDL_CreateThread(HandleKeyboard, NULL);
+
+ /* Set the surface pixels and refresh! */
+ for ( i=0; i<256; ++i ) {
+ palette[i].r = 255-i;
+ palette[i].g = 255-i;
+ palette[i].b = 255-i;
+ }
+ SDL_SetColors(screen, palette, 0, 256);
+ if ( SDL_LockSurface(screen) < 0 ) {
+ fprintf(stderr, "Couldn't lock display surface: %s\n",
+ SDL_GetError());
+ quit(2);
+ }
+ buffer = (Uint8 *)screen->pixels;
+ for ( i=0; i<screen->h; ++i ) {
+ memset(buffer,(i*255)/screen->h,
+ screen->w*screen->format->BytesPerPixel);
+ buffer += screen->pitch;
+ }
+ SDL_UnlockSurface(screen);
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+ /* Loop, waiting for QUIT */
+ while ( ! done ) {
+ if ( ! (init_flags & SDL_INIT_EVENTTHREAD) ) {
+ SDL_PumpEvents(); /* Needed when event thread is off */
+ }
+ if ( SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_QUITMASK) ) {
+ done = 1;
+ }
+ /* Give up some CPU so the events can accumulate */
+ SDL_Delay(20);
+ }
+ SDL_WaitThread(mouse_thread, NULL);
+ SDL_WaitThread(keybd_thread, NULL);
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/torturethread.c b/test/torturethread.c
new file mode 100644
index 0000000..cb18954
--- /dev/null
+++ b/test/torturethread.c
@@ -0,0 +1,91 @@
+
+/* Simple test of the SDL threading code */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+#define NUMTHREADS 10
+
+static char volatile time_for_threads_to_die[NUMTHREADS];
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ SDL_Quit();
+ exit(rc);
+}
+
+int SDLCALL SubThreadFunc(void *data) {
+ while(! *(int volatile *)data) {
+ ; /*SDL_Delay(10);*/ /* do nothing */
+ }
+ return 0;
+}
+
+int SDLCALL ThreadFunc(void *data) {
+ SDL_Thread *sub_threads[NUMTHREADS];
+ int flags[NUMTHREADS];
+ int i;
+ int tid = (int)(uintptr_t)data;
+
+ fprintf(stderr, "Creating Thread %d\n", tid);
+
+ for(i = 0; i < NUMTHREADS; i++) {
+ flags[i] = 0;
+ sub_threads[i] = SDL_CreateThread(SubThreadFunc, &flags[i]);
+ }
+
+ printf("Thread '%d' waiting for signal\n", tid);
+ while(time_for_threads_to_die[tid] != 1) {
+ ; /* do nothing */
+ }
+
+ printf("Thread '%d' sending signals to subthreads\n", tid);
+ for(i = 0; i < NUMTHREADS; i++) {
+ flags[i] = 1;
+ SDL_WaitThread(sub_threads[i], NULL);
+ }
+
+ printf("Thread '%d' exiting!\n", tid);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Thread *threads[NUMTHREADS];
+ int i;
+
+ /* Load the SDL library */
+ if ( SDL_Init(0) < 0 ) {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ return(1);
+ }
+
+ signal(SIGSEGV, SIG_DFL);
+ for(i = 0; i < NUMTHREADS; i++) {
+ time_for_threads_to_die[i] = 0;
+ threads[i] = SDL_CreateThread(ThreadFunc, (void *)(uintptr_t)i);
+
+ if ( threads[i] == NULL ) {
+ fprintf(stderr,
+ "Couldn't create thread: %s\n", SDL_GetError());
+ quit(1);
+ }
+ }
+
+ for(i = 0; i < NUMTHREADS; i++) {
+ time_for_threads_to_die[i] = 1;
+ }
+
+ for(i = 0; i < NUMTHREADS; i++) {
+ SDL_WaitThread(threads[i], NULL);
+ }
+ SDL_Quit();
+ return(0);
+}
diff --git a/test/utf8.txt b/test/utf8.txt
new file mode 100644
index 0000000..aab22f1
--- /dev/null
+++ b/test/utf8.txt
@@ -0,0 +1,287 @@
+UTF-8 decoder capability and stress test
+----------------------------------------
+
+Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2003-02-19
+
+This test file can help you examine, how your UTF-8 decoder handles
+various types of correct, malformed, or otherwise interesting UTF-8
+sequences. This file is not meant to be a conformance test. It does
+not prescribes any particular outcome and therefore there is no way to
+"pass" or "fail" this test file, even though the texts suggests a
+preferable decoder behaviour at some places. The aim is instead to
+help you think about and test the behaviour of your UTF-8 on a
+systematic collection of unusual inputs. Experience so far suggests
+that most first-time authors of UTF-8 decoders find at least one
+serious problem in their decoder by using this file.
+
+The test lines below cover boundary conditions, malformed UTF-8
+sequences as well as correctly encoded UTF-8 sequences of Unicode code
+points that should never occur in a correct UTF-8 file.
+
+According to ISO 10646-1:2000, sections D.7 and 2.3c, a device
+receiving UTF-8 shall interpret a "malformed sequence in the same way
+that it interprets a character that is outside the adopted subset" and
+"characters that are not within the adopted subset shall be indicated
+to the user" by a receiving device. A quite commonly used approach in
+UTF-8 decoders is to replace any malformed UTF-8 sequence by a
+replacement character (U+FFFD), which looks a bit like an inverted
+question mark, or a similar symbol. It might be a good idea to
+visually distinguish a malformed UTF-8 sequence from a correctly
+encoded Unicode character that is just not available in the current
+font but otherwise fully legal, even though ISO 10646-1 doesn't
+mandate this. In any case, just ignoring malformed sequences or
+unavailable characters does not conform to ISO 10646, will make
+debugging more difficult, and can lead to user confusion.
+
+Please check, whether a malformed UTF-8 sequence is (1) represented at
+all, (2) represented by exactly one single replacement character (or
+equivalent signal), and (3) the following quotation mark after an
+illegal UTF-8 sequence is correctly displayed, i.e. proper
+resynchronization takes place immageately after any malformed
+sequence. This file says "THE END" in the last line, so if you don't
+see that, your decoder crashed somehow before, which should always be
+cause for concern.
+
+All lines in this file are exactly 79 characters long (plus the line
+feed). In addition, all lines end with "|", except for the two test
+lines 2.1.1 and 2.2.1, which contain non-printable ASCII controls
+U+0000 and U+007F. If you display this file with a fixed-width font,
+these "|" characters should all line up in column 79 (right margin).
+This allows you to test quickly, whether your UTF-8 decoder finds the
+correct number of characters in every line, that is whether each
+malformed sequences is replaced by a single replacement character.
+
+Note that as an alternative to the notion of malformed sequence used
+here, it is also a perfectly acceptable (and in some situations even
+preferable) solution to represent each individual byte of a malformed
+sequence by a replacement character. If you follow this strategy in
+your decoder, then please ignore the "|" column.
+
+
+Here come the tests: |
+ |
+1 Some correct UTF-8 text |
+ |
+(The codepoints for this test are: |
+ U+03BA U+1F79 U+03C3 U+03BC U+03B5 --ryan.) |
+ |
+You should see the Greek word 'kosme': "κόσμε" |
+ |
+ |
+2 Boundary condition test cases |
+ |
+2.1 First possible sequence of a certain length |
+ |
+(byte zero skipped...there's a null added at the end of the test. --ryan.) |
+ |
+2.1.2 2 bytes (U-00000080): "€" |
+2.1.3 3 bytes (U-00000800): "ࠀ" |
+2.1.4 4 bytes (U-00010000): "𐀀" |
+ |
+(5 and 6 byte sequences were made illegal in rfc3629. --ryan.) |
+2.1.5 5 bytes (U-00200000): "" |
+2.1.6 6 bytes (U-04000000): "" |
+ |
+2.2 Last possible sequence of a certain length |
+ |
+2.2.1 1 byte (U-0000007F): "" |
+2.2.2 2 bytes (U-000007FF): "߿" |
+ |
+(Section 5.3.2 below calls this illegal. --ryan.) |
+2.2.3 3 bytes (U-0000FFFF): "￿" |
+ |
+(5 and 6 bytes sequences, and 4 bytes sequences > 0x10FFFF were made illegal |
+ in rfc3629, so these next three should be replaced with a invalid |
+ character codepoint. --ryan.) |
+2.2.4 4 bytes (U-001FFFFF): "" |
+2.2.5 5 bytes (U-03FFFFFF): "" |
+2.2.6 6 bytes (U-7FFFFFFF): "" |
+ |
+2.3 Other boundary conditions |
+ |
+2.3.1 U-0000D7FF = ed 9f bf = "퟿" |
+2.3.2 U-0000E000 = ee 80 80 = "" |
+2.3.3 U-0000FFFD = ef bf bd = "�" |
+2.3.4 U-0010FFFF = f4 8f bf bf = "􏿿" |
+ |
+(This one is bogus in rfc3629. --ryan.) |
+2.3.5 U-00110000 = f4 90 80 80 = "" |
+ |
+3 Malformed sequences |
+ |
+3.1 Unexpected continuation bytes |
+ |
+Each unexpected continuation byte should be separately signalled as a |
+malformed sequence of its own. |
+ |
+3.1.1 First continuation byte 0x80: "" |
+3.1.2 Last continuation byte 0xbf: "" |
+ |
+3.1.3 2 continuation bytes: "" |
+3.1.4 3 continuation bytes: "" |
+3.1.5 4 continuation bytes: "" |
+3.1.6 5 continuation bytes: "" |
+3.1.7 6 continuation bytes: "" |
+3.1.8 7 continuation bytes: "" |
+ |
+3.1.9 Sequence of all 64 possible continuation bytes (0x80-0xbf): |
+ |
+ " |
+ |
+ |
+ " |
+ |
+3.2 Lonely start characters |
+ |
+3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf), |
+ each followed by a space character: |
+ |
+ " |
+ " |
+ |
+3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef), |
+ each followed by a space character: |
+ |
+ " " |
+ |
+3.2.3 All 8 first bytes of 4-byte sequences (0xf0-0xf7), |
+ each followed by a space character: |
+ |
+ " " |
+ |
+3.2.4 All 4 first bytes of 5-byte sequences (0xf8-0xfb), |
+ each followed by a space character: |
+ |
+ " " |
+ |
+3.2.5 All 2 first bytes of 6-byte sequences (0xfc-0xfd), |
+ each followed by a space character: |
+ |
+ " " |
+ |
+3.3 Sequences with last continuation byte missing |
+ |
+All bytes of an incomplete sequence should be signalled as a single |
+malformed sequence, i.e., you should see only a single replacement |
+character in each of the next 10 tests. (Characters as in section 2) |
+ |
+3.3.1 2-byte sequence with last byte missing (U+0000): "" |
+3.3.2 3-byte sequence with last byte missing (U+0000): "" |
+3.3.3 4-byte sequence with last byte missing (U+0000): "" |
+3.3.4 5-byte sequence with last byte missing (U+0000): "" |
+3.3.5 6-byte sequence with last byte missing (U+0000): "" |
+3.3.6 2-byte sequence with last byte missing (U-000007FF): "" |
+3.3.7 3-byte sequence with last byte missing (U-0000FFFF): "" |
+3.3.8 4-byte sequence with last byte missing (U-001FFFFF): "" |
+3.3.9 5-byte sequence with last byte missing (U-03FFFFFF): "" |
+3.3.10 6-byte sequence with last byte missing (U-7FFFFFFF): "" |
+ |
+3.4 Concatenation of incomplete sequences |
+ |
+All the 10 sequences of 3.3 concatenated, you should see 10 malformed |
+sequences being signalled: |
+ |
+ "" |
+ |
+3.5 Impossible bytes |
+ |
+The following two bytes cannot appear in a correct UTF-8 string |
+ |
+3.5.1 fe = "" |
+3.5.2 ff = "" |
+3.5.3 fe fe ff ff = "" |
+ |
+4 Overlong sequences |
+ |
+The following sequences are not malformed according to the letter of |
+the Unicode 2.0 standard. However, they are longer then necessary and |
+a correct UTF-8 encoder is not allowed to produce them. A "safe UTF-8 |
+decoder" should reject them just like malformed sequences for two |
+reasons: (1) It helps to debug applications if overlong sequences are |
+not treated as valid representations of characters, because this helps |
+to spot problems more quickly. (2) Overlong sequences provide |
+alternative representations of characters, that could maliciously be |
+used to bypass filters that check only for ASCII characters. For |
+instance, a 2-byte encoded line feed (LF) would not be caught by a |
+line counter that counts only 0x0a bytes, but it would still be |
+processed as a line feed by an unsafe UTF-8 decoder later in the |
+pipeline. From a security point of view, ASCII compatibility of UTF-8 |
+sequences means also, that ASCII characters are *only* allowed to be |
+represented by ASCII bytes in the range 0x00-0x7f. To ensure this |
+aspect of ASCII compatibility, use only "safe UTF-8 decoders" that |
+reject overlong UTF-8 sequences for which a shorter encoding exists. |
+ |
+4.1 Examples of an overlong ASCII character |
+ |
+With a safe UTF-8 decoder, all of the following five overlong |
+representations of the ASCII character slash ("/") should be rejected |
+like a malformed UTF-8 sequence, for instance by substituting it with |
+a replacement character. If you see a slash below, you do not have a |
+safe UTF-8 decoder! |
+ |
+4.1.1 U+002F = c0 af = "" |
+4.1.2 U+002F = e0 80 af = "" |
+4.1.3 U+002F = f0 80 80 af = "" |
+4.1.4 U+002F = f8 80 80 80 af = "" |
+4.1.5 U+002F = fc 80 80 80 80 af = "" |
+ |
+4.2 Maximum overlong sequences |
+ |
+Below you see the highest Unicode value that is still resulting in an |
+overlong sequence if represented with the given number of bytes. This |
+is a boundary test for safe UTF-8 decoders. All five characters should |
+be rejected like malformed UTF-8 sequences. |
+ |
+4.2.1 U-0000007F = c1 bf = "" |
+4.2.2 U-000007FF = e0 9f bf = "" |
+4.2.3 U-0000FFFF = f0 8f bf bf = "" |
+4.2.4 U-001FFFFF = f8 87 bf bf bf = "" |
+4.2.5 U-03FFFFFF = fc 83 bf bf bf bf = "" |
+ |
+4.3 Overlong representation of the NUL character |
+ |
+The following five sequences should also be rejected like malformed |
+UTF-8 sequences and should not be treated like the ASCII NUL |
+character. |
+ |
+4.3.1 U+0000 = c0 80 = "" |
+4.3.2 U+0000 = e0 80 80 = "" |
+4.3.3 U+0000 = f0 80 80 80 = "" |
+4.3.4 U+0000 = f8 80 80 80 80 = "" |
+4.3.5 U+0000 = fc 80 80 80 80 80 = "" |
+ |
+5 Illegal code positions |
+ |
+The following UTF-8 sequences should be rejected like malformed |
+sequences, because they never represent valid ISO 10646 characters and |
+a UTF-8 decoder that accepts them might introduce security problems |
+comparable to overlong UTF-8 sequences. |
+ |
+5.1 Single UTF-16 surrogates |
+ |
+5.1.1 U+D800 = ed a0 80 = "" |
+5.1.2 U+DB7F = ed ad bf = "" |
+5.1.3 U+DB80 = ed ae 80 = "" |
+5.1.4 U+DBFF = ed af bf = "" |
+5.1.5 U+DC00 = ed b0 80 = "" |
+5.1.6 U+DF80 = ed be 80 = "" |
+5.1.7 U+DFFF = ed bf bf = "" |
+ |
+5.2 Paired UTF-16 surrogates |
+ |
+5.2.1 U+D800 U+DC00 = ed a0 80 ed b0 80 = "" |
+5.2.2 U+D800 U+DFFF = ed a0 80 ed bf bf = "" |
+5.2.3 U+DB7F U+DC00 = ed ad bf ed b0 80 = "" |
+5.2.4 U+DB7F U+DFFF = ed ad bf ed bf bf = "" |
+5.2.5 U+DB80 U+DC00 = ed ae 80 ed b0 80 = "" |
+5.2.6 U+DB80 U+DFFF = ed ae 80 ed bf bf = "" |
+5.2.7 U+DBFF U+DC00 = ed af bf ed b0 80 = "" |
+5.2.8 U+DBFF U+DFFF = ed af bf ed bf bf = "" |
+ |
+5.3 Other illegal code positions |
+ |
+5.3.1 U+FFFE = ef bf be = "￾" |
+5.3.2 U+FFFF = ef bf bf = "￿" |
+ |
+THE END |
+