diff options
Diffstat (limited to '3rdparty/SDL2/test')
154 files changed, 0 insertions, 33213 deletions
diff --git a/3rdparty/SDL2/test/COPYING b/3rdparty/SDL2/test/COPYING deleted file mode 100644 index c4c27e0968c..00000000000 --- a/3rdparty/SDL2/test/COPYING +++ /dev/null @@ -1,8 +0,0 @@ - -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/3rdparty/SDL2/test/Makefile.in b/3rdparty/SDL2/test/Makefile.in deleted file mode 100644 index 68f0d3dabd3..00000000000 --- a/3rdparty/SDL2/test/Makefile.in +++ /dev/null @@ -1,299 +0,0 @@ -# Makefile to build the SDL tests - -srcdir = @srcdir@ - -CC = @CC@ -EXE = @EXE@ -CFLAGS = @CFLAGS@ -g -LIBS = @LIBS@ - -TARGETS = \ - checkkeys$(EXE) \ - loopwave$(EXE) \ - loopwavequeue$(EXE) \ - testatomic$(EXE) \ - testaudioinfo$(EXE) \ - testaudiocapture$(EXE) \ - testautomation$(EXE) \ - testbounds$(EXE) \ - testcustomcursor$(EXE) \ - testdraw2$(EXE) \ - testdrawchessboard$(EXE) \ - testdropfile$(EXE) \ - testerror$(EXE) \ - testfile$(EXE) \ - testgamecontroller$(EXE) \ - testgesture$(EXE) \ - testgl2$(EXE) \ - testgles$(EXE) \ - testgles2$(EXE) \ - testhaptic$(EXE) \ - testhittesting$(EXE) \ - testrumble$(EXE) \ - testhotplug$(EXE) \ - testthread$(EXE) \ - testiconv$(EXE) \ - testime$(EXE) \ - testintersections$(EXE) \ - testrelative$(EXE) \ - testjoystick$(EXE) \ - testkeys$(EXE) \ - testloadso$(EXE) \ - testlock$(EXE) \ - testmultiaudio$(EXE) \ - testaudiohotplug$(EXE) \ - testnative$(EXE) \ - testoverlay2$(EXE) \ - testplatform$(EXE) \ - testpower$(EXE) \ - testfilesystem$(EXE) \ - testrendertarget$(EXE) \ - testresample$(EXE) \ - testscale$(EXE) \ - testsem$(EXE) \ - testshader$(EXE) \ - testshape$(EXE) \ - testsprite2$(EXE) \ - testspriteminimal$(EXE) \ - teststreaming$(EXE) \ - testtimer$(EXE) \ - testver$(EXE) \ - testviewport$(EXE) \ - testwm2$(EXE) \ - torturethread$(EXE) \ - testrendercopyex$(EXE) \ - testmessage$(EXE) \ - testdisplayinfo$(EXE) \ - testqsort$(EXE) \ - controllermap$(EXE) \ - -all: Makefile $(TARGETS) - -Makefile: $(srcdir)/Makefile.in - $(SHELL) config.status $@ - -checkkeys$(EXE): $(srcdir)/checkkeys.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -loopwave$(EXE): $(srcdir)/loopwave.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -loopwavequeue$(EXE): $(srcdir)/loopwavequeue.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testresample$(EXE): $(srcdir)/testresample.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testaudioinfo$(EXE): $(srcdir)/testaudioinfo.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testautomation$(EXE): $(srcdir)/testautomation.c \ - $(srcdir)/testautomation_audio.c \ - $(srcdir)/testautomation_clipboard.c \ - $(srcdir)/testautomation_events.c \ - $(srcdir)/testautomation_keyboard.c \ - $(srcdir)/testautomation_main.c \ - $(srcdir)/testautomation_mouse.c \ - $(srcdir)/testautomation_pixels.c \ - $(srcdir)/testautomation_platform.c \ - $(srcdir)/testautomation_rect.c \ - $(srcdir)/testautomation_render.c \ - $(srcdir)/testautomation_rwops.c \ - $(srcdir)/testautomation_sdltest.c \ - $(srcdir)/testautomation_stdlib.c \ - $(srcdir)/testautomation_surface.c \ - $(srcdir)/testautomation_syswm.c \ - $(srcdir)/testautomation_timer.c \ - $(srcdir)/testautomation_video.c \ - $(srcdir)/testautomation_hints.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testaudiohotplug$(EXE): $(srcdir)/testaudiohotplug.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testaudiocapture$(EXE): $(srcdir)/testaudiocapture.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testatomic$(EXE): $(srcdir)/testatomic.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testintersections$(EXE): $(srcdir)/testintersections.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testrelative$(EXE): $(srcdir)/testrelative.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testhittesting$(EXE): $(srcdir)/testhittesting.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testdraw2$(EXE): $(srcdir)/testdraw2.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testdrawchessboard$(EXE): $(srcdir)/testdrawchessboard.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testdropfile$(EXE): $(srcdir)/testdropfile.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testerror$(EXE): $(srcdir)/testerror.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testfile$(EXE): $(srcdir)/testfile.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testgamecontroller$(EXE): $(srcdir)/testgamecontroller.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testgesture$(EXE): $(srcdir)/testgesture.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ - -testgl2$(EXE): $(srcdir)/testgl2.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ - -testgles$(EXE): $(srcdir)/testgles.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLESLIB@ @MATHLIB@ - -testgles2$(EXE): $(srcdir)/testgles2.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ - -testhaptic$(EXE): $(srcdir)/testhaptic.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testhotplug$(EXE): $(srcdir)/testhotplug.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testrumble$(EXE): $(srcdir)/testrumble.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testthread$(EXE): $(srcdir)/testthread.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testiconv$(EXE): $(srcdir)/testiconv.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testime$(EXE): $(srcdir)/testime.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @SDL_TTF_LIB@ - -testjoystick$(EXE): $(srcdir)/testjoystick.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testkeys$(EXE): $(srcdir)/testkeys.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testloadso$(EXE): $(srcdir)/testloadso.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testlock$(EXE): $(srcdir)/testlock.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -ifeq (@ISMACOSX@,true) -testnative$(EXE): $(srcdir)/testnative.c \ - $(srcdir)/testnativecocoa.m \ - $(srcdir)/testnativex11.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -framework Cocoa @XLIB@ -endif - -ifeq (@ISWINDOWS@,true) -testnative$(EXE): $(srcdir)/testnative.c \ - $(srcdir)/testnativew32.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -endif - -ifeq (@ISUNIX@,true) -testnative$(EXE): $(srcdir)/testnative.c \ - $(srcdir)/testnativex11.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @XLIB@ -endif - -#there's probably a better way of doing this -ifeq (@ISMACOSX@,false) -ifeq (@ISWINDOWS@,false) -ifeq (@ISUNIX@,false) -testnative$(EXE): ; -endif -endif -endif - -testoverlay2$(EXE): $(srcdir)/testoverlay2.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testplatform$(EXE): $(srcdir)/testplatform.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testpower$(EXE): $(srcdir)/testpower.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testfilesystem$(EXE): $(srcdir)/testfilesystem.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testrendertarget$(EXE): $(srcdir)/testrendertarget.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testscale$(EXE): $(srcdir)/testscale.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testsem$(EXE): $(srcdir)/testsem.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testshader$(EXE): $(srcdir)/testshader.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@ - -testshape$(EXE): $(srcdir)/testshape.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testsprite2$(EXE): $(srcdir)/testsprite2.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testspriteminimal$(EXE): $(srcdir)/testspriteminimal.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ - -teststreaming$(EXE): $(srcdir)/teststreaming.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ - -testtimer$(EXE): $(srcdir)/testtimer.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testver$(EXE): $(srcdir)/testver.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testviewport$(EXE): $(srcdir)/testviewport.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testwm2$(EXE): $(srcdir)/testwm2.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -torturethread$(EXE): $(srcdir)/torturethread.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testrendercopyex$(EXE): $(srcdir)/testrendercopyex.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ - -testmessage$(EXE): $(srcdir)/testmessage.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testdisplayinfo$(EXE): $(srcdir)/testdisplayinfo.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testqsort$(EXE): $(srcdir)/testqsort.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testbounds$(EXE): $(srcdir)/testbounds.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -testcustomcursor$(EXE): $(srcdir)/testcustomcursor.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -controllermap$(EXE): $(srcdir)/controllermap.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/3rdparty/SDL2/test/README b/3rdparty/SDL2/test/README deleted file mode 100644 index f6282be34df..00000000000 --- a/3rdparty/SDL2/test/README +++ /dev/null @@ -1,47 +0,0 @@ - -These are test programs for the SDL library: - - checkkeys Watch the key events to check the keyboard - loopwave Audio test -- loop playing a WAV file - loopwavequeue Audio test -- loop playing a WAV file with SDL_QueueAudio - testaudioinfo Lists audio device capabilities - testerror Tests multi-threaded error handling - testfile Tests RWops layer - testgl2 A very simple example of using OpenGL with SDL - 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 - testmultiaudio Tests using several audio devices - testoverlay2 Tests the overlay flickering/scaling during playback. - testplatform Tests types, endianness and cpu capabilities - testsem Tests SDL's semaphore implementation - testshape Tests shaped windows - testsprite2 Example of fast sprite movement on the screen - testthread Hacked up test of multi-threading - testtimer Test the timer facilities - testver Check the version and dynamic loading and endianness - testwm2 Test window manager -- title, icon, events - torturethread Simple test for thread creation/destruction - controllermap Useful to generate Game Controller API compatible maps - - - -This directory contains sample.wav, which is a sample from Will Provost's -song, The Living Proof: - - From the album The Living Proof - Publisher: 5 Guys Named Will - Copyright 1996 Will Provost - -You can get a copy of the full song (and album!) from iTunes... - - https://itunes.apple.com/us/album/the-living-proof/id4153978 - -or Amazon... - - http://www.amazon.com/The-Living-Proof-Will-Provost/dp/B00004R8RH - -Thanks to Will for permitting us to distribute this sample with SDL! - diff --git a/3rdparty/SDL2/test/acinclude.m4 b/3rdparty/SDL2/test/acinclude.m4 deleted file mode 100644 index ead69e5149c..00000000000 --- a/3rdparty/SDL2/test/acinclude.m4 +++ /dev/null @@ -1,359 +0,0 @@ -# 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 - -# serial 1 - -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_SDL2], -[dnl -dnl Get the cflags and libraries from the sdl2-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) - - min_sdl_version=ifelse([$1], ,0.9.0,$1) - - if test "x$sdl_prefix$sdl_exec_prefix" = x ; then - PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], - [sdl_pc=yes], - [sdl_pc=no]) - else - sdl_pc=no - if test x$sdl_exec_prefix != x ; then - sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_exec_prefix/bin/sdl2-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_prefix/bin/sdl2-config - fi - fi - fi - - if test "x$sdl_pc" = xyes ; then - no_sdl="" - SDL_CONFIG="pkg-config sdl2" - else - as_save_PATH="$PATH" - if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then - PATH="$prefix/bin:$prefix/usr/bin:$PATH" - fi - AC_PATH_PROG(SDL_CONFIG, sdl2-config, no, [$PATH]) - PATH="$as_save_PATH" - 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 $sdl_config_args --cflags` - SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` - - sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - sdl_minor_version=`$SDL_CONFIG $sdl_config_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 sdl2-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, µ) != 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*** 'sdl2-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 sdl2-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl2-config was wrong, set the environment variable SDL_CONFIG\n"); - printf("*** to point to the correct copy of sdl2-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) - else - AC_MSG_RESULT(no) - fi - fi - if test "x$no_sdl" = x ; then - ifelse([$2], , :, [$2]) - else - if test "$SDL_CONFIG" = "no" ; then - echo "*** The sdl2-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 sdl2-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 sdl2-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 -]) -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -AC_DEFUN([PKG_PROG_PKG_CONFIG], -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) -AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) -AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_default([$1], [0.9.0]) - AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - PKG_CONFIG="" - fi -fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_EXISTS], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -if test -n "$PKG_CONFIG" && \ - AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_default([$2], [:]) -m4_ifvaln([$3], [else - $3])dnl -fi]) - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -m4_define([_PKG_CONFIG], -[if test -n "$$1"; then - pkg_cv_[]$1="$$1" - elif test -n "$PKG_CONFIG"; then - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl - -pkg_failed=no -AC_MSG_CHECKING([for $1]) - -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -and $1[]_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details.]) - -if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - - m4_default([$4], [AC_MSG_ERROR( -[Package requirements ($2) were not met: - -$$1_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -_PKG_TEXT])dnl - ]) -elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) - m4_default([$4], [AC_MSG_FAILURE( -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl - ]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - $3 -fi[]dnl -])# PKG_CHECK_MODULES diff --git a/3rdparty/SDL2/test/aclocal.m4 b/3rdparty/SDL2/test/aclocal.m4 deleted file mode 100644 index ead69e5149c..00000000000 --- a/3rdparty/SDL2/test/aclocal.m4 +++ /dev/null @@ -1,359 +0,0 @@ -# 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 - -# serial 1 - -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_SDL2], -[dnl -dnl Get the cflags and libraries from the sdl2-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) - - min_sdl_version=ifelse([$1], ,0.9.0,$1) - - if test "x$sdl_prefix$sdl_exec_prefix" = x ; then - PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], - [sdl_pc=yes], - [sdl_pc=no]) - else - sdl_pc=no - if test x$sdl_exec_prefix != x ; then - sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_exec_prefix/bin/sdl2-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_prefix/bin/sdl2-config - fi - fi - fi - - if test "x$sdl_pc" = xyes ; then - no_sdl="" - SDL_CONFIG="pkg-config sdl2" - else - as_save_PATH="$PATH" - if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then - PATH="$prefix/bin:$prefix/usr/bin:$PATH" - fi - AC_PATH_PROG(SDL_CONFIG, sdl2-config, no, [$PATH]) - PATH="$as_save_PATH" - 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 $sdl_config_args --cflags` - SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` - - sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - sdl_minor_version=`$SDL_CONFIG $sdl_config_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 sdl2-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, µ) != 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*** 'sdl2-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 sdl2-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl2-config was wrong, set the environment variable SDL_CONFIG\n"); - printf("*** to point to the correct copy of sdl2-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) - else - AC_MSG_RESULT(no) - fi - fi - if test "x$no_sdl" = x ; then - ifelse([$2], , :, [$2]) - else - if test "$SDL_CONFIG" = "no" ; then - echo "*** The sdl2-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 sdl2-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 sdl2-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 -]) -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -AC_DEFUN([PKG_PROG_PKG_CONFIG], -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) -AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) -AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_default([$1], [0.9.0]) - AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - PKG_CONFIG="" - fi -fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_EXISTS], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -if test -n "$PKG_CONFIG" && \ - AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_default([$2], [:]) -m4_ifvaln([$3], [else - $3])dnl -fi]) - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -m4_define([_PKG_CONFIG], -[if test -n "$$1"; then - pkg_cv_[]$1="$$1" - elif test -n "$PKG_CONFIG"; then - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl - -pkg_failed=no -AC_MSG_CHECKING([for $1]) - -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -and $1[]_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details.]) - -if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - - m4_default([$4], [AC_MSG_ERROR( -[Package requirements ($2) were not met: - -$$1_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -_PKG_TEXT])dnl - ]) -elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) - m4_default([$4], [AC_MSG_FAILURE( -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl - ]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - $3 -fi[]dnl -])# PKG_CHECK_MODULES diff --git a/3rdparty/SDL2/test/autogen.sh b/3rdparty/SDL2/test/autogen.sh deleted file mode 100644 index 939f34c0f39..00000000000 --- a/3rdparty/SDL2/test/autogen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/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/3rdparty/SDL2/test/axis.bmp b/3rdparty/SDL2/test/axis.bmp Binary files differdeleted file mode 100644 index c7addd3ed93..00000000000 --- a/3rdparty/SDL2/test/axis.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/button.bmp b/3rdparty/SDL2/test/button.bmp Binary files differdeleted file mode 100644 index 1593ccea490..00000000000 --- a/3rdparty/SDL2/test/button.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/checkkeys.c b/3rdparty/SDL2/test/checkkeys.c deleted file mode 100644 index 771369fa3fa..00000000000 --- a/3rdparty/SDL2/test/checkkeys.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* 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> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL.h" - -int done; - -/* 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_string(char **text, size_t *maxlen, const char *fmt, ...) -{ - int len; - va_list ap; - - va_start(ap, fmt); - len = SDL_vsnprintf(*text, *maxlen, fmt, ap); - if (len > 0) { - *text += len; - if ( ((size_t) len) < *maxlen ) { - *maxlen -= (size_t) len; - } else { - *maxlen = 0; - } - } - va_end(ap); -} - -static void -print_modifiers(char **text, size_t *maxlen) -{ - int mod; - print_string(text, maxlen, " modifiers:"); - mod = SDL_GetModState(); - if (!mod) { - print_string(text, maxlen, " (none)"); - return; - } - if (mod & KMOD_LSHIFT) - print_string(text, maxlen, " LSHIFT"); - if (mod & KMOD_RSHIFT) - print_string(text, maxlen, " RSHIFT"); - if (mod & KMOD_LCTRL) - print_string(text, maxlen, " LCTRL"); - if (mod & KMOD_RCTRL) - print_string(text, maxlen, " RCTRL"); - if (mod & KMOD_LALT) - print_string(text, maxlen, " LALT"); - if (mod & KMOD_RALT) - print_string(text, maxlen, " RALT"); - if (mod & KMOD_LGUI) - print_string(text, maxlen, " LGUI"); - if (mod & KMOD_RGUI) - print_string(text, maxlen, " RGUI"); - if (mod & KMOD_NUM) - print_string(text, maxlen, " NUM"); - if (mod & KMOD_CAPS) - print_string(text, maxlen, " CAPS"); - if (mod & KMOD_MODE) - print_string(text, maxlen, " MODE"); -} - -static void -PrintModifierState() -{ - char message[512]; - char *spot; - size_t left; - - spot = message; - left = sizeof(message); - - print_modifiers(&spot, &left); - SDL_Log("Initial state:%s\n", message); -} - -static void -PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat) -{ - char message[512]; - char *spot; - size_t left; - - spot = message; - left = sizeof(message); - - /* Print the keycode, name and state */ - if (sym->sym) { - print_string(&spot, &left, - "Key %s: scancode %d = %s, keycode 0x%08X = %s ", - pressed ? "pressed " : "released", - sym->scancode, - SDL_GetScancodeName(sym->scancode), - sym->sym, SDL_GetKeyName(sym->sym)); - } else { - print_string(&spot, &left, - "Unknown Key (scancode %d = %s) %s ", - sym->scancode, - SDL_GetScancodeName(sym->scancode), - pressed ? "pressed " : "released"); - } - print_modifiers(&spot, &left); - if (repeat) { - print_string(&spot, &left, " (repeat)"); - } - SDL_Log("%s\n", message); -} - -static void -PrintText(char *eventtype, char *text) -{ - char *spot, expanded[1024]; - - expanded[0] = '\0'; - for ( spot = text; *spot; ++spot ) - { - size_t length = SDL_strlen(expanded); - SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot); - } - SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text); -} - -void -loop() -{ - SDL_Event event; - /* Check for events */ - /*SDL_WaitEvent(&event); emscripten does not like waiting*/ - - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_KEYDOWN: - case SDL_KEYUP: - PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE); - break; - case SDL_TEXTEDITING: - PrintText("EDIT", event.text.text); - break; - case SDL_TEXTINPUT: - PrintText("INPUT", event.text.text); - break; - case SDL_MOUSEBUTTONDOWN: - /* Any button press quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - SDL_Window *window; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize SDL */ - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - /* Set 640x480 video mode */ - window = SDL_CreateWindow("CheckKeys Test", - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - 640, 480, 0); - if (!window) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", - SDL_GetError()); - quit(2); - } - -#if __IPHONEOS__ - /* Creating the context creates the view, which we need to show keyboard */ - SDL_GL_CreateContext(window); -#endif - - SDL_StartTextInput(); - - /* Print initial modifier state */ - SDL_PumpEvents(); - PrintModifierState(); - - /* Watch keystrokes */ - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - - SDL_Quit(); - return (0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/configure b/3rdparty/SDL2/test/configure deleted file mode 100644 index 61c32fba1be..00000000000 --- a/3rdparty/SDL2/test/configure +++ /dev/null @@ -1,5124 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69. -# -# -# Copyright (C) 1992-1996, 1998-2012 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 - - -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 -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (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 - - -# 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. -as_myself= -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 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="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_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - 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_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -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 - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -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'` - -# 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_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # 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; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # 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 -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -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 -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -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='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# 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'" - - -test -n "$DJDIR" || exec 7<&0 </dev/null -exec 6>&1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/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= - -# Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= -PACKAGE_URL= - -ac_unique_file="README" -ac_subst_vars='LTLIBOBJS -LIBOBJS -SDL_TTF_LIB -XLIB -GLES2LIB -GLESLIB -GLLIB -CPP -XMKMF -SDL_CONFIG -SDL_LIBS -SDL_CFLAGS -PKG_CONFIG_LIBDIR -PKG_CONFIG_PATH -PKG_CONFIG -ISUNIX -ISWINDOWS -ISMACOSX -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_URL -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 -PKG_CONFIG -PKG_CONFIG_PATH -PKG_CONFIG_LIBDIR -SDL_CFLAGS -SDL_LIBS -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= ;; - *) 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_fn_error $? "invalid feature name: $ac_useropt" - 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_fn_error $? "invalid feature name: $ac_useropt" - 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_fn_error $? "invalid package name: $ac_useropt" - 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_fn_error $? "invalid package name: $ac_useropt" - 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_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - 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_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $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_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -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 - 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_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# 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_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - 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 (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if - you have headers in a nonstandard directory <include dir> - PKG_CONFIG path to pkg-config utility - PKG_CONFIG_PATH - directories to add to pkg-config's search path - PKG_CONFIG_LIBDIR - path overriding pkg-config's built-in search path - SDL_CFLAGS C compiler flags for SDL, overriding pkg-config - SDL_LIBS linker flags for SDL, overriding pkg-config - 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. - -Report bugs to the package provider. -_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.69 - -Copyright (C) 2012 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 - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - 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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - 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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { 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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -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 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - 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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - 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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp -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.69. 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) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append 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 - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset 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 - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - 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:${as_lineno-$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= ;; #( - *) { eval $ac_var=; 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 - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - 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 - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - 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 - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - 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'; as_fn_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 - -$as_echo "/* confdefs.h */" > 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 - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_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 - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -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 /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$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" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - 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. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$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:${as_lineno-$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:${as_lineno-$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:${as_lineno-$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:${as_lineno-$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:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$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. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$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_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -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_fn_error $? "cannot find install-sh, install.sh, or shtool in $srcdir/../build-scripts" "$LINENO" 5 -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_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; 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_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -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:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; 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_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -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:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$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:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; 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 as_fn_executable_p "$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:${as_lineno-$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:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$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:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* 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:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; 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 -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; 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:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdio.h> -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { 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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* 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:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; 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:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$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 ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - 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:${as_lineno-$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:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; 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 confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -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:${as_lineno-$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:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdarg.h> -#include <stdio.h> -struct stat; -/* 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" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -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:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -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:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -$as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if ${ac_cv_c_const+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - -#ifndef __cplusplus - /* Ultrix mips cc rejects this sort of thing. */ - typedef int charset[2]; - const charset cs = { 0, 0 }; - /* 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 sort of thing. */ - char tx; - char *t = &tx; - 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 sort of thing, saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; } bx; - struct s *b = &bx; 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 -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_const=yes -else - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -$as_echo "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -$as_echo "#define const /**/" >>confdefs.h - -fi - - -ISUNIX="false" -ISWINDOWS="false" -ISMACOSX="false" - -case "$host" in - *-*-cygwin* | *-*-mingw32*) - ISWINDOWS="true" - EXE=".exe" - MATHLIB="" - SYS_GL_LIBS="-lopengl32" - ;; - *-*-haiku*) - EXE="" - MATHLIB="" - SYS_GL_LIBS="-lGL" - ;; - *-*-darwin* ) - ISMACOSX="true" - EXE="" - MATHLIB="" - SYS_GL_LIBS="-Wl,-framework,OpenGL" - ;; - *-*-aix*) - ISUNIX="true" - 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:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_OSMESA_CONFIG+:} false; 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_OSMESA_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: $OSMESA_CONFIG" >&5 -$as_echo "$OSMESA_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$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 - ;; - *-*-qnx*) - EXE="" - MATHLIB="" - SYS_GL_LIBS="-lGLES_CM" - ;; - *-*-emscripten* ) - EXE=".bc" - MATHLIB="" - SYS_GL_LIBS="" - ;; - *) - ISUNIX="true" - EXE="" - MATHLIB="-lm" - SYS_GL_LIBS="-lGL" - ;; -esac - - - - - - -SDL_VERSION=2.0.0 - - - - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$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 - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi -fi - -# 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 - - - min_sdl_version=$SDL_VERSION - - if test "x$sdl_prefix$sdl_exec_prefix" = x ; then - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL" >&5 -$as_echo_n "checking for SDL... " >&6; } - -if test -n "$SDL_CFLAGS"; then - pkg_cv_SDL_CFLAGS="$SDL_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl2 >= $min_sdl_version" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$SDL_LIBS"; then - pkg_cv_SDL_LIBS="$SDL_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl2 >= $min_sdl_version" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "sdl2 >= $min_sdl_version" 2>&1` - else - SDL_PKG_ERRORS=`$PKG_CONFIG --print-errors "sdl2 >= $min_sdl_version" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$SDL_PKG_ERRORS" >&5 - - sdl_pc=no -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - sdl_pc=no -else - SDL_CFLAGS=$pkg_cv_SDL_CFLAGS - SDL_LIBS=$pkg_cv_SDL_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - sdl_pc=yes -fi - else - sdl_pc=no - if test x$sdl_exec_prefix != x ; then - sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_exec_prefix/bin/sdl2-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_prefix/bin/sdl2-config - fi - fi - fi - - if test "x$sdl_pc" = xyes ; then - no_sdl="" - SDL_CONFIG="pkg-config sdl2" - else - as_save_PATH="$PATH" - if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then - PATH="$prefix/bin:$prefix/usr/bin:$PATH" - fi - # Extract the first word of "sdl2-config", so it can be a program name with args. -set dummy sdl2-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SDL_CONFIG+:} false; 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: $SDL_CONFIG" >&5 -$as_echo "$SDL_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - PATH="$as_save_PATH" - { $as_echo "$as_me:${as_lineno-$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 $sdl_config_args --cflags` - SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` - - sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` - sdl_minor_version=`$SDL_CONFIG $sdl_config_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 confdefs.h - <<_ACEOF >conftest.$ac_ext -/* 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, µ) != 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*** 'sdl2-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 sdl2-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl2-config was wrong, set the environment variable SDL_CONFIG\n"); - printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); - printf("*** config.cache before re-running configure\n"); - return 1; - } -} - - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - no_sdl=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam 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:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - fi - if test "x$no_sdl" = x ; then - : - else - if test "$SDL_CONFIG" = "no" ; then - echo "*** The sdl2-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 sdl2-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 confdefs.h - <<_ACEOF >conftest.$ac_ext -/* 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 -if ac_fn_c_try_link "$LINENO"; 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 - 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 sdl2-config script: $SDL_CONFIG" -fi -rm -f core conftest.err conftest.$ac_objext \ - 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_fn_error $? "*** SDL version $SDL_VERSION not found!" "$LINENO" 5 - - fi - - - rm -f conf.sdltest - -CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS -lSDL2_test $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:${as_lineno-$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 ${ac_cv_prog_CPP+:} false; 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 confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i 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:${as_lineno-$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 confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -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:${as_lineno-$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_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if ${ac_cv_have_x+:} false; 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/X11R7/include -/usr/X11R6/include -/usr/X11R5/include -/usr/X11R4/include - -/usr/include/X11 -/usr/include/X11R7 -/usr/include/X11R6 -/usr/include/X11R5 -/usr/include/X11R4 - -/usr/local/X11/include -/usr/local/X11R7/include -/usr/local/X11R6/include -/usr/local/X11R5/include -/usr/local/X11R4/include - -/usr/local/include/X11 -/usr/local/include/X11R7 -/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 confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <X11/Xlib.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # We can compile using X headers with no special include directory. -ac_x_includes= -else - 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.i 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 confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <X11/Xlib.h> -int -main () -{ -XrmInitialize () - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - LIBS=$ac_save_LIBS -# We can link X programs with no special library path. -ac_x_libraries= -else - 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 -f core conftest.err conftest.$ac_objext \ - 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:${as_lineno-$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:${as_lineno-$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" = xNone || 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" = xNone; then - : - else - if test "x$ac_x_libraries" = x; then - XPATH="" - XLIB="-lX11" - else - XPATH="-L$ac_x_libraries" - XLIB="-L$ac_x_libraries -lX11" - fi - fi -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL support" >&5 -$as_echo_n "checking for OpenGL support... " >&6; } -have_opengl=no -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include "SDL_opengl.h" - -int -main () -{ - - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -have_opengl=yes - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengl" >&5 -$as_echo "$have_opengl" >&6; } - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES support" >&5 -$as_echo_n "checking for OpenGL ES support... " >&6; } -have_opengles=no -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #if defined (__IPHONEOS__) - #include <OpenGLES/ES1/gl.h> - #else - #include <GLES/gl.h> - #endif /* __QNXNTO__ */ - -int -main () -{ - - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -have_opengles=yes - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengles" >&5 -$as_echo "$have_opengles" >&6; } - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES2 support" >&5 -$as_echo_n "checking for OpenGL ES2 support... " >&6; } -have_opengles2=no -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #if defined (__IPHONEOS__) - #include <OpenGLES/ES2/gl.h> - #include <OpenGLES/ES2/glext.h> - #else - #include <GLES2/gl2.h> - #include <GLES2/gl2ext.h> - #endif - -int -main () -{ - - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -have_opengles2=yes - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengles2" >&5 -$as_echo "$have_opengles2" >&6; } - -GLLIB="" -GLESLIB="" -GLES2LIB="" -if test x$have_opengles = xyes; then - CFLAGS="$CFLAGS -DHAVE_OPENGLES" - GLESLIB="$XPATH -lGLESv1_CM" -fi -if test x$have_opengles2 = xyes; then - CFLAGS="$CFLAGS -DHAVE_OPENGLES2" - #GLES2LIB="$XPATH -lGLESv2" -fi -if test x$have_opengl = xyes; then - CFLAGS="$CFLAGS -DHAVE_OPENGL" - GLLIB="$XPATH $SYS_GL_LIBS" -fi - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5 -$as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; } -if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lSDL2_ttf $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char TTF_Init (); -int -main () -{ -return TTF_Init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_SDL2_ttf_TTF_Init=yes -else - ac_cv_lib_SDL2_ttf_TTF_Init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_SDL2_ttf_TTF_Init" >&5 -$as_echo "$ac_cv_lib_SDL2_ttf_TTF_Init" >&6; } -if test "x$ac_cv_lib_SDL2_ttf_TTF_Init" = xyes; then : - have_SDL_ttf=yes -fi - -if test x$have_SDL_ttf = xyes; then - CFLAGS="$CFLAGS -DHAVE_SDL_TTF" - SDL_TTF_LIB="-lSDL2_ttf" -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:${as_lineno-$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= ;; #( - *) { eval $ac_var=; 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 - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$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= -U= -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. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append 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:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_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} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_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 - - -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 -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (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 - - -# 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. -as_myself= -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 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -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 - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -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'` - -# 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 - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -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 -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - 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_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# 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 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=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.69. 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 and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, 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 the package provider." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 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=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - 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 ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; 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"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append 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_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append 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_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - 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= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# 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=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -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 {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -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_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - 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_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - 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 >>"\$ac_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 >>"\$ac_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 < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries 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[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -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_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[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="$ac_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_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append 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:${as_lineno-$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 >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - 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"; as_fn_mkdir_p - 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:${as_lineno-$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 "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$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 "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - - - - esac - -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# 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 || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/3rdparty/SDL2/test/configure.in b/3rdparty/SDL2/test/configure.in deleted file mode 100644 index fd3f3022bc2..00000000000 --- a/3rdparty/SDL2/test/configure.in +++ /dev/null @@ -1,191 +0,0 @@ -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 We only care about this for building testnative at the moment, so these -dnl values shouldn't be considered absolute truth. -dnl (Haiku, for example, sets none of these.) -ISUNIX="false" -ISWINDOWS="false" -ISMACOSX="false" - -dnl Figure out which math library to use -case "$host" in - *-*-cygwin* | *-*-mingw32*) - ISWINDOWS="true" - EXE=".exe" - MATHLIB="" - SYS_GL_LIBS="-lopengl32" - ;; - *-*-haiku*) - EXE="" - MATHLIB="" - SYS_GL_LIBS="-lGL" - ;; - *-*-darwin* ) - ISMACOSX="true" - EXE="" - MATHLIB="" - SYS_GL_LIBS="-Wl,-framework,OpenGL" - ;; - *-*-aix*) - ISUNIX="true" - 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 - ;; - *-*-qnx*) - EXE="" - MATHLIB="" - SYS_GL_LIBS="-lGLES_CM" - ;; - *-*-emscripten* ) - dnl This should really be .js, but we need to specify extra flags when compiling to js - EXE=".bc" - MATHLIB="" - SYS_GL_LIBS="" - ;; - *) - dnl Oh well, call it Unix... - ISUNIX="true" - EXE="" - MATHLIB="-lm" - SYS_GL_LIBS="-lGL" - ;; -esac -AC_SUBST(EXE) -AC_SUBST(MATHLIB) -AC_SUBST(ISMACOSX) -AC_SUBST(ISWINDOWS) -AC_SUBST(ISUNIX) - -dnl Check for SDL -SDL_VERSION=2.0.0 -AM_PATH_SDL2($SDL_VERSION, - :, - AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) -) -CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS -lSDL2_test $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" = xNone || 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" = xNone; then - : - else - if test "x$ac_x_libraries" = x; then - XPATH="" - XLIB="-lX11" - else - XPATH="-L$ac_x_libraries" - XLIB="-L$ac_x_libraries -lX11" - fi - 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) - -dnl Check for OpenGL ES -AC_MSG_CHECKING(for OpenGL ES support) -have_opengles=no -AC_TRY_COMPILE([ - #if defined (__IPHONEOS__) - #include <OpenGLES/ES1/gl.h> - #else - #include <GLES/gl.h> - #endif /* __QNXNTO__ */ -],[ -],[ -have_opengles=yes -]) -AC_MSG_RESULT($have_opengles) - -dnl Check for OpenGL ES2 -AC_MSG_CHECKING(for OpenGL ES2 support) -have_opengles2=no -AC_TRY_COMPILE([ - #if defined (__IPHONEOS__) - #include <OpenGLES/ES2/gl.h> - #include <OpenGLES/ES2/glext.h> - #else - #include <GLES2/gl2.h> - #include <GLES2/gl2ext.h> - #endif -],[ -],[ -have_opengles2=yes -]) -AC_MSG_RESULT($have_opengles2) - -GLLIB="" -GLESLIB="" -GLES2LIB="" -if test x$have_opengles = xyes; then - CFLAGS="$CFLAGS -DHAVE_OPENGLES" - GLESLIB="$XPATH -lGLESv1_CM" -fi -if test x$have_opengles2 = xyes; then - CFLAGS="$CFLAGS -DHAVE_OPENGLES2" - #GLES2LIB="$XPATH -lGLESv2" -fi -if test x$have_opengl = xyes; then - CFLAGS="$CFLAGS -DHAVE_OPENGL" - GLLIB="$XPATH $SYS_GL_LIBS" -fi - -AC_SUBST(GLLIB) -AC_SUBST(GLESLIB) -AC_SUBST(GLES2LIB) -AC_SUBST(XLIB) - -dnl Check for SDL_ttf -AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes) -if test x$have_SDL_ttf = xyes; then - CFLAGS="$CFLAGS -DHAVE_SDL_TTF" - SDL_TTF_LIB="-lSDL2_ttf" -fi -AC_SUBST(SDL_TTF_LIB) - -dnl Finally create all the generated files -AC_OUTPUT([Makefile]) diff --git a/3rdparty/SDL2/test/controllermap.bmp b/3rdparty/SDL2/test/controllermap.bmp Binary files differdeleted file mode 100644 index df167f67780..00000000000 --- a/3rdparty/SDL2/test/controllermap.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/controllermap.c b/3rdparty/SDL2/test/controllermap.c deleted file mode 100644 index d626f9f89a6..00000000000 --- a/3rdparty/SDL2/test/controllermap.c +++ /dev/null @@ -1,437 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Game controller mapping generator */ -/* Gabriel Jacobo <gabomdq@gmail.com> */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "SDL.h" - -#ifndef SDL_JOYSTICK_DISABLED - -#ifdef __IPHONEOS__ -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 480 -#else -#define SCREEN_WIDTH 512 -#define SCREEN_HEIGHT 320 -#endif - -#define MARKER_BUTTON 1 -#define MARKER_AXIS 2 - -typedef struct MappingStep -{ - int x, y; - double angle; - int marker; - char *field; - int axis, button, hat, hat_value; - char mapping[4096]; -}MappingStep; - - -SDL_Texture * -LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent) -{ - SDL_Surface *temp; - SDL_Texture *texture; - - /* Load the sprite image */ - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); - return NULL; - } - - /* Set transparent pixel as the pixel at (0,0) */ - if (transparent) { - if (temp->format->palette) { - SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels); - } else { - switch (temp->format->BitsPerPixel) { - case 15: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint16 *) temp->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels); - break; - case 24: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint32 *) temp->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels); - break; - } - } - } - - /* Create textures from the image */ - texture = SDL_CreateTextureFromSurface(renderer, temp); - if (!texture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - SDL_FreeSurface(temp); - return NULL; - } - SDL_FreeSurface(temp); - - /* We're ready to roll. :) */ - return texture; -} - -static SDL_bool -WatchJoystick(SDL_Joystick * joystick) -{ - SDL_Window *window = NULL; - SDL_Renderer *screen = NULL; - SDL_Texture *background, *button, *axis, *marker; - const char *name = NULL; - SDL_bool retval = SDL_FALSE; - SDL_bool done = SDL_FALSE, next=SDL_FALSE; - SDL_Event event; - SDL_Rect dst; - int s, _s; - Uint8 alpha=200, alpha_step = -1; - Uint32 alpha_ticks = 0; - char mapping[4096], temp[4096]; - MappingStep *step, *prev_step; - MappingStep steps[] = { - {342, 132, 0.0, MARKER_BUTTON, "x", -1, -1, -1, -1, ""}, - {387, 167, 0.0, MARKER_BUTTON, "a", -1, -1, -1, -1, ""}, - {431, 132, 0.0, MARKER_BUTTON, "b", -1, -1, -1, -1, ""}, - {389, 101, 0.0, MARKER_BUTTON, "y", -1, -1, -1, -1, ""}, - {174, 132, 0.0, MARKER_BUTTON, "back", -1, -1, -1, -1, ""}, - {233, 132, 0.0, MARKER_BUTTON, "guide", -1, -1, -1, -1, ""}, - {289, 132, 0.0, MARKER_BUTTON, "start", -1, -1, -1, -1, ""}, - {116, 217, 0.0, MARKER_BUTTON, "dpleft", -1, -1, -1, -1, ""}, - {154, 249, 0.0, MARKER_BUTTON, "dpdown", -1, -1, -1, -1, ""}, - {186, 217, 0.0, MARKER_BUTTON, "dpright", -1, -1, -1, -1, ""}, - {154, 188, 0.0, MARKER_BUTTON, "dpup", -1, -1, -1, -1, ""}, - {77, 40, 0.0, MARKER_BUTTON, "leftshoulder", -1, -1, -1, -1, ""}, - {91, 0, 0.0, MARKER_BUTTON, "lefttrigger", -1, -1, -1, -1, ""}, - {396, 36, 0.0, MARKER_BUTTON, "rightshoulder", -1, -1, -1, -1, ""}, - {375, 0, 0.0, MARKER_BUTTON, "righttrigger", -1, -1, -1, -1, ""}, - {75, 154, 0.0, MARKER_BUTTON, "leftstick", -1, -1, -1, -1, ""}, - {305, 230, 0.0, MARKER_BUTTON, "rightstick", -1, -1, -1, -1, ""}, - {75, 154, 0.0, MARKER_AXIS, "leftx", -1, -1, -1, -1, ""}, - {75, 154, 90.0, MARKER_AXIS, "lefty", -1, -1, -1, -1, ""}, - {305, 230, 0.0, MARKER_AXIS, "rightx", -1, -1, -1, -1, ""}, - {305, 230, 90.0, MARKER_AXIS, "righty", -1, -1, -1, -1, ""}, - }; - - /* Create a window to display joystick axis position */ - window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); - if (window == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); - return SDL_FALSE; - } - - screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); - SDL_DestroyWindow(window); - return SDL_FALSE; - } - - background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); - button = LoadTexture(screen, "button.bmp", SDL_TRUE); - axis = LoadTexture(screen, "axis.bmp", SDL_TRUE); - SDL_RaiseWindow(window); - - /* scale for platforms that don't give you the window size you asked for. */ - SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT); - - /* Print info about the joystick we are watching */ - name = SDL_JoystickName(joystick); - SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick), - name ? name : "Unknown Joystick"); - SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", - SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), - SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); - - SDL_Log("\n\n\ - ====================================================================================\n\ - Press the buttons on your controller when indicated\n\ - (Your controller may look different than the picture)\n\ - If you want to correct a mistake, press backspace or the back button on your device\n\ - To skip a button, press SPACE or click/touch the screen\n\ - To exit, press ESC\n\ - ====================================================================================\n"); - - /* Initialize mapping with GUID and name */ - SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), temp, SDL_arraysize(temp)); - SDL_snprintf(mapping, SDL_arraysize(mapping), "%s,%s,platform:%s,", - temp, name ? name : "Unknown Joystick", SDL_GetPlatform()); - - /* Loop, getting joystick events! */ - for(s=0; s<SDL_arraysize(steps) && !done;) { - /* blank screen, set up for drawing this frame. */ - step = &steps[s]; - SDL_strlcpy(step->mapping, mapping, SDL_arraysize(step->mapping)); - step->axis = -1; - step->button = -1; - step->hat = -1; - step->hat_value = -1; - - switch(step->marker) { - case MARKER_AXIS: - marker = axis; - break; - case MARKER_BUTTON: - marker = button; - break; - default: - break; - } - - dst.x = step->x; - dst.y = step->y; - SDL_QueryTexture(marker, NULL, NULL, &dst.w, &dst.h); - next=SDL_FALSE; - - SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE); - - while (!done && !next) { - if (SDL_GetTicks() - alpha_ticks > 5) { - alpha_ticks = SDL_GetTicks(); - alpha += alpha_step; - if (alpha == 255) { - alpha_step = -1; - } - if (alpha < 128) { - alpha_step = 1; - } - } - - SDL_RenderClear(screen); - SDL_RenderCopy(screen, background, NULL, NULL); - SDL_SetTextureAlphaMod(marker, alpha); - SDL_SetTextureColorMod(marker, 10, 255, 21); - SDL_RenderCopyEx(screen, marker, NULL, &dst, step->angle, NULL, SDL_FLIP_NONE); - SDL_RenderPresent(screen); - - if (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_JOYAXISMOTION: - if ((event.jaxis.value > 20000 || event.jaxis.value < -20000) && event.jaxis.value != -32768) { - for (_s = 0; _s < s; _s++) { - if (steps[_s].axis == event.jaxis.axis) { - break; - } - } - if (_s == s) { - step->axis = event.jaxis.axis; - SDL_strlcat(mapping, step->field, SDL_arraysize(mapping)); - SDL_snprintf(temp, SDL_arraysize(temp), ":a%u,", event.jaxis.axis); - SDL_strlcat(mapping, temp, SDL_arraysize(mapping)); - s++; - next=SDL_TRUE; - } - } - - break; - case SDL_JOYHATMOTION: - if (event.jhat.value == SDL_HAT_CENTERED) { - break; /* ignore centering, we're probably just coming back to the center from the previous item we set. */ - } - for (_s = 0; _s < s; _s++) { - if (steps[_s].hat == event.jhat.hat && steps[_s].hat_value == event.jhat.value) { - break; - } - } - if (_s == s) { - step->hat = event.jhat.hat; - step->hat_value = event.jhat.value; - SDL_strlcat(mapping, step->field, SDL_arraysize(mapping)); - SDL_snprintf(temp, SDL_arraysize(temp), ":h%u.%u,", event.jhat.hat, event.jhat.value ); - SDL_strlcat(mapping, temp, SDL_arraysize(mapping)); - s++; - next=SDL_TRUE; - } - break; - case SDL_JOYBALLMOTION: - break; - case SDL_JOYBUTTONUP: - for (_s = 0; _s < s; _s++) { - if (steps[_s].button == event.jbutton.button) { - break; - } - } - if (_s == s) { - step->button = event.jbutton.button; - SDL_strlcat(mapping, step->field, SDL_arraysize(mapping)); - SDL_snprintf(temp, SDL_arraysize(temp), ":b%u,", event.jbutton.button); - SDL_strlcat(mapping, temp, SDL_arraysize(mapping)); - s++; - next=SDL_TRUE; - } - break; - case SDL_FINGERDOWN: - case SDL_MOUSEBUTTONDOWN: - /* Skip this step */ - s++; - next=SDL_TRUE; - break; - case SDL_KEYDOWN: - if (event.key.keysym.sym == SDLK_BACKSPACE || event.key.keysym.sym == SDLK_AC_BACK) { - /* Undo! */ - if (s > 0) { - prev_step = &steps[--s]; - SDL_strlcpy(mapping, prev_step->mapping, SDL_arraysize(prev_step->mapping)); - next = SDL_TRUE; - } - break; - } - if (event.key.keysym.sym == SDLK_SPACE) { - /* Skip this step */ - s++; - next=SDL_TRUE; - break; - } - - if ((event.key.keysym.sym != SDLK_ESCAPE)) { - break; - } - /* Fall through to signal quit */ - case SDL_QUIT: - done = SDL_TRUE; - break; - default: - break; - } - } - } - - } - - if (s == SDL_arraysize(steps) ) { - SDL_Log("Mapping:\n\n%s\n\n", mapping); - /* Print to stdout as well so the user can cat the output somewhere */ - printf("%s\n", mapping); - } - - while(SDL_PollEvent(&event)) {}; - - SDL_DestroyRenderer(screen); - SDL_DestroyWindow(window); - return retval; -} - -int -main(int argc, char *argv[]) -{ - const char *name; - int i; - SDL_Joystick *joystick; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize SDL (Note: video is required to start event loop) */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - - /* Print information about the joysticks */ - SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks()); - for (i = 0; i < SDL_NumJoysticks(); ++i) { - name = SDL_JoystickNameForIndex(i); - SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); - joystick = SDL_JoystickOpen(i); - if (joystick == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i, - SDL_GetError()); - } else { - char guid[64]; - SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), - guid, sizeof (guid)); - SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick)); - SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick)); - SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick)); - SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joystick)); - SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick)); - SDL_Log(" guid: %s\n", guid); - SDL_JoystickClose(joystick); - } - } - -#ifdef __ANDROID__ - if (SDL_NumJoysticks() > 0) { -#else - if (argv[1]) { -#endif - SDL_bool reportederror = SDL_FALSE; - SDL_bool keepGoing = SDL_TRUE; - SDL_Event event; - int device; -#ifdef __ANDROID__ - device = 0; -#else - device = atoi(argv[1]); -#endif - joystick = SDL_JoystickOpen(device); - - while ( keepGoing ) { - if (joystick == NULL) { - if ( !reportederror ) { - SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError()); - keepGoing = SDL_FALSE; - reportederror = SDL_TRUE; - } - } else { - reportederror = SDL_FALSE; - keepGoing = WatchJoystick(joystick); - SDL_JoystickClose(joystick); - } - - joystick = NULL; - if (keepGoing) { - SDL_Log("Waiting for attach\n"); - } - while (keepGoing) { - SDL_WaitEvent(&event); - if ((event.type == SDL_QUIT) || (event.type == SDL_FINGERDOWN) - || (event.type == SDL_MOUSEBUTTONDOWN)) { - keepGoing = SDL_FALSE; - } else if (event.type == SDL_JOYDEVICEADDED) { - joystick = SDL_JoystickOpen(device); - break; - } - } - } - } - else { - SDL_Log("\n\nUsage: ./controllermap number\nFor example: ./controllermap 0\nOr: ./controllermap 0 >> gamecontrollerdb.txt"); - } - SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); - - return 0; -} - -#else - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n"); - exit(1); -} - -#endif diff --git a/3rdparty/SDL2/test/emscripten/joystick-pre.js b/3rdparty/SDL2/test/emscripten/joystick-pre.js deleted file mode 100644 index 5fd789d1f73..00000000000 --- a/3rdparty/SDL2/test/emscripten/joystick-pre.js +++ /dev/null @@ -1,25 +0,0 @@ -Module['arguments'] = ['0']; -//Gamepads don't appear until a button is pressed and the joystick/gamepad tests expect one to be connected -Module['preRun'].push(function() -{ - Module['print']("Waiting for gamepad..."); - Module['addRunDependency']("gamepad"); - window.addEventListener('gamepadconnected', function() - { - //OK, got one - Module['removeRunDependency']("gamepad"); - }, false); - - //chrome - if(!!navigator.webkitGetGamepads) - { - var timeout = function() - { - if(navigator.webkitGetGamepads()[0] !== undefined) - Module['removeRunDependency']("gamepad"); - else - setTimeout(timeout, 100); - } - setTimeout(timeout, 100); - } -}); diff --git a/3rdparty/SDL2/test/gcc-fat.sh b/3rdparty/SDL2/test/gcc-fat.sh deleted file mode 100644 index 44d37ffdef8..00000000000 --- a/3rdparty/SDL2/test/gcc-fat.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh -# -# Build Universal binaries on Mac OS X, thanks Ryan! -# -# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf ppc x86 - -# PowerPC compiler flags (10.2 runtime compatibility) -GCC_COMPILE_PPC="gcc-3.3 -arch ppc \ --DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \ --nostdinc \ --F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ --I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \ --isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include" - -GCC_LINK_PPC="\ --L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \ --F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ --Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.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/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \ --I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \ --isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include" - -GCC_LINK_X86="\ --L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \ --Wl,-syslibroot,/Developer/SDKs/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/3rdparty/SDL2/test/icon.bmp b/3rdparty/SDL2/test/icon.bmp Binary files differdeleted file mode 100644 index cc96356acb5..00000000000 --- a/3rdparty/SDL2/test/icon.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/loopwave.c b/3rdparty/SDL2/test/loopwave.c deleted file mode 100644 index ec9f528191e..00000000000 --- a/3rdparty/SDL2/test/loopwave.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Program to load a wave file and loop playing it using SDL audio */ - -/* 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 - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL.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; -} - -#ifdef __EMSCRIPTEN__ -void -loop() -{ - if(done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)) - emscripten_cancel_main_loop(); -} -#endif - -int -main(int argc, char *argv[]) -{ - int i; - char filename[4096]; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_AUDIO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - if (argc > 1) { - SDL_strlcpy(filename, argv[1], sizeof(filename)); - } else { - SDL_strlcpy(filename, "sample.wav", sizeof(filename)); - } - /* Load the wave file into memory */ - if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, 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 */ - - /* Show the list of available drivers */ - SDL_Log("Available audio drivers:"); - for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { - SDL_Log("%i: %s", i, SDL_GetAudioDriver(i)); - } - - /* Initialize fillerup() variables */ - if (SDL_OpenAudio(&wave.spec, NULL) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); - SDL_FreeWAV(wave.sound); - quit(2); - } - - SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); - - /* Let the audio run */ - SDL_PauseAudio(0); - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) - SDL_Delay(1000); -#endif - - /* Clean up on signal */ - SDL_CloseAudio(); - SDL_FreeWAV(wave.sound); - SDL_Quit(); - return (0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/loopwavequeue.c b/3rdparty/SDL2/test/loopwavequeue.c deleted file mode 100644 index 85f5bd57934..00000000000 --- a/3rdparty/SDL2/test/loopwavequeue.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Program to load a wave file and loop playing it using SDL sound queueing */ - -#include <stdio.h> -#include <stdlib.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL.h" - -#if HAVE_SIGNAL_H -#include <signal.h> -#endif - -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); -} - -static int done = 0; -void -poked(int sig) -{ - done = 1; -} - -void -loop() -{ -#ifdef __EMSCRIPTEN__ - if (done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)) { - emscripten_cancel_main_loop(); - } - else -#endif - { - /* The device from SDL_OpenAudio() is always device #1. */ - const Uint32 queued = SDL_GetQueuedAudioSize(1); - SDL_Log("Device has %u bytes queued.\n", (unsigned int) queued); - if (queued <= 8192) { /* time to requeue the whole thing? */ - if (SDL_QueueAudio(1, wave.sound, wave.soundlen) == 0) { - SDL_Log("Device queued %u more bytes.\n", (unsigned int) wave.soundlen); - } else { - SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int) wave.soundlen, SDL_GetError()); - } - } - } -} - -int -main(int argc, char *argv[]) -{ - char filename[4096]; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_AUDIO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - if (argc > 1) { - SDL_strlcpy(filename, argv[1], sizeof(filename)); - } else { - SDL_strlcpy(filename, "sample.wav", sizeof(filename)); - } - /* Load the wave file into memory */ - if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); - quit(1); - } - - wave.spec.callback = NULL; /* we'll push audio. */ - -#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) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); - SDL_FreeWAV(wave.sound); - quit(2); - } - - /*static x[99999]; SDL_QueueAudio(1, x, sizeof (x));*/ - - /* Let the audio run */ - SDL_PauseAudio(0); - - done = 0; - - /* Note that we stuff the entire audio buffer into the queue in one - shot. Most apps would want to feed it a little at a time, as it - plays, but we're going for simplicity here. */ - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) - { - loop(); - - SDL_Delay(100); /* let it play for awhile. */ - } -#endif - - /* Clean up on signal */ - SDL_CloseAudio(); - SDL_FreeWAV(wave.sound); - SDL_Quit(); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/moose.dat b/3rdparty/SDL2/test/moose.dat Binary files differdeleted file mode 100644 index 10530046fd7..00000000000 --- a/3rdparty/SDL2/test/moose.dat +++ /dev/null diff --git a/3rdparty/SDL2/test/nacl/Makefile b/3rdparty/SDL2/test/nacl/Makefile deleted file mode 100644 index 9ca166c1274..00000000000 --- a/3rdparty/SDL2/test/nacl/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# GNU Makefile based on shared rules provided by the Native Client SDK. -# See README.Makefiles for more details. - -VALID_TOOLCHAINS := pnacl - -# NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../../..) -include $(NACL_SDK_ROOT)/tools/common.mk - - -TARGET = sdl_app -DEPS = ppapi_simple nacl_io -# ppapi_simple and SDL2 end up being listed twice due to dependency solving issues -- Gabriel -LIBS = SDL2_test SDL2 ppapi_simple SDL2main SDL2 $(DEPS) ppapi_gles2 ppapi_cpp ppapi pthread - -CFLAGS := -Wall -SOURCES ?= testgles2.c - -# Build rules generated by macros from common.mk: -# Overriden macro from NACL SDK to be able to customize the library search path -- Gabriel -# Specific Link Macro -# -# $1 = Target Name -# $2 = List of inputs -# $3 = List of libs -# $4 = List of deps -# $5 = List of lib dirs -# $6 = Other Linker Args -# -# For debugging, we translate the pre-finalized .bc file. -# -define LINKER_RULE -all: $(1).pexe -$(1)_x86_32.nexe : $(1).bc - $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-32 $$^ -o $$@) - -$(1)_x86_64.nexe : $(1).bc - $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-64 $$^ -o $$@) - -$(1)_arm.nexe : $(1).bc - $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch arm $$^ -o $$@) - -$(1).pexe: $(1).bc - $(call LOG,FINALIZE,$$@,$(PNACL_FINALIZE) -o $$@ $$^) - -$(1).bc: $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) - $(call LOG,LINK,$$@,$(PNACL_LINK) -o $$@ $(2) $(PNACL_LDFLAGS) $(foreach path,$(5),-L$(path)/pnacl/$(CONFIG)) -L./lib $(foreach lib,$(3),-l$(lib)) $(6)) -endef - -$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep)))) -$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) - -ifeq ($(CONFIG),Release) -$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS))) -$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) -else -$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) -endif - -$(eval $(call NMF_RULE,$(TARGET),)) diff --git a/3rdparty/SDL2/test/nacl/background.js b/3rdparty/SDL2/test/nacl/background.js deleted file mode 100644 index 5c3b1b7c94d..00000000000 --- a/3rdparty/SDL2/test/nacl/background.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -function makeURL(toolchain, config) { - return 'index.html?tc=' + toolchain + '&config=' + config; -} - -function createWindow(url) { - console.log('loading ' + url); - chrome.app.window.create(url, { - width: 1024, - height: 800, - frame: 'none' - }); -} - -function onLaunched(launchData) { - // Send and XHR to get the URL to load from a configuration file. - // Normally you won't need to do this; just call: - // - // chrome.app.window.create('<your url>', {...}); - // - // In the SDK we want to be able to load different URLs (for different - // toolchain/config combinations) from the commandline, so we to read - // this information from the file "run_package_config". - var xhr = new XMLHttpRequest(); - xhr.open('GET', 'run_package_config', true); - xhr.onload = function() { - var toolchain_config = this.responseText.split(' '); - createWindow(makeURL.apply(null, toolchain_config)); - }; - xhr.onerror = function() { - // Can't find the config file, just load the default. - createWindow('index.html'); - }; - xhr.send(); -} - -chrome.app.runtime.onLaunched.addListener(onLaunched); diff --git a/3rdparty/SDL2/test/nacl/common.js b/3rdparty/SDL2/test/nacl/common.js deleted file mode 100644 index a108fad329a..00000000000 --- a/3rdparty/SDL2/test/nacl/common.js +++ /dev/null @@ -1,469 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Set to true when the Document is loaded IFF "test=true" is in the query -// string. -var isTest = false; - -// Set to true when loading a "Release" NaCl module, false when loading a -// "Debug" NaCl module. -var isRelease = true; - -// Javascript module pattern: -// see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces -// In essence, we define an anonymous function which is immediately called and -// returns a new object. The new object contains only the exported definitions; -// all other definitions in the anonymous function are inaccessible to external -// code. -var common = (function() { - - function isHostToolchain(tool) { - return tool == 'win' || tool == 'linux' || tool == 'mac'; - } - - /** - * Return the mime type for NaCl plugin. - * - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @return {string} The mime-type for the kind of NaCl plugin matching - * the given toolchain. - */ - function mimeTypeForTool(tool) { - // For NaCl modules use application/x-nacl. - var mimetype = 'application/x-nacl'; - if (isHostToolchain(tool)) { - // For non-NaCl PPAPI plugins use the x-ppapi-debug/release - // mime type. - if (isRelease) - mimetype = 'application/x-ppapi-release'; - else - mimetype = 'application/x-ppapi-debug'; - } else if (tool == 'pnacl' && isRelease) { - mimetype = 'application/x-pnacl'; - } - return mimetype; - } - - /** - * Check if the browser supports NaCl plugins. - * - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @return {bool} True if the browser supports the type of NaCl plugin - * produced by the given toolchain. - */ - function browserSupportsNaCl(tool) { - // Assume host toolchains always work with the given browser. - // The below mime-type checking might not work with - // --register-pepper-plugins. - if (isHostToolchain(tool)) { - return true; - } - var mimetype = mimeTypeForTool(tool); - return navigator.mimeTypes[mimetype] !== undefined; - } - - /** - * Inject a script into the DOM, and call a callback when it is loaded. - * - * @param {string} url The url of the script to load. - * @param {Function} onload The callback to call when the script is loaded. - * @param {Function} onerror The callback to call if the script fails to load. - */ - function injectScript(url, onload, onerror) { - var scriptEl = document.createElement('script'); - scriptEl.type = 'text/javascript'; - scriptEl.src = url; - scriptEl.onload = onload; - if (onerror) { - scriptEl.addEventListener('error', onerror, false); - } - document.head.appendChild(scriptEl); - } - - /** - * Run all tests for this example. - * - * @param {Object} moduleEl The module DOM element. - */ - function runTests(moduleEl) { - console.log('runTests()'); - common.tester = new Tester(); - - // All NaCl SDK examples are OK if the example exits cleanly; (i.e. the - // NaCl module returns 0 or calls exit(0)). - // - // Without this exception, the browser_tester thinks that the module - // has crashed. - common.tester.exitCleanlyIsOK(); - - common.tester.addAsyncTest('loaded', function(test) { - test.pass(); - }); - - if (typeof window.addTests !== 'undefined') { - window.addTests(); - } - - common.tester.waitFor(moduleEl); - common.tester.run(); - } - - /** - * Create the Native Client <embed> element as a child of the DOM element - * named "listener". - * - * @param {string} name The name of the example. - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @param {string} path Directory name where .nmf file can be found. - * @param {number} width The width to create the plugin. - * @param {number} height The height to create the plugin. - * @param {Object} attrs Dictionary of attributes to set on the module. - */ - function createNaClModule(name, tool, path, width, height, attrs) { - var moduleEl = document.createElement('embed'); - moduleEl.setAttribute('name', 'nacl_module'); - moduleEl.setAttribute('id', 'nacl_module'); - moduleEl.setAttribute('width', width); - moduleEl.setAttribute('height', height); - moduleEl.setAttribute('path', path); - moduleEl.setAttribute('src', path + '/' + name + '.nmf'); - - // Add any optional arguments - if (attrs) { - for (var key in attrs) { - moduleEl.setAttribute(key, attrs[key]); - } - } - - var mimetype = mimeTypeForTool(tool); - moduleEl.setAttribute('type', mimetype); - - // The <EMBED> element is wrapped inside a <DIV>, which has both a 'load' - // and a 'message' event listener attached. This wrapping method is used - // instead of attaching the event listeners directly to the <EMBED> element - // to ensure that the listeners are active before the NaCl module 'load' - // event fires. - var listenerDiv = document.getElementById('listener'); - listenerDiv.appendChild(moduleEl); - - // Host plugins don't send a moduleDidLoad message. We'll fake it here. - var isHost = isHostToolchain(tool); - if (isHost) { - window.setTimeout(function() { - moduleEl.readyState = 1; - moduleEl.dispatchEvent(new CustomEvent('loadstart')); - moduleEl.readyState = 4; - moduleEl.dispatchEvent(new CustomEvent('load')); - moduleEl.dispatchEvent(new CustomEvent('loadend')); - }, 100); // 100 ms - } - - // This is code that is only used to test the SDK. - if (isTest) { - var loadNaClTest = function() { - injectScript('nacltest.js', function() { - runTests(moduleEl); - }); - }; - - // Try to load test.js for the example. Whether or not it exists, load - // nacltest.js. - injectScript('test.js', loadNaClTest, loadNaClTest); - } - } - - /** - * Add the default "load" and "message" event listeners to the element with - * id "listener". - * - * The "load" event is sent when the module is successfully loaded. The - * "message" event is sent when the naclModule posts a message using - * PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in - * C++). - */ - function attachDefaultListeners() { - var listenerDiv = document.getElementById('listener'); - listenerDiv.addEventListener('load', moduleDidLoad, true); - listenerDiv.addEventListener('message', handleMessage, true); - listenerDiv.addEventListener('error', handleError, true); - listenerDiv.addEventListener('crash', handleCrash, true); - if (typeof window.attachListeners !== 'undefined') { - window.attachListeners(); - } - } - - /** - * Called when the NaCl module fails to load. - * - * This event listener is registered in createNaClModule above. - */ - function handleError(event) { - // We can't use common.naclModule yet because the module has not been - // loaded. - var moduleEl = document.getElementById('nacl_module'); - updateStatus('ERROR [' + moduleEl.lastError + ']'); - } - - /** - * Called when the Browser can not communicate with the Module - * - * This event listener is registered in attachDefaultListeners above. - */ - function handleCrash(event) { - if (common.naclModule.exitStatus == -1) { - updateStatus('CRASHED'); - } else { - updateStatus('EXITED [' + common.naclModule.exitStatus + ']'); - } - if (typeof window.handleCrash !== 'undefined') { - window.handleCrash(common.naclModule.lastError); - } - } - - /** - * Called when the NaCl module is loaded. - * - * This event listener is registered in attachDefaultListeners above. - */ - function moduleDidLoad() { - common.naclModule = document.getElementById('nacl_module'); - updateStatus('RUNNING'); - - if (typeof window.moduleDidLoad !== 'undefined') { - window.moduleDidLoad(); - } - } - - /** - * Hide the NaCl module's embed element. - * - * We don't want to hide by default; if we do, it is harder to determine that - * a plugin failed to load. Instead, call this function inside the example's - * "moduleDidLoad" function. - * - */ - function hideModule() { - // Setting common.naclModule.style.display = "None" doesn't work; the - // module will no longer be able to receive postMessages. - common.naclModule.style.height = '0'; - } - - /** - * Remove the NaCl module from the page. - */ - function removeModule() { - common.naclModule.parentNode.removeChild(common.naclModule); - common.naclModule = null; - } - - /** - * Return true when |s| starts with the string |prefix|. - * - * @param {string} s The string to search. - * @param {string} prefix The prefix to search for in |s|. - */ - function startsWith(s, prefix) { - // indexOf would search the entire string, lastIndexOf(p, 0) only checks at - // the first index. See: http://stackoverflow.com/a/4579228 - return s.lastIndexOf(prefix, 0) === 0; - } - - /** Maximum length of logMessageArray. */ - var kMaxLogMessageLength = 20; - - /** An array of messages to display in the element with id "log". */ - var logMessageArray = []; - - /** - * Add a message to an element with id "log". - * - * This function is used by the default "log:" message handler. - * - * @param {string} message The message to log. - */ - function logMessage(message) { - logMessageArray.push(message); - if (logMessageArray.length > kMaxLogMessageLength) - logMessageArray.shift(); - - document.getElementById('log').textContent = logMessageArray.join('\n'); - console.log(message); - } - - /** - */ - var defaultMessageTypes = { - 'alert': alert, - 'log': logMessage - }; - - /** - * Called when the NaCl module sends a message to JavaScript (via - * PPB_Messaging.PostMessage()) - * - * This event listener is registered in createNaClModule above. - * - * @param {Event} message_event A message event. message_event.data contains - * the data sent from the NaCl module. - */ - function handleMessage(message_event) { - if (typeof message_event.data === 'string') { - for (var type in defaultMessageTypes) { - if (defaultMessageTypes.hasOwnProperty(type)) { - if (startsWith(message_event.data, type + ':')) { - func = defaultMessageTypes[type]; - func(message_event.data.slice(type.length + 1)); - return; - } - } - } - } - - if (typeof window.handleMessage !== 'undefined') { - window.handleMessage(message_event); - return; - } - - logMessage('Unhandled message: ' + message_event.data); - } - - /** - * Called when the DOM content has loaded; i.e. the page's document is fully - * parsed. At this point, we can safely query any elements in the document via - * document.querySelector, document.getElementById, etc. - * - * @param {string} name The name of the example. - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @param {string} path Directory name where .nmf file can be found. - * @param {number} width The width to create the plugin. - * @param {number} height The height to create the plugin. - * @param {Object} attrs Optional dictionary of additional attributes. - */ - function domContentLoaded(name, tool, path, width, height, attrs) { - // If the page loads before the Native Client module loads, then set the - // status message indicating that the module is still loading. Otherwise, - // do not change the status message. - updateStatus('Page loaded.'); - if (!browserSupportsNaCl(tool)) { - updateStatus( - 'Browser does not support NaCl (' + tool + '), or NaCl is disabled'); - } else if (common.naclModule == null) { - updateStatus('Creating embed: ' + tool); - - // We use a non-zero sized embed to give Chrome space to place the bad - // plug-in graphic, if there is a problem. - width = typeof width !== 'undefined' ? width : 200; - height = typeof height !== 'undefined' ? height : 200; - attachDefaultListeners(); - createNaClModule(name, tool, path, width, height, attrs); - } else { - // It's possible that the Native Client module onload event fired - // before the page's onload event. In this case, the status message - // will reflect 'SUCCESS', but won't be displayed. This call will - // display the current message. - updateStatus('Waiting.'); - } - } - - /** Saved text to display in the element with id 'statusField'. */ - var statusText = 'NO-STATUSES'; - - /** - * Set the global status message. If the element with id 'statusField' - * exists, then set its HTML to the status message as well. - * - * @param {string} opt_message The message to set. If null or undefined, then - * set element 'statusField' to the message from the last call to - * updateStatus. - */ - function updateStatus(opt_message) { - if (opt_message) { - statusText = opt_message; - } - var statusField = document.getElementById('statusField'); - if (statusField) { - statusField.innerHTML = statusText; - } - } - - // The symbols to export. - return { - /** A reference to the NaCl module, once it is loaded. */ - naclModule: null, - - attachDefaultListeners: attachDefaultListeners, - domContentLoaded: domContentLoaded, - createNaClModule: createNaClModule, - hideModule: hideModule, - removeModule: removeModule, - logMessage: logMessage, - updateStatus: updateStatus - }; - -}()); - -// Listen for the DOM content to be loaded. This event is fired when parsing of -// the page's document has finished. -document.addEventListener('DOMContentLoaded', function() { - var body = document.body; - - // The data-* attributes on the body can be referenced via body.dataset. - if (body.dataset) { - var loadFunction; - if (!body.dataset.customLoad) { - loadFunction = common.domContentLoaded; - } else if (typeof window.domContentLoaded !== 'undefined') { - loadFunction = window.domContentLoaded; - } - - // From https://developer.mozilla.org/en-US/docs/DOM/window.location - var searchVars = {}; - if (window.location.search.length > 1) { - var pairs = window.location.search.substr(1).split('&'); - for (var key_ix = 0; key_ix < pairs.length; key_ix++) { - var keyValue = pairs[key_ix].split('='); - searchVars[unescape(keyValue[0])] = - keyValue.length > 1 ? unescape(keyValue[1]) : ''; - } - } - - if (loadFunction) { - var toolchains = body.dataset.tools.split(' '); - var configs = body.dataset.configs.split(' '); - - var attrs = {}; - if (body.dataset.attrs) { - var attr_list = body.dataset.attrs.split(' '); - for (var key in attr_list) { - var attr = attr_list[key].split('='); - var key = attr[0]; - var value = attr[1]; - attrs[key] = value; - } - } - - var tc = toolchains.indexOf(searchVars.tc) !== -1 ? - searchVars.tc : toolchains[0]; - - // If the config value is included in the search vars, use that. - // Otherwise default to Release if it is valid, or the first value if - // Release is not valid. - if (configs.indexOf(searchVars.config) !== -1) - var config = searchVars.config; - else if (configs.indexOf('Release') !== -1) - var config = 'Release'; - else - var config = configs[0]; - - var pathFormat = body.dataset.path; - var path = pathFormat.replace('{tc}', tc).replace('{config}', config); - - isTest = searchVars.test === 'true'; - isRelease = path.toLowerCase().indexOf('release') != -1; - - loadFunction(body.dataset.name, tc, path, body.dataset.width, - body.dataset.height, attrs); - } - } -}); diff --git a/3rdparty/SDL2/test/nacl/index.html b/3rdparty/SDL2/test/nacl/index.html deleted file mode 100644 index 4695b7e9c02..00000000000 --- a/3rdparty/SDL2/test/nacl/index.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<head> - <meta http-equiv="Pragma" content="no-cache"> - <meta http-equiv="Expires" content="-1"> - <title>SDL NACL Test</title> - <script type="text/javascript" src="common.js"></script> -</head> -<body data-width="640" data-height="640" data-name="sdl_app" data-tools="pnacl" data-configs="Debug Release" data-path="{tc}/{config}"> - <h1>SDL NACL Test</h1> - <h2>Status: <code id="statusField">NO-STATUS</code></h2> - <!-- The NaCl plugin will be embedded inside the element with id "listener". - See common.js.--> - <div id="listener"></div> -</body> -</html> diff --git a/3rdparty/SDL2/test/nacl/manifest.json b/3rdparty/SDL2/test/nacl/manifest.json deleted file mode 100644 index df6772b4c49..00000000000 --- a/3rdparty/SDL2/test/nacl/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "SDL testgles2", - "version": "33.0.1750.117", - "minimum_chrome_version": "33.0.1750.117", - "manifest_version": 2, - "description": "testgles2", - "offline_enabled": true, - "icons": { - "128": "icon128.png" - }, - "app": { - "background": { - "scripts": ["background.js"] - } - }, - "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMN716Qyu0l2EHNFqIJVqVysFcTR6urqhaGGqW4UK7slBaURz9+Sb1b4Ot5P1uQNE5c+CTU5Vu61wpqmSqMMxqHLWdPPMh8uRlyctsb2cxWwG6XoGSvpX29NsQVUFXd4v2tkJm3G9t+V0X8TYskrvWQmnyOW8OEIDvrBhUEfFxWQIDAQAB", - "oauth2": { - "client_id": "903965034255.apps.googleusercontent.com", - "scopes": ["https://www.googleapis.com/auth/drive"] - }, - "permissions": [] -} diff --git a/3rdparty/SDL2/test/picture.xbm b/3rdparty/SDL2/test/picture.xbm deleted file mode 100644 index c873a60a183..00000000000 --- a/3rdparty/SDL2/test/picture.xbm +++ /dev/null @@ -1,14 +0,0 @@ -#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/3rdparty/SDL2/test/relative_mode.markdown b/3rdparty/SDL2/test/relative_mode.markdown deleted file mode 100644 index 5b2ed61850f..00000000000 --- a/3rdparty/SDL2/test/relative_mode.markdown +++ /dev/null @@ -1,58 +0,0 @@ -Relative mode testing -===================== - -See test program at the bottom of this file. - -Initial tests: - - - When in relative mode, the mouse shouldn't be moveable outside of the window. - - When the cursor is outside the window when relative mode is enabled, mouse - clicks should not go to whatever app was under the cursor previously. - - When alt/cmd-tabbing between a relative mode app and another app, clicks when - in the relative mode app should also not go to whatever app was under the - cursor previously. - - -Code -==== - - #include <SDL.h> - - int PollEvents() - { - SDL_Event event; - while (SDL_PollEvent(&event)) - { - switch (event.type) - { - case SDL_QUIT: - return 1; - default: - break; - } - } - - return 0; - } - - int main(int argc, char *argv[]) - { - SDL_Window *win; - - SDL_Init(SDL_INIT_VIDEO); - - win = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0); - SDL_SetRelativeMouseMode(SDL_TRUE); - - while (1) - { - if (PollEvents()) - break; - } - - SDL_DestroyWindow(win); - - SDL_Quit(); - - return 0; - } diff --git a/3rdparty/SDL2/test/sample.bmp b/3rdparty/SDL2/test/sample.bmp Binary files differdeleted file mode 100644 index aca8bbca6e0..00000000000 --- a/3rdparty/SDL2/test/sample.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/sample.wav b/3rdparty/SDL2/test/sample.wav Binary files differdeleted file mode 100644 index 002f8158151..00000000000 --- a/3rdparty/SDL2/test/sample.wav +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p01_shape24.bmp b/3rdparty/SDL2/test/shapes/p01_shape24.bmp Binary files differdeleted file mode 100644 index 290e93d9c75..00000000000 --- a/3rdparty/SDL2/test/shapes/p01_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p01_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p01_shape32alpha.bmp Binary files differdeleted file mode 100644 index a1b8d956190..00000000000 --- a/3rdparty/SDL2/test/shapes/p01_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p01_shape8.bmp b/3rdparty/SDL2/test/shapes/p01_shape8.bmp Binary files differdeleted file mode 100644 index 5adca298f71..00000000000 --- a/3rdparty/SDL2/test/shapes/p01_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p02_shape24.bmp b/3rdparty/SDL2/test/shapes/p02_shape24.bmp Binary files differdeleted file mode 100644 index 61e411bb774..00000000000 --- a/3rdparty/SDL2/test/shapes/p02_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p02_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p02_shape32alpha.bmp Binary files differdeleted file mode 100644 index 6497a7b0d82..00000000000 --- a/3rdparty/SDL2/test/shapes/p02_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p02_shape8.bmp b/3rdparty/SDL2/test/shapes/p02_shape8.bmp Binary files differdeleted file mode 100644 index 8ad7c9ac8be..00000000000 --- a/3rdparty/SDL2/test/shapes/p02_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p03_shape24.bmp b/3rdparty/SDL2/test/shapes/p03_shape24.bmp Binary files differdeleted file mode 100644 index e2378679fa5..00000000000 --- a/3rdparty/SDL2/test/shapes/p03_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p03_shape8.bmp b/3rdparty/SDL2/test/shapes/p03_shape8.bmp Binary files differdeleted file mode 100644 index 28f8800f63d..00000000000 --- a/3rdparty/SDL2/test/shapes/p03_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p04_shape1.bmp b/3rdparty/SDL2/test/shapes/p04_shape1.bmp Binary files differdeleted file mode 100644 index ad288ace530..00000000000 --- a/3rdparty/SDL2/test/shapes/p04_shape1.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p04_shape24.bmp b/3rdparty/SDL2/test/shapes/p04_shape24.bmp Binary files differdeleted file mode 100644 index 8cf61298637..00000000000 --- a/3rdparty/SDL2/test/shapes/p04_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p04_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p04_shape32alpha.bmp Binary files differdeleted file mode 100644 index 771ebc05337..00000000000 --- a/3rdparty/SDL2/test/shapes/p04_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p04_shape8.bmp b/3rdparty/SDL2/test/shapes/p04_shape8.bmp Binary files differdeleted file mode 100644 index 29d50316832..00000000000 --- a/3rdparty/SDL2/test/shapes/p04_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p05_shape8.bmp b/3rdparty/SDL2/test/shapes/p05_shape8.bmp Binary files differdeleted file mode 100644 index e2d62a53d45..00000000000 --- a/3rdparty/SDL2/test/shapes/p05_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p06_shape1alpha.bmp b/3rdparty/SDL2/test/shapes/p06_shape1alpha.bmp Binary files differdeleted file mode 100644 index 1ca14f11db9..00000000000 --- a/3rdparty/SDL2/test/shapes/p06_shape1alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p06_shape24.bmp b/3rdparty/SDL2/test/shapes/p06_shape24.bmp Binary files differdeleted file mode 100644 index 4cc257688f1..00000000000 --- a/3rdparty/SDL2/test/shapes/p06_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p06_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p06_shape32alpha.bmp Binary files differdeleted file mode 100644 index 04afd793cdd..00000000000 --- a/3rdparty/SDL2/test/shapes/p06_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p06_shape8.bmp b/3rdparty/SDL2/test/shapes/p06_shape8.bmp Binary files differdeleted file mode 100644 index 017c1ed776f..00000000000 --- a/3rdparty/SDL2/test/shapes/p06_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p07_shape24.bmp b/3rdparty/SDL2/test/shapes/p07_shape24.bmp Binary files differdeleted file mode 100644 index fa8012cae8c..00000000000 --- a/3rdparty/SDL2/test/shapes/p07_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p07_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p07_shape32alpha.bmp Binary files differdeleted file mode 100644 index d2376666de2..00000000000 --- a/3rdparty/SDL2/test/shapes/p07_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p07_shape8.bmp b/3rdparty/SDL2/test/shapes/p07_shape8.bmp Binary files differdeleted file mode 100644 index 9aeaa0810fc..00000000000 --- a/3rdparty/SDL2/test/shapes/p07_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p08_shape24.bmp b/3rdparty/SDL2/test/shapes/p08_shape24.bmp Binary files differdeleted file mode 100644 index 332f8634999..00000000000 --- a/3rdparty/SDL2/test/shapes/p08_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p08_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p08_shape32alpha.bmp Binary files differdeleted file mode 100644 index 4d1d25e9ff4..00000000000 --- a/3rdparty/SDL2/test/shapes/p08_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p08_shape8.bmp b/3rdparty/SDL2/test/shapes/p08_shape8.bmp Binary files differdeleted file mode 100644 index 920f9070ee0..00000000000 --- a/3rdparty/SDL2/test/shapes/p08_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p09_shape24.bmp b/3rdparty/SDL2/test/shapes/p09_shape24.bmp Binary files differdeleted file mode 100644 index e5a7c0043d9..00000000000 --- a/3rdparty/SDL2/test/shapes/p09_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p09_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p09_shape32alpha.bmp Binary files differdeleted file mode 100644 index 250d267d149..00000000000 --- a/3rdparty/SDL2/test/shapes/p09_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p09_shape8.bmp b/3rdparty/SDL2/test/shapes/p09_shape8.bmp Binary files differdeleted file mode 100644 index 4d1cd014ec3..00000000000 --- a/3rdparty/SDL2/test/shapes/p09_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p10_shape1.bmp b/3rdparty/SDL2/test/shapes/p10_shape1.bmp Binary files differdeleted file mode 100644 index 42b5a7f3474..00000000000 --- a/3rdparty/SDL2/test/shapes/p10_shape1.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p10_shape24.bmp b/3rdparty/SDL2/test/shapes/p10_shape24.bmp Binary files differdeleted file mode 100644 index bc1faf4e7b4..00000000000 --- a/3rdparty/SDL2/test/shapes/p10_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p10_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p10_shape32alpha.bmp Binary files differdeleted file mode 100644 index 4330e44548b..00000000000 --- a/3rdparty/SDL2/test/shapes/p10_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p10_shape8.bmp b/3rdparty/SDL2/test/shapes/p10_shape8.bmp Binary files differdeleted file mode 100644 index 64fb5c37206..00000000000 --- a/3rdparty/SDL2/test/shapes/p10_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p11_shape24.bmp b/3rdparty/SDL2/test/shapes/p11_shape24.bmp Binary files differdeleted file mode 100644 index 65353078622..00000000000 --- a/3rdparty/SDL2/test/shapes/p11_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p11_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p11_shape32alpha.bmp Binary files differdeleted file mode 100644 index 406d20a815e..00000000000 --- a/3rdparty/SDL2/test/shapes/p11_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p11_shape8.bmp b/3rdparty/SDL2/test/shapes/p11_shape8.bmp Binary files differdeleted file mode 100644 index 36f1ba2c6b3..00000000000 --- a/3rdparty/SDL2/test/shapes/p11_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p12_shape24.bmp b/3rdparty/SDL2/test/shapes/p12_shape24.bmp Binary files differdeleted file mode 100644 index 582cf994e2e..00000000000 --- a/3rdparty/SDL2/test/shapes/p12_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p12_shape8.bmp b/3rdparty/SDL2/test/shapes/p12_shape8.bmp Binary files differdeleted file mode 100644 index 59377200bbd..00000000000 --- a/3rdparty/SDL2/test/shapes/p12_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p13_shape24.bmp b/3rdparty/SDL2/test/shapes/p13_shape24.bmp Binary files differdeleted file mode 100644 index 70215db590c..00000000000 --- a/3rdparty/SDL2/test/shapes/p13_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p13_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p13_shape32alpha.bmp Binary files differdeleted file mode 100644 index b656da8165c..00000000000 --- a/3rdparty/SDL2/test/shapes/p13_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p13_shape8.bmp b/3rdparty/SDL2/test/shapes/p13_shape8.bmp Binary files differdeleted file mode 100644 index 822b896e1c7..00000000000 --- a/3rdparty/SDL2/test/shapes/p13_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p14_shape24.bmp b/3rdparty/SDL2/test/shapes/p14_shape24.bmp Binary files differdeleted file mode 100644 index ae83f5a8ce0..00000000000 --- a/3rdparty/SDL2/test/shapes/p14_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p14_shape8.bmp b/3rdparty/SDL2/test/shapes/p14_shape8.bmp Binary files differdeleted file mode 100644 index d6f981f58ad..00000000000 --- a/3rdparty/SDL2/test/shapes/p14_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p15_shape24.bmp b/3rdparty/SDL2/test/shapes/p15_shape24.bmp Binary files differdeleted file mode 100644 index 33b99588e44..00000000000 --- a/3rdparty/SDL2/test/shapes/p15_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p15_shape32alpha.bmp b/3rdparty/SDL2/test/shapes/p15_shape32alpha.bmp Binary files differdeleted file mode 100644 index 6954a5d91c4..00000000000 --- a/3rdparty/SDL2/test/shapes/p15_shape32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p15_shape8.bmp b/3rdparty/SDL2/test/shapes/p15_shape8.bmp Binary files differdeleted file mode 100644 index ada5aefb83d..00000000000 --- a/3rdparty/SDL2/test/shapes/p15_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p16_shape1.bmp b/3rdparty/SDL2/test/shapes/p16_shape1.bmp Binary files differdeleted file mode 100644 index 5b3f5509ba2..00000000000 --- a/3rdparty/SDL2/test/shapes/p16_shape1.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p16_shape24.bmp b/3rdparty/SDL2/test/shapes/p16_shape24.bmp Binary files differdeleted file mode 100644 index 1f2a1d230c0..00000000000 --- a/3rdparty/SDL2/test/shapes/p16_shape24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/p16_shape8.bmp b/3rdparty/SDL2/test/shapes/p16_shape8.bmp Binary files differdeleted file mode 100644 index 0b4d4221c5c..00000000000 --- a/3rdparty/SDL2/test/shapes/p16_shape8.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/trollface_24.bmp b/3rdparty/SDL2/test/shapes/trollface_24.bmp Binary files differdeleted file mode 100644 index e18c2c2ad12..00000000000 --- a/3rdparty/SDL2/test/shapes/trollface_24.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/shapes/trollface_32alpha.bmp b/3rdparty/SDL2/test/shapes/trollface_32alpha.bmp Binary files differdeleted file mode 100644 index ee3ecf9be4c..00000000000 --- a/3rdparty/SDL2/test/shapes/trollface_32alpha.bmp +++ /dev/null diff --git a/3rdparty/SDL2/test/testatomic.c b/3rdparty/SDL2/test/testatomic.c deleted file mode 100644 index d371ef31fa7..00000000000 --- a/3rdparty/SDL2/test/testatomic.c +++ /dev/null @@ -1,724 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include <stdio.h> - -#include "SDL.h" - -/* - Absolutely basic tests just to see if we get the expected value - after calling each function. -*/ - -static -char * -tf(SDL_bool tf) -{ - static char *t = "TRUE"; - static char *f = "FALSE"; - - if (tf) - { - return t; - } - - return f; -} - -static -void RunBasicTest() -{ - int value; - SDL_SpinLock lock = 0; - - SDL_atomic_t v; - SDL_bool tfret = SDL_FALSE; - - SDL_Log("\nspin lock---------------------------------------\n\n"); - - SDL_AtomicLock(&lock); - SDL_Log("AtomicLock lock=%d\n", lock); - SDL_AtomicUnlock(&lock); - SDL_Log("AtomicUnlock lock=%d\n", lock); - - SDL_Log("\natomic -----------------------------------------\n\n"); - - SDL_AtomicSet(&v, 0); - tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - - SDL_AtomicSet(&v, 0); - SDL_AtomicIncRef(&v); - tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - SDL_AtomicIncRef(&v); - tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - - SDL_AtomicSet(&v, 10); - tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - value = SDL_AtomicGet(&v); - tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE; - SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); -} - -/**************************************************************************/ -/* Atomic operation test - * Adapted with permission from code by Michael Davidsaver at: - * http://bazaar.launchpad.net/~mdavidsaver/epics-base/atomic/revision/12105#src/libCom/test/epicsAtomicTest.c - * Original copyright 2010 Brookhaven Science Associates as operator of Brookhaven National Lab - * http://www.aps.anl.gov/epics/license/open.php - */ - -/* Tests semantics of atomic operations. Also a stress test - * to see if they are really atomic. - * - * Several threads adding to the same variable. - * at the end the value is compared with the expected - * and with a non-atomic counter. - */ - -/* Number of concurrent incrementers */ -#define NThreads 2 -#define CountInc 100 -#define VALBITS (sizeof(atomicValue)*8) - -#define atomicValue int -#define CountTo ((atomicValue)((unsigned int)(1<<(VALBITS-1))-1)) -#define NInter (CountTo/CountInc/NThreads) -#define Expect (CountTo-NInter*CountInc*NThreads) - -SDL_COMPILE_TIME_ASSERT(size, CountTo>0); /* check for rollover */ - -static SDL_atomic_t good = { 42 }; - -static atomicValue bad = 42; - -static SDL_atomic_t threadsRunning; - -static SDL_sem *threadDone; - -static -int adder(void* junk) -{ - unsigned long N=NInter; - SDL_Log("Thread subtracting %d %lu times\n",CountInc,N); - while (N--) { - SDL_AtomicAdd(&good, -CountInc); - bad-=CountInc; - } - SDL_AtomicAdd(&threadsRunning, -1); - SDL_SemPost(threadDone); - return 0; -} - -static -void runAdder(void) -{ - Uint32 start, end; - int T=NThreads; - - start = SDL_GetTicks(); - - threadDone = SDL_CreateSemaphore(0); - - SDL_AtomicSet(&threadsRunning, NThreads); - - while (T--) - SDL_CreateThread(adder, "Adder", NULL); - - while (SDL_AtomicGet(&threadsRunning) > 0) - SDL_SemWait(threadDone); - - SDL_DestroySemaphore(threadDone); - - end = SDL_GetTicks(); - - SDL_Log("Finished in %f sec\n", (end - start) / 1000.f); -} - -static -void RunEpicTest() -{ - int b; - atomicValue v; - - SDL_Log("\nepic test---------------------------------------\n\n"); - - SDL_Log("Size asserted to be >= 32-bit\n"); - SDL_assert(sizeof(atomicValue)>=4); - - SDL_Log("Check static initializer\n"); - v=SDL_AtomicGet(&good); - SDL_assert(v==42); - - SDL_assert(bad==42); - - SDL_Log("Test negative values\n"); - SDL_AtomicSet(&good, -5); - v=SDL_AtomicGet(&good); - SDL_assert(v==-5); - - SDL_Log("Verify maximum value\n"); - SDL_AtomicSet(&good, CountTo); - v=SDL_AtomicGet(&good); - SDL_assert(v==CountTo); - - SDL_Log("Test compare and exchange\n"); - - b=SDL_AtomicCAS(&good, 500, 43); - SDL_assert(!b); /* no swap since CountTo!=500 */ - v=SDL_AtomicGet(&good); - SDL_assert(v==CountTo); /* ensure no swap */ - - b=SDL_AtomicCAS(&good, CountTo, 44); - SDL_assert(!!b); /* will swap */ - v=SDL_AtomicGet(&good); - SDL_assert(v==44); - - SDL_Log("Test Add\n"); - - v=SDL_AtomicAdd(&good, 1); - SDL_assert(v==44); - v=SDL_AtomicGet(&good); - SDL_assert(v==45); - - v=SDL_AtomicAdd(&good, 10); - SDL_assert(v==45); - v=SDL_AtomicGet(&good); - SDL_assert(v==55); - - SDL_Log("Test Add (Negative values)\n"); - - v=SDL_AtomicAdd(&good, -20); - SDL_assert(v==55); - v=SDL_AtomicGet(&good); - SDL_assert(v==35); - - v=SDL_AtomicAdd(&good, -50); /* crossing zero down */ - SDL_assert(v==35); - v=SDL_AtomicGet(&good); - SDL_assert(v==-15); - - v=SDL_AtomicAdd(&good, 30); /* crossing zero up */ - SDL_assert(v==-15); - v=SDL_AtomicGet(&good); - SDL_assert(v==15); - - SDL_Log("Reset before count down test\n"); - SDL_AtomicSet(&good, CountTo); - v=SDL_AtomicGet(&good); - SDL_assert(v==CountTo); - - bad=CountTo; - SDL_assert(bad==CountTo); - - SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect); - runAdder(); - - v=SDL_AtomicGet(&good); - SDL_Log("Atomic %d Non-Atomic %d\n",v,bad); - SDL_assert(v==Expect); - SDL_assert(bad!=Expect); -} - -/* End atomic operation test */ -/**************************************************************************/ - -/**************************************************************************/ -/* Lock-free FIFO test */ - -/* This is useful to test the impact of another thread locking the queue - entirely for heavy-weight manipulation. - */ -#define TEST_SPINLOCK_FIFO - -#define NUM_READERS 4 -#define NUM_WRITERS 4 -#define EVENTS_PER_WRITER 1000000 - -/* The number of entries must be a power of 2 */ -#define MAX_ENTRIES 256 -#define WRAP_MASK (MAX_ENTRIES-1) - -typedef struct -{ - SDL_atomic_t sequence; - SDL_Event event; -} SDL_EventQueueEntry; - -typedef struct -{ - SDL_EventQueueEntry entries[MAX_ENTRIES]; - - char cache_pad1[SDL_CACHELINE_SIZE-((sizeof(SDL_EventQueueEntry)*MAX_ENTRIES)%SDL_CACHELINE_SIZE)]; - - SDL_atomic_t enqueue_pos; - - char cache_pad2[SDL_CACHELINE_SIZE-sizeof(SDL_atomic_t)]; - - SDL_atomic_t dequeue_pos; - - char cache_pad3[SDL_CACHELINE_SIZE-sizeof(SDL_atomic_t)]; - -#ifdef TEST_SPINLOCK_FIFO - SDL_SpinLock lock; - SDL_atomic_t rwcount; - SDL_atomic_t watcher; - - char cache_pad4[SDL_CACHELINE_SIZE-sizeof(SDL_SpinLock)-2*sizeof(SDL_atomic_t)]; -#endif - - SDL_atomic_t active; - - /* Only needed for the mutex test */ - SDL_mutex *mutex; - -} SDL_EventQueue; - -static void InitEventQueue(SDL_EventQueue *queue) -{ - int i; - - for (i = 0; i < MAX_ENTRIES; ++i) { - SDL_AtomicSet(&queue->entries[i].sequence, i); - } - SDL_AtomicSet(&queue->enqueue_pos, 0); - SDL_AtomicSet(&queue->dequeue_pos, 0); -#ifdef TEST_SPINLOCK_FIFO - queue->lock = 0; - SDL_AtomicSet(&queue->rwcount, 0); - SDL_AtomicSet(&queue->watcher, 0); -#endif - SDL_AtomicSet(&queue->active, 1); -} - -static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *event) -{ - SDL_EventQueueEntry *entry; - unsigned queue_pos; - unsigned entry_seq; - int delta; - SDL_bool status; - -#ifdef TEST_SPINLOCK_FIFO - /* This is a gate so an external thread can lock the queue */ - SDL_AtomicLock(&queue->lock); - SDL_assert(SDL_AtomicGet(&queue->watcher) == 0); - SDL_AtomicIncRef(&queue->rwcount); - SDL_AtomicUnlock(&queue->lock); -#endif - - queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos); - for ( ; ; ) { - entry = &queue->entries[queue_pos & WRAP_MASK]; - entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence); - - delta = (int)(entry_seq - queue_pos); - if (delta == 0) { - /* The entry and the queue position match, try to increment the queue position */ - if (SDL_AtomicCAS(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos+1))) { - /* We own the object, fill it! */ - entry->event = *event; - SDL_AtomicSet(&entry->sequence, (int)(queue_pos + 1)); - status = SDL_TRUE; - break; - } - } else if (delta < 0) { - /* We ran into an old queue entry, which means it still needs to be dequeued */ - status = SDL_FALSE; - break; - } else { - /* We ran into a new queue entry, get the new queue position */ - queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos); - } - } - -#ifdef TEST_SPINLOCK_FIFO - SDL_AtomicDecRef(&queue->rwcount); -#endif - return status; -} - -static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event) -{ - SDL_EventQueueEntry *entry; - unsigned queue_pos; - unsigned entry_seq; - int delta; - SDL_bool status; - -#ifdef TEST_SPINLOCK_FIFO - /* This is a gate so an external thread can lock the queue */ - SDL_AtomicLock(&queue->lock); - SDL_assert(SDL_AtomicGet(&queue->watcher) == 0); - SDL_AtomicIncRef(&queue->rwcount); - SDL_AtomicUnlock(&queue->lock); -#endif - - queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos); - for ( ; ; ) { - entry = &queue->entries[queue_pos & WRAP_MASK]; - entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence); - - delta = (int)(entry_seq - (queue_pos + 1)); - if (delta == 0) { - /* The entry and the queue position match, try to increment the queue position */ - if (SDL_AtomicCAS(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos+1))) { - /* We own the object, fill it! */ - *event = entry->event; - SDL_AtomicSet(&entry->sequence, (int)(queue_pos+MAX_ENTRIES)); - status = SDL_TRUE; - break; - } - } else if (delta < 0) { - /* We ran into an old queue entry, which means we've hit empty */ - status = SDL_FALSE; - break; - } else { - /* We ran into a new queue entry, get the new queue position */ - queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos); - } - } - -#ifdef TEST_SPINLOCK_FIFO - SDL_AtomicDecRef(&queue->rwcount); -#endif - return status; -} - -static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event) -{ - SDL_EventQueueEntry *entry; - unsigned queue_pos; - unsigned entry_seq; - int delta; - SDL_bool status = SDL_FALSE; - - SDL_LockMutex(queue->mutex); - - queue_pos = (unsigned)queue->enqueue_pos.value; - entry = &queue->entries[queue_pos & WRAP_MASK]; - entry_seq = (unsigned)entry->sequence.value; - - delta = (int)(entry_seq - queue_pos); - if (delta == 0) { - ++queue->enqueue_pos.value; - - /* We own the object, fill it! */ - entry->event = *event; - entry->sequence.value = (int)(queue_pos + 1); - status = SDL_TRUE; - } else if (delta < 0) { - /* We ran into an old queue entry, which means it still needs to be dequeued */ - } else { - SDL_Log("ERROR: mutex failed!\n"); - } - - SDL_UnlockMutex(queue->mutex); - - return status; -} - -static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event) -{ - SDL_EventQueueEntry *entry; - unsigned queue_pos; - unsigned entry_seq; - int delta; - SDL_bool status = SDL_FALSE; - - SDL_LockMutex(queue->mutex); - - queue_pos = (unsigned)queue->dequeue_pos.value; - entry = &queue->entries[queue_pos & WRAP_MASK]; - entry_seq = (unsigned)entry->sequence.value; - - delta = (int)(entry_seq - (queue_pos + 1)); - if (delta == 0) { - ++queue->dequeue_pos.value; - - /* We own the object, fill it! */ - *event = entry->event; - entry->sequence.value = (int)(queue_pos + MAX_ENTRIES); - status = SDL_TRUE; - } else if (delta < 0) { - /* We ran into an old queue entry, which means we've hit empty */ - } else { - SDL_Log("ERROR: mutex failed!\n"); - } - - SDL_UnlockMutex(queue->mutex); - - return status; -} - -static SDL_sem *writersDone; -static SDL_sem *readersDone; -static SDL_atomic_t writersRunning; -static SDL_atomic_t readersRunning; - -typedef struct -{ - SDL_EventQueue *queue; - int index; - char padding1[SDL_CACHELINE_SIZE-(sizeof(SDL_EventQueue*)+sizeof(int))%SDL_CACHELINE_SIZE]; - int waits; - SDL_bool lock_free; - char padding2[SDL_CACHELINE_SIZE-sizeof(int)-sizeof(SDL_bool)]; -} WriterData; - -typedef struct -{ - SDL_EventQueue *queue; - int counters[NUM_WRITERS]; - int waits; - SDL_bool lock_free; - char padding[SDL_CACHELINE_SIZE-(sizeof(SDL_EventQueue*)+sizeof(int)*NUM_WRITERS+sizeof(int)+sizeof(SDL_bool))%SDL_CACHELINE_SIZE]; -} ReaderData; - -static int FIFO_Writer(void* _data) -{ - WriterData *data = (WriterData *)_data; - SDL_EventQueue *queue = data->queue; - int i; - SDL_Event event; - - event.type = SDL_USEREVENT; - event.user.windowID = 0; - event.user.code = 0; - event.user.data1 = data; - event.user.data2 = NULL; - - if (data->lock_free) { - for (i = 0; i < EVENTS_PER_WRITER; ++i) { - event.user.code = i; - while (!EnqueueEvent_LockFree(queue, &event)) { - ++data->waits; - SDL_Delay(0); - } - } - } else { - for (i = 0; i < EVENTS_PER_WRITER; ++i) { - event.user.code = i; - while (!EnqueueEvent_Mutex(queue, &event)) { - ++data->waits; - SDL_Delay(0); - } - } - } - SDL_AtomicAdd(&writersRunning, -1); - SDL_SemPost(writersDone); - return 0; -} - -static int FIFO_Reader(void* _data) -{ - ReaderData *data = (ReaderData *)_data; - SDL_EventQueue *queue = data->queue; - SDL_Event event; - - if (data->lock_free) { - for ( ; ; ) { - if (DequeueEvent_LockFree(queue, &event)) { - WriterData *writer = (WriterData*)event.user.data1; - ++data->counters[writer->index]; - } else if (SDL_AtomicGet(&queue->active)) { - ++data->waits; - SDL_Delay(0); - } else { - /* We drained the queue, we're done! */ - break; - } - } - } else { - for ( ; ; ) { - if (DequeueEvent_Mutex(queue, &event)) { - WriterData *writer = (WriterData*)event.user.data1; - ++data->counters[writer->index]; - } else if (SDL_AtomicGet(&queue->active)) { - ++data->waits; - SDL_Delay(0); - } else { - /* We drained the queue, we're done! */ - break; - } - } - } - SDL_AtomicAdd(&readersRunning, -1); - SDL_SemPost(readersDone); - return 0; -} - -#ifdef TEST_SPINLOCK_FIFO -/* This thread periodically locks the queue for no particular reason */ -static int FIFO_Watcher(void* _data) -{ - SDL_EventQueue *queue = (SDL_EventQueue *)_data; - - while (SDL_AtomicGet(&queue->active)) { - SDL_AtomicLock(&queue->lock); - SDL_AtomicIncRef(&queue->watcher); - while (SDL_AtomicGet(&queue->rwcount) > 0) { - SDL_Delay(0); - } - /* Do queue manipulation here... */ - SDL_AtomicDecRef(&queue->watcher); - SDL_AtomicUnlock(&queue->lock); - - /* Wait a bit... */ - SDL_Delay(1); - } - return 0; -} -#endif /* TEST_SPINLOCK_FIFO */ - -static void RunFIFOTest(SDL_bool lock_free) -{ - SDL_EventQueue queue; - WriterData writerData[NUM_WRITERS]; - ReaderData readerData[NUM_READERS]; - Uint32 start, end; - int i, j; - int grand_total; - char textBuffer[1024]; - int len; - - SDL_Log("\nFIFO test---------------------------------------\n\n"); - SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); - - readersDone = SDL_CreateSemaphore(0); - writersDone = SDL_CreateSemaphore(0); - - SDL_memset(&queue, 0xff, sizeof(queue)); - - InitEventQueue(&queue); - if (!lock_free) { - queue.mutex = SDL_CreateMutex(); - } - - start = SDL_GetTicks(); - -#ifdef TEST_SPINLOCK_FIFO - /* Start a monitoring thread */ - if (lock_free) { - SDL_CreateThread(FIFO_Watcher, "FIFOWatcher", &queue); - } -#endif - - /* Start the readers first */ - SDL_Log("Starting %d readers\n", NUM_READERS); - SDL_zero(readerData); - SDL_AtomicSet(&readersRunning, NUM_READERS); - for (i = 0; i < NUM_READERS; ++i) { - char name[64]; - SDL_snprintf(name, sizeof (name), "FIFOReader%d", i); - readerData[i].queue = &queue; - readerData[i].lock_free = lock_free; - SDL_CreateThread(FIFO_Reader, name, &readerData[i]); - } - - /* Start up the writers */ - SDL_Log("Starting %d writers\n", NUM_WRITERS); - SDL_zero(writerData); - SDL_AtomicSet(&writersRunning, NUM_WRITERS); - for (i = 0; i < NUM_WRITERS; ++i) { - char name[64]; - SDL_snprintf(name, sizeof (name), "FIFOWriter%d", i); - writerData[i].queue = &queue; - writerData[i].index = i; - writerData[i].lock_free = lock_free; - SDL_CreateThread(FIFO_Writer, name, &writerData[i]); - } - - /* Wait for the writers */ - while (SDL_AtomicGet(&writersRunning) > 0) { - SDL_SemWait(writersDone); - } - - /* Shut down the queue so readers exit */ - SDL_AtomicSet(&queue.active, 0); - - /* Wait for the readers */ - while (SDL_AtomicGet(&readersRunning) > 0) { - SDL_SemWait(readersDone); - } - - end = SDL_GetTicks(); - - SDL_DestroySemaphore(readersDone); - SDL_DestroySemaphore(writersDone); - - if (!lock_free) { - SDL_DestroyMutex(queue.mutex); - } - - SDL_Log("Finished in %f sec\n", (end - start) / 1000.f); - - SDL_Log("\n"); - for (i = 0; i < NUM_WRITERS; ++i) { - SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits); - } - SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER); - - /* Print a breakdown of which readers read messages from which writer */ - SDL_Log("\n"); - grand_total = 0; - for (i = 0; i < NUM_READERS; ++i) { - int total = 0; - for (j = 0; j < NUM_WRITERS; ++j) { - total += readerData[i].counters[j]; - } - grand_total += total; - SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits); - SDL_snprintf(textBuffer, sizeof(textBuffer), " { "); - for (j = 0; j < NUM_WRITERS; ++j) { - if (j > 0) { - len = SDL_strlen(textBuffer); - SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", "); - } - len = SDL_strlen(textBuffer); - SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]); - } - len = SDL_strlen(textBuffer); - SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n"); - SDL_Log("%s", textBuffer); - } - SDL_Log("Readers read %d total events\n", grand_total); -} - -/* End FIFO test */ -/**************************************************************************/ - -int -main(int argc, char *argv[]) -{ - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - RunBasicTest(); - RunEpicTest(); -/* This test is really slow, so don't run it by default */ -#if 0 - RunFIFOTest(SDL_FALSE); -#endif - RunFIFOTest(SDL_TRUE); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testaudiocapture.c b/3rdparty/SDL2/test/testaudiocapture.c deleted file mode 100644 index 26321a71c34..00000000000 --- a/3rdparty/SDL2/test/testaudiocapture.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include "SDL.h" - -#include <stdlib.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -static SDL_Window *window = NULL; -static SDL_Renderer *renderer = NULL; -static SDL_AudioSpec spec; -static SDL_AudioDeviceID devid_in = 0; -static SDL_AudioDeviceID devid_out = 0; - -static void -loop() -{ - SDL_bool please_quit = SDL_FALSE; - SDL_Event e; - - while (SDL_PollEvent(&e)) { - if (e.type == SDL_QUIT) { - please_quit = SDL_TRUE; - } else if (e.type == SDL_KEYDOWN) { - if (e.key.keysym.sym == SDLK_ESCAPE) { - please_quit = SDL_TRUE; - } - } else if (e.type == SDL_MOUSEBUTTONDOWN) { - if (e.button.button == 1) { - SDL_PauseAudioDevice(devid_out, SDL_TRUE); - SDL_PauseAudioDevice(devid_in, SDL_FALSE); - } - } else if (e.type == SDL_MOUSEBUTTONUP) { - if (e.button.button == 1) { - SDL_PauseAudioDevice(devid_in, SDL_TRUE); - SDL_PauseAudioDevice(devid_out, SDL_FALSE); - } - } - } - - if (SDL_GetAudioDeviceStatus(devid_in) == SDL_AUDIO_PLAYING) { - SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); - } else { - SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); - } - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - - if (please_quit) { - /* stop playing back, quit. */ - SDL_Log("Shutting down.\n"); - SDL_PauseAudioDevice(devid_in, 1); - SDL_CloseAudioDevice(devid_in); - SDL_PauseAudioDevice(devid_out, 1); - SDL_CloseAudioDevice(devid_out); - SDL_DestroyRenderer(renderer); - SDL_DestroyWindow(window); - SDL_Quit(); - #ifdef __EMSCRIPTEN__ - emscripten_cancel_main_loop(); - #endif - exit(0); - } - - /* Note that it would be easier to just have a one-line function that - calls SDL_QueueAudio() as a capture device callback, but we're - trying to test the API, so we use SDL_DequeueAudio() here. */ - while (SDL_TRUE) { - Uint8 buf[1024]; - const Uint32 br = SDL_DequeueAudio(devid_in, buf, sizeof (buf)); - SDL_QueueAudio(devid_out, buf, br); - if (br < sizeof (buf)) { - break; - } - } -} - -int -main(int argc, char **argv) -{ - /* (argv[1] == NULL means "open default device.") */ - const char *devname = argv[1]; - SDL_AudioSpec wanted; - int devcount; - int i; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - window = SDL_CreateWindow("testaudiocapture", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0); - renderer = SDL_CreateRenderer(window, -1, 0); - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - - SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); - - devcount = SDL_GetNumAudioDevices(SDL_TRUE); - for (i = 0; i < devcount; i++) { - SDL_Log(" Capture device #%d: '%s'\n", i, SDL_GetAudioDeviceName(i, SDL_TRUE)); - } - - SDL_zero(wanted); - wanted.freq = 44100; - wanted.format = AUDIO_F32SYS; - wanted.channels = 1; - wanted.samples = 4096; - wanted.callback = NULL; - - SDL_zero(spec); - - /* DirectSound can fail in some instances if you open the same hardware - for both capture and output and didn't open the output end first, - according to the docs, so if you're doing something like this, always - open your capture devices second in case you land in those bizarre - circumstances. */ - - SDL_Log("Opening default playback device...\n"); - devid_out = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wanted, &spec, SDL_AUDIO_ALLOW_ANY_CHANGE); - if (!devid_out) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for playback: %s!\n", SDL_GetError()); - SDL_Quit(); - exit(1); - } - - SDL_Log("Opening capture device %s%s%s...\n", - devname ? "'" : "", - devname ? devname : "[[default]]", - devname ? "'" : ""); - - devid_in = SDL_OpenAudioDevice(argv[1], SDL_TRUE, &spec, &spec, 0); - if (!devid_in) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for capture: %s!\n", SDL_GetError()); - SDL_Quit(); - exit(1); - } - - SDL_Log("Ready! Hold down mouse or finger to record!\n"); - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (1) { loop(); SDL_Delay(16); } -#endif - - return 0; -} - diff --git a/3rdparty/SDL2/test/testaudiohotplug.c b/3rdparty/SDL2/test/testaudiohotplug.c deleted file mode 100644 index 73d4805057d..00000000000 --- a/3rdparty/SDL2/test/testaudiohotplug.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Program to test hotplugging of audio devices */ - -#include "SDL_config.h" - -#include <stdio.h> -#include <stdlib.h> - -#if HAVE_SIGNAL_H -#include <signal.h> -#endif - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL.h" - -static SDL_AudioSpec spec; -static Uint8 *sound = NULL; /* Pointer to wave data */ -static Uint32 soundlen = 0; /* Length of wave data */ - -static int posindex = 0; -static Uint32 positions[64]; - -/* 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 *_pos, Uint8 * stream, int len) -{ - Uint32 pos = *((Uint32 *) _pos); - Uint8 *waveptr; - int waveleft; - - /* Set up the pointers */ - waveptr = sound + pos; - waveleft = soundlen - pos; - - /* Go! */ - while (waveleft <= len) { - SDL_memcpy(stream, waveptr, waveleft); - stream += waveleft; - len -= waveleft; - waveptr = sound; - waveleft = soundlen; - pos = 0; - } - SDL_memcpy(stream, waveptr, len); - pos += len; - *((Uint32 *) _pos) = pos; -} - -static int done = 0; -void -poked(int sig) -{ - done = 1; -} - -static const char* -devtypestr(int iscapture) -{ - return iscapture ? "capture" : "output"; -} - -static void -iteration() -{ - SDL_Event e; - SDL_AudioDeviceID dev; - while (SDL_PollEvent(&e)) { - if (e.type == SDL_QUIT) { - done = 1; - } else if (e.type == SDL_KEYUP) { - if (e.key.keysym.sym == SDLK_ESCAPE) - done = 1; - } else if (e.type == SDL_AUDIODEVICEADDED) { - int index = e.adevice.which; - int iscapture = e.adevice.iscapture; - const char *name = SDL_GetAudioDeviceName(index, iscapture); - if (name != NULL) - SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int) index, name); - else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n", - devtypestr(iscapture), (unsigned int) index, SDL_GetError()); - continue; - } - if (!iscapture) { - positions[posindex] = 0; - spec.userdata = &positions[posindex++]; - spec.callback = fillerup; - dev = SDL_OpenAudioDevice(name, 0, &spec, NULL, 0); - if (!dev) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open '%s': %s\n", name, SDL_GetError()); - } else { - SDL_Log("Opened '%s' as %u\n", name, (unsigned int) dev); - SDL_PauseAudioDevice(dev, 0); - } - } - } else if (e.type == SDL_AUDIODEVICEREMOVED) { - dev = (SDL_AudioDeviceID) e.adevice.which; - SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.iscapture), (unsigned int) dev); - SDL_CloseAudioDevice(dev); - } - } -} - -#ifdef __EMSCRIPTEN__ -void -loop() -{ - if(done) - emscripten_cancel_main_loop(); - else - iteration(); -} -#endif - -int -main(int argc, char *argv[]) -{ - int i; - char filename[4096]; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - /* Some targets (Mac CoreAudio) need an event queue for audio hotplug, so make and immediately hide a window. */ - SDL_MinimizeWindow(SDL_CreateWindow("testaudiohotplug", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0)); - - if (argc > 1) { - SDL_strlcpy(filename, argv[1], sizeof(filename)); - } else { - SDL_strlcpy(filename, "sample.wav", sizeof(filename)); - } - /* Load the wave file into memory */ - if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); - quit(1); - } - -#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 */ - - /* Show the list of available drivers */ - SDL_Log("Available audio drivers:"); - for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { - SDL_Log("%i: %s", i, SDL_GetAudioDriver(i)); - } - - SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n"); - SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - SDL_Delay(100); - iteration(); - } -#endif - - /* Clean up on signal */ - /* Quit audio first, then free WAV. This prevents access violations in the audio threads. */ - SDL_QuitSubSystem(SDL_INIT_AUDIO); - SDL_FreeWAV(sound); - SDL_Quit(); - return (0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testaudioinfo.c b/3rdparty/SDL2/test/testaudioinfo.c deleted file mode 100644 index 485fd0a3855..00000000000 --- a/3rdparty/SDL2/test/testaudioinfo.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include <stdio.h> -#include "SDL.h" - -static void -print_devices(int iscapture) -{ - const char *typestr = ((iscapture) ? "capture" : "output"); - int n = SDL_GetNumAudioDevices(iscapture); - - SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : ""); - - if (n == -1) - SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr); - else if (n == 0) - SDL_Log(" No %s devices found.\n\n", typestr); - else { - int i; - for (i = 0; i < n; i++) { - const char *name = SDL_GetAudioDeviceName(i, iscapture); - if (name != NULL) - SDL_Log(" %d: %s\n", i, name); - else - SDL_Log(" %d Error: %s\n", i, SDL_GetError()); - } - SDL_Log("\n"); - } -} - -int -main(int argc, char **argv) -{ - int n; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_AUDIO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - /* Print available audio drivers */ - n = SDL_GetNumAudioDrivers(); - if (n == 0) { - SDL_Log("No built-in audio drivers\n\n"); - } else { - int i; - SDL_Log("Built-in audio drivers:\n"); - for (i = 0; i < n; ++i) { - SDL_Log(" %d: %s\n", i, SDL_GetAudioDriver(i)); - } - SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n"); - } - - SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver()); - - print_devices(0); - print_devices(1); - - SDL_Quit(); - return 0; -} diff --git a/3rdparty/SDL2/test/testautomation.c b/3rdparty/SDL2/test/testautomation.c deleted file mode 100644 index eea74b3b864..00000000000 --- a/3rdparty/SDL2/test/testautomation.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#include "SDL.h" -#include "SDL_test.h" - -#include "testautomation_suites.h" - -static SDLTest_CommonState *state; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -int -main(int argc, char *argv[]) -{ - int result; - int testIterations = 1; - Uint64 userExecKey = 0; - char *userRunSeed = NULL; - char *filter = NULL; - int i, done; - SDL_Event event; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - - /* Parse commandline */ - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - if (SDL_strcasecmp(argv[i], "--iterations") == 0) { - if (argv[i + 1]) { - testIterations = SDL_atoi(argv[i + 1]); - if (testIterations < 1) testIterations = 1; - consumed = 2; - } - } - else if (SDL_strcasecmp(argv[i], "--execKey") == 0) { - if (argv[i + 1]) { - SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, (long long unsigned int *)&userExecKey); - consumed = 2; - } - } - else if (SDL_strcasecmp(argv[i], "--seed") == 0) { - if (argv[i + 1]) { - userRunSeed = SDL_strdup(argv[i + 1]); - consumed = 2; - } - } - else if (SDL_strcasecmp(argv[i], "--filter") == 0) { - if (argv[i + 1]) { - filter = SDL_strdup(argv[i + 1]); - consumed = 2; - } - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n", - argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - - i += consumed; - } - - /* Initialize common state */ - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - /* Create the windows, initialize the renderers */ - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); - SDL_RenderClear(renderer); - } - - /* Call Harness */ - result = SDLTest_RunSuites(testSuites, (const char *)userRunSeed, userExecKey, (const char *)filter, testIterations); - - /* Empty event queue */ - done = 0; - for (i=0; i<100; i++) { - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - SDL_Delay(10); - } - - /* Clean up */ - SDL_free(userRunSeed); - SDL_free(filter); - - /* Shutdown everything */ - quit(result); - return(result); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testautomation_audio.c b/3rdparty/SDL2/test/testautomation_audio.c deleted file mode 100644 index bef838dde05..00000000000 --- a/3rdparty/SDL2/test/testautomation_audio.c +++ /dev/null @@ -1,1038 +0,0 @@ -/** - * Original code: automated SDL audio test written by Edgar Simo "bobbens" - * New/updated tests: aschiffler at ferzkopp dot net - */ - -/* quiet windows compiler warnings */ -#define _CRT_SECURE_NO_WARNINGS - -#include <stdio.h> -#include <string.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -/* Fixture */ - -void -_audioSetUp(void *arg) -{ - /* Start SDL audio subsystem */ - int ret = SDL_InitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)"); - SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)"); - if (ret != 0) { - SDLTest_LogError("%s", SDL_GetError()); - } -} - -void -_audioTearDown(void *arg) -{ - /* Remove a possibly created file from SDL disk writer audio driver; ignore errors */ - remove("sdlaudio.raw"); - - SDLTest_AssertPass("Cleanup of test files completed"); -} - - -/* Global counter for callback invocation */ -int _audio_testCallbackCounter; - -/* Global accumulator for total callback length */ -int _audio_testCallbackLength; - - -/* Test callback function */ -void _audio_testCallback(void *userdata, Uint8 *stream, int len) -{ - /* track that callback was called */ - _audio_testCallbackCounter++; - _audio_testCallbackLength += len; -} - - -/* Test case functions */ - -/** - * \brief Stop and restart audio subsystem - * - * \sa https://wiki.libsdl.org/SDL_QuitSubSystem - * \sa https://wiki.libsdl.org/SDL_InitSubSystem - */ -int audio_quitInitAudioSubSystem() -{ - /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - - /* Restart audio again */ - _audioSetUp(NULL); - - return TEST_COMPLETED; -} - -/** - * \brief Start and stop audio directly - * - * \sa https://wiki.libsdl.org/SDL_InitAudio - * \sa https://wiki.libsdl.org/SDL_QuitAudio - */ -int audio_initQuitAudio() -{ - int result; - int i, iMax; - const char* audioDriver; - - /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); - for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); - - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - - /* Call Quit */ - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit()"); - } - - /* NULL driver specification */ - audioDriver = NULL; - - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit(NULL)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - - /* Call Quit */ - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit()"); - - /* Restart audio again */ - _audioSetUp(NULL); - - return TEST_COMPLETED; -} - -/** - * \brief Start, open, close and stop audio - * - * \sa https://wiki.libsdl.org/SDL_InitAudio - * \sa https://wiki.libsdl.org/SDL_OpenAudio - * \sa https://wiki.libsdl.org/SDL_CloseAudio - * \sa https://wiki.libsdl.org/SDL_QuitAudio - */ -int audio_initOpenCloseQuitAudio() -{ - int result, expectedResult; - int i, iMax, j, k; - const char* audioDriver; - SDL_AudioSpec desired; - - /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); - for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); - - /* Change specs */ - for (j = 0; j < 2; j++) { - - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - - /* Set spec */ - SDL_memset(&desired, 0, sizeof(desired)); - switch (j) { - case 0: - /* Set standard desired spec */ - desired.freq = 22050; - desired.format = AUDIO_S16SYS; - desired.channels = 2; - desired.samples = 4096; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - - case 1: - /* Set custom desired spec */ - desired.freq = 48000; - desired.format = AUDIO_F32SYS; - desired.channels = 2; - desired.samples = 2048; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - break; - } - - /* Call Open (maybe multiple times) */ - for (k=0; k <= j; k++) { - result = SDL_OpenAudio(&desired, NULL); - SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL), call %d", j, k+1); - expectedResult = (k==0) ? 0 : -1; - SDLTest_AssertCheck(result == expectedResult, "Verify return value; expected: %d, got: %d", expectedResult, result); - } - - /* Call Close (maybe multiple times) */ - for (k=0; k <= j; k++) { - SDL_CloseAudio(); - SDLTest_AssertPass("Call to SDL_CloseAudio(), call %d", k+1); - } - - /* Call Quit (maybe multiple times) */ - for (k=0; k <= j; k++) { - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit(), call %d", k+1); - } - - } /* spec loop */ - } /* driver loop */ - - /* Restart audio again */ - _audioSetUp(NULL); - - return TEST_COMPLETED; -} - -/** - * \brief Pause and unpause audio - * - * \sa https://wiki.libsdl.org/SDL_PauseAudio - */ -int audio_pauseUnpauseAudio() -{ - int result; - int i, iMax, j, k, l; - int totalDelay; - int pause_on; - int originalCounter; - const char* audioDriver; - SDL_AudioSpec desired; - - /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); - SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); - for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); - - /* Change specs */ - for (j = 0; j < 2; j++) { - - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - - /* Set spec */ - SDL_memset(&desired, 0, sizeof(desired)); - switch (j) { - case 0: - /* Set standard desired spec */ - desired.freq = 22050; - desired.format = AUDIO_S16SYS; - desired.channels = 2; - desired.samples = 4096; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - - case 1: - /* Set custom desired spec */ - desired.freq = 48000; - desired.format = AUDIO_F32SYS; - desired.channels = 2; - desired.samples = 2048; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - break; - } - - /* Call Open */ - result = SDL_OpenAudio(&desired, NULL); - SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result); - - /* Start and stop audio multiple times */ - for (l=0; l<3; l++) { - SDLTest_Log("Pause/Unpause iteration: %d", l+1); - - /* Reset callback counters */ - _audio_testCallbackCounter = 0; - _audio_testCallbackLength = 0; - - /* Un-pause audio to start playing (maybe multiple times) */ - pause_on = 0; - for (k=0; k <= j; k++) { - SDL_PauseAudio(pause_on); - SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1); - } - - /* Wait for callback */ - totalDelay = 0; - do { - SDL_Delay(10); - totalDelay += 10; - } - while (_audio_testCallbackCounter == 0 && totalDelay < 1000); - SDLTest_AssertCheck(_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", _audio_testCallbackCounter); - SDLTest_AssertCheck(_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", _audio_testCallbackLength); - - /* Pause audio to stop playing (maybe multiple times) */ - for (k=0; k <= j; k++) { - pause_on = (k==0) ? 1 : SDLTest_RandomIntegerInRange(99, 9999); - SDL_PauseAudio(pause_on); - SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1); - } - - /* Ensure callback is not called again */ - originalCounter = _audio_testCallbackCounter; - SDL_Delay(totalDelay + 10); - SDLTest_AssertCheck(originalCounter == _audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, _audio_testCallbackCounter); - } - - /* Call Close */ - SDL_CloseAudio(); - SDLTest_AssertPass("Call to SDL_CloseAudio()"); - - /* Call Quit */ - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit()"); - - } /* spec loop */ - } /* driver loop */ - - /* Restart audio again */ - _audioSetUp(NULL); - - return TEST_COMPLETED; -} - -/** - * \brief Enumerate and name available audio devices (output and capture). - * - * \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices - * \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName - */ -int audio_enumerateAndNameAudioDevices() -{ - int t, tt; - int i, n, nn; - const char *name, *nameAgain; - - /* Iterate over types: t=0 output device, t=1 input/capture device */ - for (t=0; t<2; t++) { - - /* Get number of devices. */ - n = SDL_GetNumAudioDevices(t); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t); - SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "capture" : "output", n); - SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n); - - /* Variation of non-zero type */ - if (t==1) { - tt = t + SDLTest_RandomIntegerInRange(1,10); - nn = SDL_GetNumAudioDevices(tt); - SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn); - nn = SDL_GetNumAudioDevices(-tt); - SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn); - } - - /* List devices. */ - if (n>0) { - for (i=0; i<n; i++) { - name = SDL_GetAudioDeviceName(i, t); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); - SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t); - if (name != NULL) { - SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name); - if (t==1) { - /* Also try non-zero type */ - tt = t + SDLTest_RandomIntegerInRange(1,10); - nameAgain = SDL_GetAudioDeviceName(i, tt); - SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt); - if (nameAgain != NULL) { - SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain); - SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0, - "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", - i, t, i, tt); - } - } - } - } - } - } - - return TEST_COMPLETED; -} - -/** - * \brief Negative tests around enumeration and naming of audio devices. - * - * \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices - * \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName - */ -int audio_enumerateAndNameAudioDevicesNegativeTests() -{ - int t; - int i, j, no, nc; - const char *name; - - /* Get number of devices. */ - no = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - nc = SDL_GetNumAudioDevices(1); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)"); - - /* Invalid device index when getting name */ - for (t=0; t<2; t++) { - /* Negative device index */ - i = SDLTest_RandomIntegerInRange(-10,-1); - name = SDL_GetAudioDeviceName(i, t); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); - SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); - - /* Device index past range */ - for (j=0; j<3; j++) { - i = (t) ? nc+j : no+j; - name = SDL_GetAudioDeviceName(i, t); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); - SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); - } - - /* Capture index past capture range but within output range */ - if ((no>0) && (no>nc) && (t==1)) { - i = no-1; - name = SDL_GetAudioDeviceName(i, t); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); - SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); - } - } - - return TEST_COMPLETED; -} - - -/** - * \brief Checks available audio driver names. - * - * \sa https://wiki.libsdl.org/SDL_GetNumAudioDrivers - * \sa https://wiki.libsdl.org/SDL_GetAudioDriver - */ -int audio_printAudioDrivers() -{ - int i, n; - const char *name; - - /* Get number of drivers */ - n = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n); - - /* List drivers. */ - if (n>0) - { - for (i=0; i<n; i++) { - name = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i); - SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); - if (name != NULL) { - SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); - } - } - } - - return TEST_COMPLETED; -} - - -/** - * \brief Checks current audio driver name with initialized audio. - * - * \sa https://wiki.libsdl.org/SDL_GetCurrentAudioDriver - */ -int audio_printCurrentAudioDriver() -{ - /* Check current audio driver */ - const char *name = SDL_GetCurrentAudioDriver(); - SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()"); - SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); - if (name != NULL) { - SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); - } - - return TEST_COMPLETED; -} - -/* Definition of all formats, channels, and frequencies used to test audio conversions */ -const int _numAudioFormats = 18; -SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, - AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, - AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 }; -char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB", - "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", - "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" }; -const int _numAudioChannels = 4; -Uint8 _audioChannels[] = { 1, 2, 4, 6 }; -const int _numAudioFrequencies = 4; -int _audioFrequencies[] = { 11025, 22050, 44100, 48000 }; - - -/** - * \brief Builds various audio conversion structures - * - * \sa https://wiki.libsdl.org/SDL_BuildAudioCVT - */ -int audio_buildAudioCVT() -{ - int result; - SDL_AudioCVT cvt; - SDL_AudioSpec spec1; - SDL_AudioSpec spec2; - int i, ii, j, jj, k, kk; - - /* No conversion needed */ - spec1.format = AUDIO_S16LSB; - spec1.channels = 2; - spec1.freq = 22050; - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec1.format, spec1.channels, spec1.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec1)"); - SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0, got: %i", result); - - /* Typical conversion */ - spec1.format = AUDIO_S8; - spec1.channels = 1; - spec1.freq = 22050; - spec2.format = AUDIO_S16LSB; - spec2.channels = 2; - spec2.freq = 44100; - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)"); - SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); - - /* All source conversions with random conversion targets, allow 'null' conversions */ - for (i = 0; i < _numAudioFormats; i++) { - for (j = 0; j < _numAudioChannels; j++) { - for (k = 0; k < _numAudioFrequencies; k++) { - spec1.format = _audioFormats[i]; - spec1.channels = _audioChannels[j]; - spec1.freq = _audioFrequencies[k]; - ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); - jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); - kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); - spec2.format = _audioFormats[ii]; - spec2.channels = _audioChannels[jj]; - spec2.freq = _audioFrequencies[kk]; - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", - i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); - SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result); - if (result<0) { - SDLTest_LogError("%s", SDL_GetError()); - } else { - SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult); - } - } - } - } - - return TEST_COMPLETED; -} - -/** - * \brief Checkes calls with invalid input to SDL_BuildAudioCVT - * - * \sa https://wiki.libsdl.org/SDL_BuildAudioCVT - */ -int audio_buildAudioCVTNegative() -{ - const char *expectedError = "Parameter 'cvt' is invalid"; - const char *error; - int result; - SDL_AudioCVT cvt; - SDL_AudioSpec spec1; - SDL_AudioSpec spec2; - int i; - char message[256]; - - /* Valid format */ - spec1.format = AUDIO_S8; - spec1.channels = 1; - spec1.freq = 22050; - spec2.format = AUDIO_S16LSB; - spec2.channels = 2; - spec2.freq = 44100; - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* NULL input for CVT buffer */ - result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)"); - SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } - - /* Invalid conversions */ - for (i = 1; i < 64; i++) { - /* Valid format to start with */ - spec1.format = AUDIO_S8; - spec1.channels = 1; - spec1.freq = 22050; - spec2.format = AUDIO_S16LSB; - spec2.channels = 2; - spec2.freq = 44100; - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* Set various invalid format inputs */ - SDL_strlcpy(message, "Invalid: ", 256); - if (i & 1) { - SDL_strlcat(message, " spec1.format", 256); - spec1.format = 0; - } - if (i & 2) { - SDL_strlcat(message, " spec1.channels", 256); - spec1.channels = 0; - } - if (i & 4) { - SDL_strlcat(message, " spec1.freq", 256); - spec1.freq = 0; - } - if (i & 8) { - SDL_strlcat(message, " spec2.format", 256); - spec2.format = 0; - } - if (i & 16) { - SDL_strlcat(message, " spec2.channels", 256); - spec2.channels = 0; - } - if (i & 32) { - SDL_strlcat(message, " spec2.freq", 256); - spec2.freq = 0; - } - SDLTest_Log("%s", message); - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)"); - SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty"); - } - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/** - * \brief Checks current audio status. - * - * \sa https://wiki.libsdl.org/SDL_GetAudioStatus - */ -int audio_getAudioStatus() -{ - SDL_AudioStatus result; - - /* Check current audio status */ - result = SDL_GetAudioStatus(); - SDLTest_AssertPass("Call to SDL_GetAudioStatus()"); - SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, - "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", - SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); - - return TEST_COMPLETED; -} - - - -/** - * \brief Opens, checks current audio status, and closes a device. - * - * \sa https://wiki.libsdl.org/SDL_GetAudioStatus - */ -int audio_openCloseAndGetAudioStatus() -{ - SDL_AudioStatus result; - int i; - int count; - char *device; - SDL_AudioDeviceID id; - SDL_AudioSpec desired, obtained; - - /* Get number of devices. */ - count = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - if (count > 0) { - for (i = 0; i < count; i++) { - /* Get device name */ - device = (char *)SDL_GetAudioDeviceName(i, 0); - SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); - SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); - if (device == NULL) return TEST_ABORTED; - - /* Set standard desired spec */ - desired.freq=22050; - desired.format=AUDIO_S16SYS; - desired.channels=2; - desired.samples=4096; - desired.callback=_audio_testCallback; - desired.userdata=NULL; - - /* Open device */ - id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); - SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); - SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id); - if (id > 1) { - - /* Check device audio status */ - result = SDL_GetAudioDeviceStatus(id); - SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()"); - SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, - "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", - SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); - - /* Close device again */ - SDL_CloseAudioDevice(id); - SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); - } - } - } else { - SDLTest_Log("No devices to test with"); - } - - return TEST_COMPLETED; -} - -/** - * \brief Locks and unlocks open audio device. - * - * \sa https://wiki.libsdl.org/SDL_LockAudioDevice - * \sa https://wiki.libsdl.org/SDL_UnlockAudioDevice - */ -int audio_lockUnlockOpenAudioDevice() -{ - int i; - int count; - char *device; - SDL_AudioDeviceID id; - SDL_AudioSpec desired, obtained; - - /* Get number of devices. */ - count = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - if (count > 0) { - for (i = 0; i < count; i++) { - /* Get device name */ - device = (char *)SDL_GetAudioDeviceName(i, 0); - SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); - SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); - if (device == NULL) return TEST_ABORTED; - - /* Set standard desired spec */ - desired.freq=22050; - desired.format=AUDIO_S16SYS; - desired.channels=2; - desired.samples=4096; - desired.callback=_audio_testCallback; - desired.userdata=NULL; - - /* Open device */ - id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); - SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); - SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id); - if (id > 1) { - /* Lock to protect callback */ - SDL_LockAudioDevice(id); - SDLTest_AssertPass("SDL_LockAudioDevice(%i)", id); - - /* Simulate callback processing */ - SDL_Delay(10); - SDLTest_Log("Simulate callback processing - delay"); - - /* Unlock again */ - SDL_UnlockAudioDevice(id); - SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id); - - /* Close device again */ - SDL_CloseAudioDevice(id); - SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); - } - } - } else { - SDLTest_Log("No devices to test with"); - } - - return TEST_COMPLETED; -} - - -/** - * \brief Convert audio using various conversion structures - * - * \sa https://wiki.libsdl.org/SDL_BuildAudioCVT - * \sa https://wiki.libsdl.org/SDL_ConvertAudio - */ -int audio_convertAudio() -{ - int result; - SDL_AudioCVT cvt; - SDL_AudioSpec spec1; - SDL_AudioSpec spec2; - int c; - char message[128]; - int i, ii, j, jj, k, kk, l, ll; - - /* Iterate over bitmask that determines which parameters are modified in the conversion */ - for (c = 1; c < 8; c++) { - SDL_strlcpy(message, "Changing:", 128); - if (c & 1) { - SDL_strlcat(message, " Format", 128); - } - if (c & 2) { - SDL_strlcat(message, " Channels", 128); - } - if (c & 4) { - SDL_strlcat(message, " Frequencies", 128); - } - SDLTest_Log("%s", message); - /* All source conversions with random conversion targets */ - for (i = 0; i < _numAudioFormats; i++) { - for (j = 0; j < _numAudioChannels; j++) { - for (k = 0; k < _numAudioFrequencies; k++) { - spec1.format = _audioFormats[i]; - spec1.channels = _audioChannels[j]; - spec1.freq = _audioFrequencies[k]; - - /* Ensure we have a different target format */ - do { - if (c & 1) { - ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1); - } else { - ii = 1; - } - if (c & 2) { - jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1); - } else { - jj= j; - } - if (c & 4) { - kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1); - } else { - kk = k; - } - } while ((i == ii) && (j == jj) && (k == kk)); - spec2.format = _audioFormats[ii]; - spec2.channels = _audioChannels[jj]; - spec2.freq = _audioFrequencies[kk]; - - result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, - spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", - i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); - SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); - if (result != 1) { - SDLTest_LogError("%s", SDL_GetError()); - } else { - SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult); - if (cvt.len_mult < 1) return TEST_ABORTED; - - /* Create some random data to convert */ - l = 64; - ll = l * cvt.len_mult; - SDLTest_Log("Creating dummy sample buffer of %i length (%i bytes)", l, ll); - cvt.len = l; - cvt.buf = (Uint8 *)SDL_malloc(ll); - SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL"); - if (cvt.buf == NULL) return TEST_ABORTED; - - /* Convert the data */ - result = SDL_ConvertAudio(&cvt); - SDLTest_AssertPass("Call to SDL_ConvertAudio()"); - SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result); - SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL"); - SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio); - - /* Free converted buffer */ - SDL_free(cvt.buf); - cvt.buf = NULL; - } - } - } - } - } - - return TEST_COMPLETED; -} - - -/** - * \brief Opens, checks current connected status, and closes a device. - * - * \sa https://wiki.libsdl.org/SDL_AudioDeviceConnected - */ -int audio_openCloseAudioDeviceConnected() -{ - int result = -1; - int i; - int count; - char *device; - SDL_AudioDeviceID id; - SDL_AudioSpec desired, obtained; - - /* Get number of devices. */ - count = SDL_GetNumAudioDevices(0); - SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); - if (count > 0) { - for (i = 0; i < count; i++) { - /* Get device name */ - device = (char *)SDL_GetAudioDeviceName(i, 0); - SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); - SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); - if (device == NULL) return TEST_ABORTED; - - /* Set standard desired spec */ - desired.freq=22050; - desired.format=AUDIO_S16SYS; - desired.channels=2; - desired.samples=4096; - desired.callback=_audio_testCallback; - desired.userdata=NULL; - - /* Open device */ - id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); - SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); - SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %i", id); - if (id > 1) { - -/* TODO: enable test code when function is available in SDL2 */ - -#ifdef AUDIODEVICECONNECTED_DEFINED - /* Get connected status */ - result = SDL_AudioDeviceConnected(id); - SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()"); -#endif - SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result); - - /* Close device again */ - SDL_CloseAudioDevice(id); - SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); - } - } - } else { - SDLTest_Log("No devices to test with"); - } - - return TEST_COMPLETED; -} - - - -/* ================= Test Case References ================== */ - -/* Audio test cases */ -static const SDLTest_TestCaseReference audioTest1 = - { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest2 = - { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest3 = - { (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest4 = - { (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest5 = - { (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest6 = - { (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest7 = - { (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest8 = - { (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest9 = - { (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED }; - -/* TODO: enable test when SDL_ConvertAudio segfaults on cygwin have been fixed. */ -/* For debugging, test case can be run manually using --filter audio_convertAudio */ - -static const SDLTest_TestCaseReference audioTest10 = - { (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED }; - -/* TODO: enable test when SDL_AudioDeviceConnected has been implemented. */ - -static const SDLTest_TestCaseReference audioTest11 = - { (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED }; - -static const SDLTest_TestCaseReference audioTest12 = - { (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest13 = - { (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest14 = - { (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_ENABLED }; - -static const SDLTest_TestCaseReference audioTest15 = - { (SDLTest_TestCaseFp)audio_pauseUnpauseAudio, "audio_pauseUnpauseAudio", "Pause and Unpause audio for various audio specs while testing callback.", TEST_ENABLED }; - -/* Sequence of Audio test cases */ -static const SDLTest_TestCaseReference *audioTests[] = { - &audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6, - &audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11, - &audioTest12, &audioTest13, &audioTest14, &audioTest15, NULL -}; - -/* Audio test suite (global) */ -SDLTest_TestSuiteReference audioTestSuite = { - "Audio", - _audioSetUp, - audioTests, - _audioTearDown -}; diff --git a/3rdparty/SDL2/test/testautomation_clipboard.c b/3rdparty/SDL2/test/testautomation_clipboard.c deleted file mode 100644 index f943ffee790..00000000000 --- a/3rdparty/SDL2/test/testautomation_clipboard.c +++ /dev/null @@ -1,184 +0,0 @@ -/** - * New/updated tests: aschiffler at ferzkopp dot net - */ - -#include <stdio.h> -#include <string.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -/* Test case functions */ - -/** - * \brief Check call to SDL_HasClipboardText - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText - */ -int -clipboard_testHasClipboardText(void *arg) -{ - SDL_bool result; - result = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); - - return TEST_COMPLETED; -} - -/** - * \brief Check call to SDL_GetClipboardText - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText - */ -int -clipboard_testGetClipboardText(void *arg) -{ - char *charResult; - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - - SDL_free(charResult); - - return TEST_COMPLETED; -} - -/** - * \brief Check call to SDL_SetClipboardText - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText - */ -int -clipboard_testSetClipboardText(void *arg) -{ - char *textRef = SDLTest_RandomAsciiString(); - char *text = SDL_strdup(textRef); - int result; - result = SDL_SetClipboardText((const char *)text); - SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); - SDLTest_AssertCheck( - result == 0, - "Validate SDL_SetClipboardText result, expected 0, got %i", - result); - SDLTest_AssertCheck( - SDL_strcmp(textRef, text) == 0, - "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'", - textRef, text); - - /* Cleanup */ - SDL_free(textRef); - SDL_free(text); - - return TEST_COMPLETED; -} - -/** - * \brief End-to-end test of SDL_xyzClipboardText functions - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText - * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText - * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText - */ -int -clipboard_testClipboardTextFunctions(void *arg) -{ - char *textRef = SDLTest_RandomAsciiString(); - char *text = SDL_strdup(textRef); - SDL_bool boolResult; - int intResult; - char *charResult; - - /* Clear clipboard text state */ - boolResult = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); - if (boolResult == SDL_TRUE) { - intResult = SDL_SetClipboardText((const char *)NULL); - SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded"); - SDLTest_AssertCheck( - intResult == 0, - "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i", - intResult); - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - SDL_free(charResult); - boolResult = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); - SDLTest_AssertCheck( - boolResult == SDL_FALSE, - "Verify SDL_HasClipboardText returned SDL_FALSE, got %s", - (boolResult) ? "SDL_TRUE" : "SDL_FALSE"); - } - - /* Empty clipboard */ - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - SDLTest_AssertCheck( - charResult != NULL, - "Verify SDL_GetClipboardText did not return NULL"); - SDLTest_AssertCheck( - charResult[0] == '\0', - "Verify SDL_GetClipboardText returned string with length 0, got length %i", - SDL_strlen(charResult)); - intResult = SDL_SetClipboardText((const char *)text); - SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); - SDLTest_AssertCheck( - intResult == 0, - "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i", - intResult); - SDLTest_AssertCheck( - SDL_strcmp(textRef, text) == 0, - "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'", - textRef, text); - boolResult = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); - SDLTest_AssertCheck( - boolResult == SDL_TRUE, - "Verify SDL_HasClipboardText returned SDL_TRUE, got %s", - (boolResult) ? "SDL_TRUE" : "SDL_FALSE"); - SDL_free(charResult); - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - SDLTest_AssertCheck( - SDL_strcmp(textRef, charResult) == 0, - "Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'", - textRef, charResult); - - /* Cleanup */ - SDL_free(textRef); - SDL_free(text); - SDL_free(charResult); - - return TEST_COMPLETED; -} - - -/* ================= Test References ================== */ - -/* Clipboard test cases */ -static const SDLTest_TestCaseReference clipboardTest1 = - { (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED }; - -static const SDLTest_TestCaseReference clipboardTest2 = - { (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED }; - -static const SDLTest_TestCaseReference clipboardTest3 = - { (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED }; - -static const SDLTest_TestCaseReference clipboardTest4 = - { (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED }; - -/* Sequence of Clipboard test cases */ -static const SDLTest_TestCaseReference *clipboardTests[] = { - &clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL -}; - -/* Clipboard test suite (global) */ -SDLTest_TestSuiteReference clipboardTestSuite = { - "Clipboard", - NULL, - clipboardTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_events.c b/3rdparty/SDL2/test/testautomation_events.c deleted file mode 100644 index a0119bdbe32..00000000000 --- a/3rdparty/SDL2/test/testautomation_events.c +++ /dev/null @@ -1,201 +0,0 @@ -/** - * Events test suite - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -/* Test case functions */ - -/* Flag indicating if the userdata should be checked */ -int _userdataCheck = 0; - -/* Userdata value to check */ -int _userdataValue = 0; - -/* Flag indicating that the filter was called */ -int _eventFilterCalled = 0; - -/* Userdata values for event */ -int _userdataValue1 = 1; -int _userdataValue2 = 2; - -/* Event filter that sets some flags and optionally checks userdata */ -int _events_sampleNullEventFilter(void *userdata, SDL_Event *event) -{ - _eventFilterCalled = 1; - - if (_userdataCheck != 0) { - SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL"); - if (userdata != NULL) { - SDLTest_AssertCheck(*(int *)userdata == _userdataValue, "Check userdata value, expected: %i, got: %i", _userdataValue, *(int *)userdata); - } - } - - return 0; -} - -/** - * @brief Test pumping and peeking events. - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_PumpEvents - * @sa http://wiki.libsdl.org/moin.cgi/SDL_PollEvent - */ -int -events_pushPumpAndPollUserevent(void *arg) -{ - SDL_Event event1; - SDL_Event event2; - int result; - - /* Create user event */ - event1.type = SDL_USEREVENT; - event1.user.code = SDLTest_RandomSint32(); - event1.user.data1 = (void *)&_userdataValue1; - event1.user.data2 = (void *)&_userdataValue2; - - /* Push a user event onto the queue and force queue update */ - SDL_PushEvent(&event1); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - - /* Poll for user event */ - result = SDL_PollEvent(&event2); - SDLTest_AssertPass("Call to SDL_PollEvent()"); - SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result); - - return TEST_COMPLETED; -} - - -/** - * @brief Adds and deletes an event watch function with NULL userdata - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_AddEventWatch - * @sa http://wiki.libsdl.org/moin.cgi/SDL_DelEventWatch - * - */ -int -events_addDelEventWatch(void *arg) -{ - SDL_Event event; - - /* Create user event */ - event.type = SDL_USEREVENT; - event.user.code = SDLTest_RandomSint32(); - event.user.data1 = (void *)&_userdataValue1; - event.user.data2 = (void *)&_userdataValue2; - - /* Disable userdata check */ - _userdataCheck = 0; - - /* Reset event filter call tracker */ - _eventFilterCalled = 0; - - /* Add watch */ - SDL_AddEventWatch(_events_sampleNullEventFilter, NULL); - SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - - /* Push a user event onto the queue and force queue update */ - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); - - /* Delete watch */ - SDL_DelEventWatch(_events_sampleNullEventFilter, NULL); - SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - - /* Push a user event onto the queue and force queue update */ - _eventFilterCalled = 0; - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); - - return TEST_COMPLETED; -} - -/** - * @brief Adds and deletes an event watch function with userdata - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_AddEventWatch - * @sa http://wiki.libsdl.org/moin.cgi/SDL_DelEventWatch - * - */ -int -events_addDelEventWatchWithUserdata(void *arg) -{ - SDL_Event event; - - /* Create user event */ - event.type = SDL_USEREVENT; - event.user.code = SDLTest_RandomSint32(); - event.user.data1 = (void *)&_userdataValue1; - event.user.data2 = (void *)&_userdataValue2; - - /* Enable userdata check and set a value to check */ - _userdataCheck = 1; - _userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024); - - /* Reset event filter call tracker */ - _eventFilterCalled = 0; - - /* Add watch */ - SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); - SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - - /* Push a user event onto the queue and force queue update */ - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called"); - - /* Delete watch */ - SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); - SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - - /* Push a user event onto the queue and force queue update */ - _eventFilterCalled = 0; - SDL_PushEvent(&event); - SDLTest_AssertPass("Call to SDL_PushEvent()"); - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); - - return TEST_COMPLETED; -} - - -/* ================= Test References ================== */ - -/* Events test cases */ -static const SDLTest_TestCaseReference eventsTest1 = - { (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED }; - -static const SDLTest_TestCaseReference eventsTest2 = - { (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED }; - -static const SDLTest_TestCaseReference eventsTest3 = - { (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED }; - -/* Sequence of Events test cases */ -static const SDLTest_TestCaseReference *eventsTests[] = { - &eventsTest1, &eventsTest2, &eventsTest3, NULL -}; - -/* Events test suite (global) */ -SDLTest_TestSuiteReference eventsTestSuite = { - "Events", - NULL, - eventsTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_hints.c b/3rdparty/SDL2/test/testautomation_hints.c deleted file mode 100644 index a6beb88d764..00000000000 --- a/3rdparty/SDL2/test/testautomation_hints.c +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Hints test suite - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - - -const int _numHintsEnum = 25; -char* _HintsEnum[] = - { - SDL_HINT_ACCELEROMETER_AS_JOYSTICK, - SDL_HINT_FRAMEBUFFER_ACCELERATION, - SDL_HINT_GAMECONTROLLERCONFIG, - SDL_HINT_GRAB_KEYBOARD, - SDL_HINT_IDLE_TIMER_DISABLED, - SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, - SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, - SDL_HINT_MOUSE_RELATIVE_MODE_WARP, - SDL_HINT_ORIENTATIONS, - SDL_HINT_RENDER_DIRECT3D_THREADSAFE, - SDL_HINT_RENDER_DRIVER, - SDL_HINT_RENDER_OPENGL_SHADERS, - SDL_HINT_RENDER_SCALE_QUALITY, - SDL_HINT_RENDER_VSYNC, - SDL_HINT_TIMER_RESOLUTION, - SDL_HINT_VIDEO_ALLOW_SCREENSAVER, - SDL_HINT_VIDEO_HIGHDPI_DISABLED, - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, - SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, - SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, - SDL_HINT_VIDEO_WIN_D3DCOMPILER, - SDL_HINT_VIDEO_X11_XINERAMA, - SDL_HINT_VIDEO_X11_XRANDR, - SDL_HINT_VIDEO_X11_XVIDMODE, - SDL_HINT_XINPUT_ENABLED, - }; -char* _HintsVerbose[] = - { - "SDL_HINT_ACCELEROMETER_AS_JOYSTICK", - "SDL_HINT_FRAMEBUFFER_ACCELERATION", - "SDL_HINT_GAMECONTROLLERCONFIG", - "SDL_HINT_GRAB_KEYBOARD", - "SDL_HINT_IDLE_TIMER_DISABLED", - "SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS", - "SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK", - "SDL_HINT_MOUSE_RELATIVE_MODE_WARP", - "SDL_HINT_ORIENTATIONS", - "SDL_HINT_RENDER_DIRECT3D_THREADSAFE", - "SDL_HINT_RENDER_DRIVER", - "SDL_HINT_RENDER_OPENGL_SHADERS", - "SDL_HINT_RENDER_SCALE_QUALITY", - "SDL_HINT_RENDER_VSYNC", - "SDL_HINT_TIMER_RESOLUTION", - "SDL_HINT_VIDEO_ALLOW_SCREENSAVER", - "SDL_HINT_VIDEO_HIGHDPI_DISABLED", - "SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES", - "SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS", - "SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT", - "SDL_HINT_VIDEO_WIN_D3DCOMPILER", - "SDL_HINT_VIDEO_X11_XINERAMA", - "SDL_HINT_VIDEO_X11_XRANDR", - "SDL_HINT_VIDEO_X11_XVIDMODE", - "SDL_HINT_XINPUT_ENABLED" - }; - - -/* Test case functions */ - -/** - * @brief Call to SDL_GetHint - */ -int -hints_getHint(void *arg) -{ - char *result1; - char *result2; - int i; - - for (i=0; i<_numHintsEnum; i++) { - result1 = (char *)SDL_GetHint((char*)_HintsEnum[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]); - result2 = (char *)SDL_GetHint((char *)_HintsVerbose[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]); - SDLTest_AssertCheck( - (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0), - "Verify returned values are equal; got: result1='%s' result2='%s", - (result1 == NULL) ? "null" : result1, - (result2 == NULL) ? "null" : result2); - } - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_SetHint - */ -int -hints_setHint(void *arg) -{ - char *originalValue; - char *value; - char *testValue; - SDL_bool result; - int i, j; - - /* Create random values to set */ - value = SDLTest_RandomAsciiStringOfSize(10); - - for (i=0; i<_numHintsEnum; i++) { - /* Capture current value */ - originalValue = (char *)SDL_GetHint((char*)_HintsEnum[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s)", (char*)_HintsEnum[i]); - - /* Set value (twice) */ - for (j=1; j<=2; j++) { - result = SDL_SetHint((char*)_HintsEnum[i], value); - SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", (char*)_HintsEnum[i], value, j); - SDLTest_AssertCheck( - result == SDL_TRUE || result == SDL_FALSE, - "Verify valid result was returned, got: %i", - (int)result); - testValue = (char *)SDL_GetHint((char*)_HintsEnum[i]); - SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]); - SDLTest_AssertCheck( - (SDL_strcmp(value, testValue) == 0), - "Verify returned value equals set value; got: testValue='%s' value='%s", - (testValue == NULL) ? "null" : testValue, - value); - } - - /* Reset original value */ - result = SDL_SetHint((char*)_HintsEnum[i], originalValue); - SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", (char*)_HintsEnum[i]); - SDLTest_AssertCheck( - result == SDL_TRUE || result == SDL_FALSE, - "Verify valid result was returned, got: %i", - (int)result); - } - - SDL_free(value); - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* Hints test cases */ -static const SDLTest_TestCaseReference hintsTest1 = - { (SDLTest_TestCaseFp)hints_getHint, "hints_getHint", "Call to SDL_GetHint", TEST_ENABLED }; - -static const SDLTest_TestCaseReference hintsTest2 = - { (SDLTest_TestCaseFp)hints_setHint, "hints_setHint", "Call to SDL_SetHint", TEST_ENABLED }; - -/* Sequence of Hints test cases */ -static const SDLTest_TestCaseReference *hintsTests[] = { - &hintsTest1, &hintsTest2, NULL -}; - -/* Hints test suite (global) */ -SDLTest_TestSuiteReference hintsTestSuite = { - "Hints", - NULL, - hintsTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_keyboard.c b/3rdparty/SDL2/test/testautomation_keyboard.c deleted file mode 100644 index b2c3b9ae1f7..00000000000 --- a/3rdparty/SDL2/test/testautomation_keyboard.c +++ /dev/null @@ -1,713 +0,0 @@ -/** - * Keyboard test suite - */ - -#include <stdio.h> -#include <limits.h> - -#include "SDL_config.h" -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -/* Test case functions */ - -/** - * @brief Check call to SDL_GetKeyboardState with and without numkeys reference. - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardState - */ -int -keyboard_getKeyboardState(void *arg) -{ - int numkeys; - Uint8 *state; - - /* Case where numkeys pointer is NULL */ - state = (Uint8 *)SDL_GetKeyboardState(NULL); - SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)"); - SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); - - /* Case where numkeys pointer is not NULL */ - numkeys = -1; - state = (Uint8 *)SDL_GetKeyboardState(&numkeys); - SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)"); - SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); - SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetKeyboardFocus - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardFocus - */ -int -keyboard_getKeyboardFocus(void *arg) -{ - SDL_Window* window; - - /* Call, but ignore return value */ - window = SDL_GetKeyboardFocus(); - SDLTest_AssertPass("Call to SDL_GetKeyboardFocus()"); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetKeyFromName for known, unknown and invalid name. - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromName - */ -int -keyboard_getKeyFromName(void *arg) -{ - SDL_Keycode result; - - /* Case where Key is known, 1 character input */ - result = SDL_GetKeyFromName("A"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/single)"); - SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result); - - /* Case where Key is known, 2 character input */ - result = SDL_GetKeyFromName("F1"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/double)"); - SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %i, got: %i", SDLK_F1, result); - - /* Case where Key is known, 3 character input */ - result = SDL_GetKeyFromName("End"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/triple)"); - SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %i, got: %i", SDLK_END, result); - - /* Case where Key is known, 4 character input */ - result = SDL_GetKeyFromName("Find"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/quad)"); - SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %i, got: %i", SDLK_FIND, result); - - /* Case where Key is known, multiple character input */ - result = SDL_GetKeyFromName("AudioStop"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/multi)"); - SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %i, got: %i", SDLK_AUDIOSTOP, result); - - /* Case where Key is unknown */ - result = SDL_GetKeyFromName("NotThere"); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(unknown)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result); - - /* Case where input is NULL/invalid */ - result = SDL_GetKeyFromName(NULL); - SDLTest_AssertPass("Call to SDL_GetKeyFromName(NULL)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result); - - return TEST_COMPLETED; -} - -/* - * Local helper to check for the invalid scancode error message - */ -void -_checkInvalidScancodeError() -{ - const char *expectedError = "Parameter 'scancode' is invalid"; - const char *error; - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } -} - -/** - * @brief Check call to SDL_GetKeyFromScancode - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode - */ -int -keyboard_getKeyFromScancode(void *arg) -{ - SDL_Keycode result; - - /* Case where input is valid */ - result = SDL_GetKeyFromScancode(SDL_SCANCODE_A); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)"); - SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result); - - /* Case where input is zero */ - result = SDL_GetKeyFromScancode(0); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result); - - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* Case where input is invalid (too small) */ - result = SDL_GetKeyFromScancode(-999); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result); - _checkInvalidScancodeError(); - - /* Case where input is invalid (too big) */ - result = SDL_GetKeyFromScancode(999); - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)"); - SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result); - _checkInvalidScancodeError(); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetKeyName - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName - */ -int -keyboard_getKeyName(void *arg) -{ - char *result; - char *expected; - - /* Case where key has a 1 character name */ - expected = "3"; - result = (char *)SDL_GetKeyName(SDLK_3); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - - /* Case where key has a 2 character name */ - expected = "F1"; - result = (char *)SDL_GetKeyName(SDLK_F1); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - - /* Case where key has a 3 character name */ - expected = "Cut"; - result = (char *)SDL_GetKeyName(SDLK_CUT); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - - /* Case where key has a 4 character name */ - expected = "Down"; - result = (char *)SDL_GetKeyName(SDLK_DOWN); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - - /* Case where key has a N character name */ - expected = "BrightnessUp"; - result = (char *)SDL_GetKeyName(SDLK_BRIGHTNESSUP); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - - /* Case where key has a N character name with space */ - expected = "Keypad MemStore"; - result = (char *)SDL_GetKeyName(SDLK_KP_MEMSTORE); - SDLTest_AssertPass("Call to SDL_GetKeyName()"); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result); - - return TEST_COMPLETED; -} - -/** - * @brief SDL_GetScancodeName negative cases - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName - */ -int -keyboard_getScancodeNameNegative(void *arg) -{ - SDL_Scancode scancode; - char *result; - char *expected = ""; - - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* Out-of-bounds scancode */ - scancode = (SDL_Scancode)SDL_NUM_SCANCODES; - result = (char *)SDL_GetScancodeName(scancode); - SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); - _checkInvalidScancodeError(); - - return TEST_COMPLETED; -} - -/** - * @brief SDL_GetKeyName negative cases - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName - */ -int -keyboard_getKeyNameNegative(void *arg) -{ - SDL_Keycode keycode; - char *result; - char *expected = ""; - - /* Unknown keycode */ - keycode = SDLK_UNKNOWN; - result = (char *)SDL_GetKeyName(keycode); - SDLTest_AssertPass("Call to SDL_GetKeyName(%d/unknown)", keycode); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); - - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* Negative keycode */ - keycode = (SDL_Keycode)SDLTest_RandomIntegerInRange(-255, -1); - result = (char *)SDL_GetKeyName(keycode); - SDLTest_AssertPass("Call to SDL_GetKeyName(%d/negative)", keycode); - SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); - SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result); - _checkInvalidScancodeError(); - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetModState and SDL_SetModState - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetModState - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetModState - */ -int -keyboard_getSetModState(void *arg) -{ - SDL_Keymod result; - SDL_Keymod currentState; - SDL_Keymod newState; - SDL_Keymod allStates = - KMOD_NONE | - KMOD_LSHIFT | - KMOD_RSHIFT | - KMOD_LCTRL | - KMOD_RCTRL | - KMOD_LALT | - KMOD_RALT | - KMOD_LGUI | - KMOD_RGUI | - KMOD_NUM | - KMOD_CAPS | - KMOD_MODE | - KMOD_RESERVED; - - /* Get state, cache for later reset */ - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result); - currentState = result; - - /* Set random state */ - newState = SDLTest_RandomIntegerInRange(0, allStates); - SDL_SetModState(newState); - SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState); - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %i, got: %i", newState, result); - - /* Set zero state */ - SDL_SetModState(0); - SDLTest_AssertPass("Call to SDL_SetModState(0)"); - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %i", result); - - /* Revert back to cached current state if needed */ - if (currentState != 0) { - SDL_SetModState(currentState); - SDLTest_AssertPass("Call to SDL_SetModState(%i)", currentState); - result = SDL_GetModState(); - SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %i, got: %i", currentState, result); - } - - return TEST_COMPLETED; -} - - -/** - * @brief Check call to SDL_StartTextInput and SDL_StopTextInput - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput - * @sa http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput - */ -int -keyboard_startStopTextInput(void *arg) -{ - /* Start-Stop */ - SDL_StartTextInput(); - SDLTest_AssertPass("Call to SDL_StartTextInput()"); - SDL_StopTextInput(); - SDLTest_AssertPass("Call to SDL_StopTextInput()"); - - /* Stop-Start */ - SDL_StartTextInput(); - SDLTest_AssertPass("Call to SDL_StartTextInput()"); - - /* Start-Start */ - SDL_StartTextInput(); - SDLTest_AssertPass("Call to SDL_StartTextInput()"); - - /* Stop-Stop */ - SDL_StopTextInput(); - SDLTest_AssertPass("Call to SDL_StopTextInput()"); - SDL_StopTextInput(); - SDLTest_AssertPass("Call to SDL_StopTextInput()"); - - return TEST_COMPLETED; -} - -/* Internal function to test SDL_SetTextInputRect */ -void _testSetTextInputRect(SDL_Rect refRect) -{ - SDL_Rect testRect; - - testRect = refRect; - SDL_SetTextInputRect(&testRect); - SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h); - SDLTest_AssertCheck( - (refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h), - "Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i", - refRect.x, refRect.y, refRect.w, refRect.h, - testRect.x, testRect.y, testRect.w, testRect.h); -} - -/** - * @brief Check call to SDL_SetTextInputRect - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect - */ -int -keyboard_setTextInputRect(void *arg) -{ - SDL_Rect refRect; - - /* Normal visible refRect, origin inside */ - refRect.x = SDLTest_RandomIntegerInRange(1, 50); - refRect.y = SDLTest_RandomIntegerInRange(1, 50); - refRect.w = SDLTest_RandomIntegerInRange(10, 50); - refRect.h = SDLTest_RandomIntegerInRange(10, 50); - _testSetTextInputRect(refRect); - - /* Normal visible refRect, origin 0,0 */ - refRect.x = 0; - refRect.y = 0; - refRect.w = SDLTest_RandomIntegerInRange(10, 50); - refRect.h = SDLTest_RandomIntegerInRange(10, 50); - _testSetTextInputRect(refRect); - - /* 1Pixel refRect */ - refRect.x = SDLTest_RandomIntegerInRange(10, 50); - refRect.y = SDLTest_RandomIntegerInRange(10, 50); - refRect.w = 1; - refRect.h = 1; - _testSetTextInputRect(refRect); - - /* 0pixel refRect */ - refRect.x = 1; - refRect.y = 1; - refRect.w = 1; - refRect.h = 0; - _testSetTextInputRect(refRect); - - /* 0pixel refRect */ - refRect.x = 1; - refRect.y = 1; - refRect.w = 0; - refRect.h = 1; - _testSetTextInputRect(refRect); - - /* 0pixel refRect */ - refRect.x = 1; - refRect.y = 1; - refRect.w = 0; - refRect.h = 0; - _testSetTextInputRect(refRect); - - /* 0pixel refRect */ - refRect.x = 0; - refRect.y = 0; - refRect.w = 0; - refRect.h = 0; - _testSetTextInputRect(refRect); - - /* negative refRect */ - refRect.x = SDLTest_RandomIntegerInRange(-200, -100); - refRect.y = SDLTest_RandomIntegerInRange(-200, -100); - refRect.w = 50; - refRect.h = 50; - _testSetTextInputRect(refRect); - - /* oversized refRect */ - refRect.x = SDLTest_RandomIntegerInRange(1, 50); - refRect.y = SDLTest_RandomIntegerInRange(1, 50); - refRect.w = 5000; - refRect.h = 5000; - _testSetTextInputRect(refRect); - - /* NULL refRect */ - SDL_SetTextInputRect(NULL); - SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_SetTextInputRect with invalid data - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect - */ -int -keyboard_setTextInputRectNegative(void *arg) -{ - /* Some platforms set also an error message; prepare for checking it */ -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA - const char *expectedError = "Parameter 'rect' is invalid"; - const char *error; - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); -#endif - - /* NULL refRect */ - SDL_SetTextInputRect(NULL); - SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); - - /* Some platforms set also an error message; so check it */ -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); -#endif - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetScancodeFromKey - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey - * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode - */ -int -keyboard_getScancodeFromKey(void *arg) -{ - SDL_Scancode scancode; - - /* Regular key */ - scancode = SDL_GetScancodeFromKey(SDLK_4); - SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode); - - /* Virtual key */ - scancode = SDL_GetScancodeFromKey(SDLK_PLUS); - SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)"); - SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetScancodeFromName - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName - * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode - */ -int -keyboard_getScancodeFromName(void *arg) -{ - SDL_Scancode scancode; - - /* Regular key, 1 character, first name in list */ - scancode = SDL_GetScancodeFromName("A"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode); - - /* Regular key, 1 character */ - scancode = SDL_GetScancodeFromName("4"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode); - - /* Regular key, 2 characters */ - scancode = SDL_GetScancodeFromName("F1"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode); - - /* Regular key, 3 characters */ - scancode = SDL_GetScancodeFromName("End"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode); - - /* Regular key, 4 characters */ - scancode = SDL_GetScancodeFromName("Find"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode); - - /* Regular key, several characters */ - scancode = SDL_GetScancodeFromName("Backspace"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode); - - /* Regular key, several characters with space */ - scancode = SDL_GetScancodeFromName("Keypad Enter"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode); - - /* Regular key, last name in list */ - scancode = SDL_GetScancodeFromName("Sleep"); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode); - - return TEST_COMPLETED; -} - -/* - * Local helper to check for the invalid scancode error message - */ -void -_checkInvalidNameError() -{ - const char *expectedError = "Parameter 'name' is invalid"; - const char *error; - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } -} - -/** - * @brief Check call to SDL_GetScancodeFromName with invalid data - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName - * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode - */ -int -keyboard_getScancodeFromNameNegative(void *arg) -{ - char *name; - SDL_Scancode scancode; - - /* Clear error message */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* Random string input */ - name = SDLTest_RandomAsciiStringOfSize(32); - SDLTest_Assert(name != NULL, "Check that random name is not NULL"); - if (name == NULL) { - return TEST_ABORTED; - } - scancode = SDL_GetScancodeFromName((const char *)name); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name); - SDL_free(name); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); - _checkInvalidNameError(); - - /* Zero length string input */ - name = ""; - scancode = SDL_GetScancodeFromName((const char *)name); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); - _checkInvalidNameError(); - - /* NULL input */ - name = NULL; - scancode = SDL_GetScancodeFromName((const char *)name); - SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); - _checkInvalidNameError(); - - return TEST_COMPLETED; -} - - - -/* ================= Test References ================== */ - -/* Keyboard test cases */ -static const SDLTest_TestCaseReference keyboardTest1 = - { (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest2 = - { (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest3 = - { (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest4 = - { (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest5 = - { (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest6 = - { (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest7 = - { (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest8 = - { (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest9 = - { (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest10 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest11 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest12 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest13 = - { (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED }; - -static const SDLTest_TestCaseReference keyboardTest14 = - { (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED }; - -/* Sequence of Keyboard test cases */ -static const SDLTest_TestCaseReference *keyboardTests[] = { - &keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6, - &keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12, - &keyboardTest13, &keyboardTest14, NULL -}; - -/* Keyboard test suite (global) */ -SDLTest_TestSuiteReference keyboardTestSuite = { - "Keyboard", - NULL, - keyboardTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_main.c b/3rdparty/SDL2/test/testautomation_main.c deleted file mode 100644 index ae060cdd1a4..00000000000 --- a/3rdparty/SDL2/test/testautomation_main.c +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Automated SDL subsystems management test. - * - * Written by J�rgen Tjern� "jorgenpt" - * - * Released under Public Domain. - */ - -#include "SDL.h" -#include "SDL_test.h" - - -/* ! - * \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_Init - * http://wiki.libsdl.org/moin.cgi/SDL_Quit - */ -static int main_testInitQuitJoystickHaptic (void *arg) -{ -#if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED - return TEST_SKIPPED; -#else - int enabled_subsystems; - int initialized_subsystems = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC; - - SDLTest_AssertCheck( SDL_Init(initialized_subsystems) == 0, "SDL_Init multiple systems." ); - - enabled_subsystems = SDL_WasInit(initialized_subsystems); - SDLTest_AssertCheck( enabled_subsystems == initialized_subsystems, "SDL_WasInit(SDL_INIT_EVERYTHING) contains all systems (%i)", enabled_subsystems ); - - SDL_Quit(); - - enabled_subsystems = SDL_WasInit(initialized_subsystems); - SDLTest_AssertCheck( enabled_subsystems == 0, "SDL_Quit should shut down everything (%i)", enabled_subsystems ); - - return TEST_COMPLETED; -#endif -} - -/* ! - * \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem() - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_Init - * http://wiki.libsdl.org/moin.cgi/SDL_Quit - */ -static int main_testInitQuitSubSystem (void *arg) -{ -#if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED || defined SDL_GAMECONTROLLER_DISABLED - return TEST_SKIPPED; -#else - int i; - int subsystems[] = { SDL_INIT_JOYSTICK, SDL_INIT_HAPTIC, SDL_INIT_GAMECONTROLLER }; - - for (i = 0; i < SDL_arraysize(subsystems); ++i) { - int initialized_system; - int subsystem = subsystems[i]; - - SDLTest_AssertCheck( (SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) before init should be false", subsystem ); - SDLTest_AssertCheck( SDL_InitSubSystem(subsystem) == 0, "SDL_InitSubSystem(%x)", subsystem ); - - initialized_system = SDL_WasInit(subsystem); - SDLTest_AssertCheck( (initialized_system & subsystem) != 0, "SDL_WasInit(%x) should be true (%x)", subsystem, initialized_system ); - - SDL_QuitSubSystem(subsystem); - - SDLTest_AssertCheck( (SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) after shutdown should be false", subsystem ); - } - - return TEST_COMPLETED; -#endif -} - -const int joy_and_controller = SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER; -static int main_testImpliedJoystickInit (void *arg) -{ -#if defined SDL_JOYSTICK_DISABLED || defined SDL_GAMECONTROLLER_DISABLED - return TEST_SKIPPED; -#else - int initialized_system; - - /* First initialize the controller */ - SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); - SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); - - /* Then make sure this implicitly initialized the joystick subsystem */ - initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); - - /* Then quit the controller, and make sure that implicitly also quits the */ - /* joystick subsystem */ - SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); - initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); - - return TEST_COMPLETED; -#endif -} - -static int main_testImpliedJoystickQuit (void *arg) -{ -#if defined SDL_JOYSTICK_DISABLED || defined SDL_GAMECONTROLLER_DISABLED - return TEST_SKIPPED; -#else - int initialized_system; - - /* First initialize the controller and the joystick (explicitly) */ - SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); - SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)" ); - SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); - - /* Then make sure they're both initialized properly */ - initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); - - /* Then quit the controller, and make sure that it does NOT quit the */ - /* explicitly initialized joystick subsystem. */ - SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); - initialized_system = SDL_WasInit(joy_and_controller); - SDLTest_AssertCheck( (initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); - - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - - return TEST_COMPLETED; -#endif -} - -static const SDLTest_TestCaseReference mainTest1 = - { (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED}; - -static const SDLTest_TestCaseReference mainTest2 = - { (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED}; - -static const SDLTest_TestCaseReference mainTest3 = - { (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED}; - -static const SDLTest_TestCaseReference mainTest4 = - { (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED}; - -/* Sequence of Main test cases */ -static const SDLTest_TestCaseReference *mainTests[] = { - &mainTest1, - &mainTest2, - &mainTest3, - &mainTest4, - NULL -}; - -/* Main test suite (global) */ -SDLTest_TestSuiteReference mainTestSuite = { - "Main", - NULL, - mainTests, - NULL -}; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testautomation_mouse.c b/3rdparty/SDL2/test/testautomation_mouse.c deleted file mode 100644 index 57cadee2eb7..00000000000 --- a/3rdparty/SDL2/test/testautomation_mouse.c +++ /dev/null @@ -1,594 +0,0 @@ -/** - * Mouse test suite - */ - -#include <stdio.h> -#include <limits.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -/* Test case functions */ - -/* Helper to evaluate state returned from SDL_GetMouseState */ -int _mouseStateCheck(Uint32 state) -{ - return (state == 0) || - (state == SDL_BUTTON(SDL_BUTTON_LEFT)) || - (state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) || - (state == SDL_BUTTON(SDL_BUTTON_RIGHT)) || - (state == SDL_BUTTON(SDL_BUTTON_X1)) || - (state == SDL_BUTTON(SDL_BUTTON_X2)); -} - -/** - * @brief Check call to SDL_GetMouseState - * - */ -int -mouse_getMouseState(void *arg) -{ - int x; - int y; - Uint32 state; - - /* Pump some events to update mouse state */ - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - - /* Case where x, y pointer is NULL */ - state = SDL_GetMouseState(NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)"); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - /* Case where x pointer is not NULL */ - x = INT_MIN; - state = SDL_GetMouseState(&x, NULL); - SDLTest_AssertPass("Call to SDL_GetMouseState(&x, NULL)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - /* Case where y pointer is not NULL */ - y = INT_MIN; - state = SDL_GetMouseState(NULL, &y); - SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, &y)"); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - /* Case where x and y pointer is not NULL */ - x = INT_MIN; - y = INT_MIN; - state = SDL_GetMouseState(&x, &y); - SDLTest_AssertPass("Call to SDL_GetMouseState(&x, &y)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetRelativeMouseState - * - */ -int -mouse_getRelativeMouseState(void *arg) -{ - int x; - int y; - Uint32 state; - - /* Pump some events to update mouse state */ - SDL_PumpEvents(); - SDLTest_AssertPass("Call to SDL_PumpEvents()"); - - /* Case where x, y pointer is NULL */ - state = SDL_GetRelativeMouseState(NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)"); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - /* Case where x pointer is not NULL */ - x = INT_MIN; - state = SDL_GetRelativeMouseState(&x, NULL); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, NULL)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - /* Case where y pointer is not NULL */ - y = INT_MIN; - state = SDL_GetRelativeMouseState(NULL, &y); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, &y)"); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - /* Case where x and y pointer is not NULL */ - x = INT_MIN; - y = INT_MIN; - state = SDL_GetRelativeMouseState(&x, &y); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, &y)"); - SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); - SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); - SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - - return TEST_COMPLETED; -} - - -/* XPM definition of mouse Cursor */ -static const char *_mouseArrowData[] = { - /* 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 ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " " -}; - -/* Helper that creates a new mouse cursor from an XPM */ -static SDL_Cursor *_initArrowCursor(const char *image[]) -{ - SDL_Cursor *cursor; - int i, row, col; - Uint8 data[4*32]; - Uint8 mask[4*32]; - - 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 (image[row][col]) { - case 'X': - data[i] |= 0x01; - mask[i] |= 0x01; - break; - case '.': - mask[i] |= 0x01; - break; - case ' ': - break; - } - } - } - - cursor = SDL_CreateCursor(data, mask, 32, 32, 0, 0); - return cursor; -} - -/** - * @brief Check call to SDL_CreateCursor and SDL_FreeCursor - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateCursor - * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor - */ -int -mouse_createFreeCursor(void *arg) -{ - SDL_Cursor *cursor; - - /* Create a cursor */ - cursor = _initArrowCursor(_mouseArrowData); - SDLTest_AssertPass("Call to SDL_CreateCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); - if (cursor == NULL) { - return TEST_ABORTED; - } - - /* Free cursor again */ - SDL_FreeCursor(cursor); - SDLTest_AssertPass("Call to SDL_FreeCursor()"); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_CreateColorCursor and SDL_FreeCursor - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateColorCursor - * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor - */ -int -mouse_createFreeColorCursor(void *arg) -{ - SDL_Surface *face; - SDL_Cursor *cursor; - - /* Get sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Validate sample input image is not NULL"); - if (face == NULL) return TEST_ABORTED; - - /* Create a color cursor from surface */ - cursor = SDL_CreateColorCursor(face, 0, 0); - SDLTest_AssertPass("Call to SDL_CreateColorCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL"); - if (cursor == NULL) { - SDL_FreeSurface(face); - return TEST_ABORTED; - } - - /* Free cursor again */ - SDL_FreeCursor(cursor); - SDLTest_AssertPass("Call to SDL_FreeCursor()"); - - /* Clean up */ - SDL_FreeSurface(face); - - return TEST_COMPLETED; -} - -/* Helper that changes cursor visibility */ -void _changeCursorVisibility(int state) -{ - int oldState; - int newState; - int result; - - oldState = SDL_ShowCursor(SDL_QUERY); - SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); - - result = SDL_ShowCursor(state); - SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE"); - SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i", - (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result); - - newState = SDL_ShowCursor(SDL_QUERY); - SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); - SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i", - state, newState); -} - -/** - * @brief Check call to SDL_ShowCursor - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_ShowCursor - */ -int -mouse_showCursor(void *arg) -{ - int currentState; - - /* Get current state */ - currentState = SDL_ShowCursor(SDL_QUERY); - SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); - SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE, - "Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState); - if (currentState == SDL_DISABLE) { - /* Show the cursor, then hide it again */ - _changeCursorVisibility(SDL_ENABLE); - _changeCursorVisibility(SDL_DISABLE); - } else if (currentState == SDL_ENABLE) { - /* Hide the cursor, then show it again */ - _changeCursorVisibility(SDL_DISABLE); - _changeCursorVisibility(SDL_ENABLE); - } else { - return TEST_ABORTED; - } - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_SetCursor - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetCursor - */ -int -mouse_setCursor(void *arg) -{ - SDL_Cursor *cursor; - - /* Create a cursor */ - cursor = _initArrowCursor(_mouseArrowData); - SDLTest_AssertPass("Call to SDL_CreateCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); - if (cursor == NULL) { - return TEST_ABORTED; - } - - /* Set the arrow cursor */ - SDL_SetCursor(cursor); - SDLTest_AssertPass("Call to SDL_SetCursor(cursor)"); - - /* Force redraw */ - SDL_SetCursor(NULL); - SDLTest_AssertPass("Call to SDL_SetCursor(NULL)"); - - /* Free cursor again */ - SDL_FreeCursor(cursor); - SDLTest_AssertPass("Call to SDL_FreeCursor()"); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetCursor - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetCursor - */ -int -mouse_getCursor(void *arg) -{ - SDL_Cursor *cursor; - - /* Get current cursor */ - cursor = SDL_GetCursor(); - SDLTest_AssertPass("Call to SDL_GetCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL"); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetRelativeMouseMode - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetRelativeMouseMode - */ -int -mouse_getSetRelativeMouseMode(void *arg) -{ - int result; - int i; - SDL_bool initialState; - SDL_bool currentState; - - /* Capture original state so we can revert back to it later */ - initialState = SDL_GetRelativeMouseMode(); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); - - /* Repeat twice to check D->D transition */ - for (i=0; i<2; i++) { - /* Disable - should always be supported */ - result = SDL_SetRelativeMouseMode(SDL_FALSE); - SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); - SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); - SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); - } - - /* Repeat twice to check D->E->E transition */ - for (i=0; i<2; i++) { - /* Enable - may not be supported */ - result = SDL_SetRelativeMouseMode(SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(TRUE)"); - if (result != -1) { - SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); - SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState); - } - } - - /* Disable to check E->D transition */ - result = SDL_SetRelativeMouseMode(SDL_FALSE); - SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); - SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); - SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); - SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); - - /* Revert to original state - ignore result */ - result = SDL_SetRelativeMouseMode(initialState); - - return TEST_COMPLETED; -} - -#define MOUSE_TESTWINDOW_WIDTH 320 -#define MOUSE_TESTWINDOW_HEIGHT 200 - -/** - * Creates a test window - */ -SDL_Window *_createMouseSuiteTestWindow() -{ - int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT; - SDL_Window *window; - window = SDL_CreateWindow("mouse_createMouseSuiteTestWindow", posX, posY, width, height, 0); - SDLTest_AssertPass("SDL_CreateWindow()"); - SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); - return window; -} - -/* - * Destroy test window - */ -void _destroyMouseSuiteTestWindow(SDL_Window *window) -{ - if (window != NULL) { - SDL_DestroyWindow(window); - window = NULL; - SDLTest_AssertPass("SDL_DestroyWindow()"); - } -} - -/** - * @brief Check call to SDL_WarpMouseInWindow - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_WarpMouseInWindow - */ -int -mouse_warpMouseInWindow(void *arg) -{ - const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT; - int numPositions = 6; - int xPositions[] = {-1, 0, 1, w-1, w, w+1 }; - int yPositions[] = {-1, 0, 1, h-1, h, h+1 }; - int x, y, i, j; - SDL_Window *window; - - /* Create test window */ - window = _createMouseSuiteTestWindow(); - if (window == NULL) return TEST_ABORTED; - - /* Mouse to random position inside window */ - x = SDLTest_RandomIntegerInRange(1, w-1); - y = SDLTest_RandomIntegerInRange(1, h-1); - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - - /* Same position again */ - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - - /* Mouse to various boundary positions */ - for (i=0; i<numPositions; i++) { - for (j=0; j<numPositions; j++) { - x = xPositions[i]; - y = yPositions[j]; - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - - /* TODO: add tracking of events and check that each call generates a mouse motion event */ - SDL_PumpEvents(); - SDLTest_AssertPass("SDL_PumpEvents()"); - } - } - - - /* Clean up test window */ - _destroyMouseSuiteTestWindow(window); - - return TEST_COMPLETED; -} - -/** - * @brief Check call to SDL_GetMouseFocus - * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetMouseFocus - */ -int -mouse_getMouseFocus(void *arg) -{ - const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT; - int x, y; - SDL_Window *window; - SDL_Window *focusWindow; - - /* Get focus - focus non-deterministic */ - focusWindow = SDL_GetMouseFocus(); - SDLTest_AssertPass("SDL_GetMouseFocus()"); - - /* Create test window */ - window = _createMouseSuiteTestWindow(); - if (window == NULL) return TEST_ABORTED; - - /* Mouse to random position inside window */ - x = SDLTest_RandomIntegerInRange(1, w-1); - y = SDLTest_RandomIntegerInRange(1, h-1); - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - - /* Pump events to update focus state */ - SDL_PumpEvents(); - SDLTest_AssertPass("SDL_PumpEvents()"); - - /* Get focus with explicit window setup - focus deterministic */ - focusWindow = SDL_GetMouseFocus(); - SDLTest_AssertPass("SDL_GetMouseFocus()"); - SDLTest_AssertCheck (focusWindow != NULL, "Check returned window value is not NULL"); - SDLTest_AssertCheck (focusWindow == window, "Check returned window value is test window"); - - /* Mouse to random position outside window */ - x = SDLTest_RandomIntegerInRange(-9, -1); - y = SDLTest_RandomIntegerInRange(-9, -1); - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - - /* Clean up test window */ - _destroyMouseSuiteTestWindow(window); - - /* Pump events to update focus state */ - SDL_PumpEvents(); - SDLTest_AssertPass("SDL_PumpEvents()"); - - /* Get focus for non-existing window */ - focusWindow = SDL_GetMouseFocus(); - SDLTest_AssertPass("SDL_GetMouseFocus()"); - SDLTest_AssertCheck (focusWindow == NULL, "Check returned window value is NULL"); - - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* Mouse test cases */ -static const SDLTest_TestCaseReference mouseTest1 = - { (SDLTest_TestCaseFp)mouse_getMouseState, "mouse_getMouseState", "Check call to SDL_GetMouseState", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest2 = - { (SDLTest_TestCaseFp)mouse_getRelativeMouseState, "mouse_getRelativeMouseState", "Check call to SDL_GetRelativeMouseState", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest3 = - { (SDLTest_TestCaseFp)mouse_createFreeCursor, "mouse_createFreeCursor", "Check call to SDL_CreateCursor and SDL_FreeCursor", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest4 = - { (SDLTest_TestCaseFp)mouse_showCursor, "mouse_showCursor", "Check call to SDL_ShowCursor", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest5 = - { (SDLTest_TestCaseFp)mouse_setCursor, "mouse_setCursor", "Check call to SDL_SetCursor", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest6 = - { (SDLTest_TestCaseFp)mouse_getCursor, "mouse_getCursor", "Check call to SDL_GetCursor", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest7 = - { (SDLTest_TestCaseFp)mouse_warpMouseInWindow, "mouse_warpMouseInWindow", "Check call to SDL_WarpMouseInWindow", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest8 = - { (SDLTest_TestCaseFp)mouse_getMouseFocus, "mouse_getMouseFocus", "Check call to SDL_getMouseFocus", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest9 = - { (SDLTest_TestCaseFp)mouse_createFreeColorCursor, "mouse_createFreeColorCursor", "Check call to SDL_CreateColorCursor and SDL_FreeCursor", TEST_ENABLED }; - -static const SDLTest_TestCaseReference mouseTest10 = - { (SDLTest_TestCaseFp)mouse_getSetRelativeMouseMode, "mouse_getSetRelativeMouseMode", "Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode", TEST_ENABLED }; - -/* Sequence of Mouse test cases */ -static const SDLTest_TestCaseReference *mouseTests[] = { - &mouseTest1, &mouseTest2, &mouseTest3, &mouseTest4, &mouseTest5, &mouseTest6, - &mouseTest7, &mouseTest8, &mouseTest9, &mouseTest10, NULL -}; - -/* Mouse test suite (global) */ -SDLTest_TestSuiteReference mouseTestSuite = { - "Mouse", - NULL, - mouseTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_pixels.c b/3rdparty/SDL2/test/testautomation_pixels.c deleted file mode 100644 index 7b88caaa9da..00000000000 --- a/3rdparty/SDL2/test/testautomation_pixels.c +++ /dev/null @@ -1,529 +0,0 @@ -/** - * Pixels test suite - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* Test case functions */ - -/* Definition of all RGB formats used to test pixel conversions */ -const int _numRGBPixelFormats = 30; -Uint32 _RGBPixelFormats[] = - { - SDL_PIXELFORMAT_INDEX1LSB, - SDL_PIXELFORMAT_INDEX1MSB, - SDL_PIXELFORMAT_INDEX4LSB, - SDL_PIXELFORMAT_INDEX4MSB, - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB332, - SDL_PIXELFORMAT_RGB444, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_BGR555, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_RGBA4444, - SDL_PIXELFORMAT_ABGR4444, - SDL_PIXELFORMAT_BGRA4444, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGBA5551, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGRA5551, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_BGR565, - SDL_PIXELFORMAT_RGB24, - SDL_PIXELFORMAT_BGR24, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_RGBX8888, - SDL_PIXELFORMAT_BGR888, - SDL_PIXELFORMAT_BGRX8888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_ARGB2101010 - }; -char* _RGBPixelFormatsVerbose[] = - { - "SDL_PIXELFORMAT_INDEX1LSB", - "SDL_PIXELFORMAT_INDEX1MSB", - "SDL_PIXELFORMAT_INDEX4LSB", - "SDL_PIXELFORMAT_INDEX4MSB", - "SDL_PIXELFORMAT_INDEX8", - "SDL_PIXELFORMAT_RGB332", - "SDL_PIXELFORMAT_RGB444", - "SDL_PIXELFORMAT_RGB555", - "SDL_PIXELFORMAT_BGR555", - "SDL_PIXELFORMAT_ARGB4444", - "SDL_PIXELFORMAT_RGBA4444", - "SDL_PIXELFORMAT_ABGR4444", - "SDL_PIXELFORMAT_BGRA4444", - "SDL_PIXELFORMAT_ARGB1555", - "SDL_PIXELFORMAT_RGBA5551", - "SDL_PIXELFORMAT_ABGR1555", - "SDL_PIXELFORMAT_BGRA5551", - "SDL_PIXELFORMAT_RGB565", - "SDL_PIXELFORMAT_BGR565", - "SDL_PIXELFORMAT_RGB24", - "SDL_PIXELFORMAT_BGR24", - "SDL_PIXELFORMAT_RGB888", - "SDL_PIXELFORMAT_RGBX8888", - "SDL_PIXELFORMAT_BGR888", - "SDL_PIXELFORMAT_BGRX8888", - "SDL_PIXELFORMAT_ARGB8888", - "SDL_PIXELFORMAT_RGBA8888", - "SDL_PIXELFORMAT_ABGR8888", - "SDL_PIXELFORMAT_BGRA8888", - "SDL_PIXELFORMAT_ARGB2101010" - }; - -/* Definition of all Non-RGB formats used to test pixel conversions */ -const int _numNonRGBPixelFormats = 7; -Uint32 _nonRGBPixelFormats[] = - { - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU, - SDL_PIXELFORMAT_NV12, - SDL_PIXELFORMAT_NV21 - }; -char* _nonRGBPixelFormatsVerbose[] = - { - "SDL_PIXELFORMAT_YV12", - "SDL_PIXELFORMAT_IYUV", - "SDL_PIXELFORMAT_YUY2", - "SDL_PIXELFORMAT_UYVY", - "SDL_PIXELFORMAT_YVYU", - "SDL_PIXELFORMAT_NV12", - "SDL_PIXELFORMAT_NV21" - }; - -/* Definition of some invalid formats for negative tests */ -const int _numInvalidPixelFormats = 2; -Uint32 _invalidPixelFormats[] = - { - 0xfffffffe, - 0xffffffff - }; -char* _invalidPixelFormatsVerbose[] = - { - "SDL_PIXELFORMAT_UNKNOWN", - "SDL_PIXELFORMAT_UNKNOWN" - }; - -/* Test case functions */ - -/** - * @brief Call to SDL_AllocFormat and SDL_FreeFormat - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocFormat - * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat - */ -int -pixels_allocFreeFormat(void *arg) -{ - const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN"; - const char *expectedError = "Parameter 'format' is invalid"; - const char *error; - int i; - Uint32 format; - Uint32 masks; - SDL_PixelFormat* result; - - /* Blank/unknown format */ - format = 0; - SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format); - - /* Allocate format */ - result = SDL_AllocFormat(format); - SDLTest_AssertPass("Call to SDL_AllocFormat()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format); - SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel); - SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel); - masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; - SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %u", masks); - - /* Deallocate again */ - SDL_FreeFormat(result); - SDLTest_AssertPass("Call to SDL_FreeFormat()"); - } - - /* RGB formats */ - for (i = 0; i < _numRGBPixelFormats; i++) { - format = _RGBPixelFormats[i]; - SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format); - - /* Allocate format */ - result = SDL_AllocFormat(format); - SDLTest_AssertPass("Call to SDL_AllocFormat()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format); - SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel); - SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel); - if (result->palette != NULL) { - masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; - SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %u", masks); - } - - /* Deallocate again */ - SDL_FreeFormat(result); - SDLTest_AssertPass("Call to SDL_FreeFormat()"); - } - } - - /* Non-RGB formats */ - for (i = 0; i < _numNonRGBPixelFormats; i++) { - format = _nonRGBPixelFormats[i]; - SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format); - - /* Try to allocate format */ - result = SDL_AllocFormat(format); - SDLTest_AssertPass("Call to SDL_AllocFormat()"); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); - } - - /* Negative cases */ - - /* Invalid Formats */ - for (i = 0; i < _numInvalidPixelFormats; i++) { - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - format = _invalidPixelFormats[i]; - result = SDL_AllocFormat(format); - SDLTest_AssertPass("Call to SDL_AllocFormat(%u)", format); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } - } - - /* Invalid free pointer */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_FreeFormat(NULL); - SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_GetPixelFormatName - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetPixelFormatName - */ -int -pixels_getPixelFormatName(void *arg) -{ - const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN"; - const char *error; - int i; - Uint32 format; - char* result; - - /* Blank/undefined format */ - format = 0; - SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format); - - /* Get name of format */ - result = (char *)SDL_GetPixelFormatName(format); - SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, - "Verify result text; expected: %s, got %s", unknownFormat, result); - } - - /* RGB formats */ - for (i = 0; i < _numRGBPixelFormats; i++) { - format = _RGBPixelFormats[i]; - SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format); - - /* Get name of format */ - result = (char *)SDL_GetPixelFormatName(format); - SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, - "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result); - } - } - - /* Non-RGB formats */ - for (i = 0; i < _numNonRGBPixelFormats; i++) { - format = _nonRGBPixelFormats[i]; - SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format); - - /* Get name of format */ - result = (char *)SDL_GetPixelFormatName(format); - SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, - "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result); - } - } - - /* Negative cases */ - - /* Invalid Formats */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (i = 0; i < _numInvalidPixelFormats; i++) { - format = _invalidPixelFormats[i]; - result = (char *)SDL_GetPixelFormatName(format); - SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result[0] != '\0', - "Verify result is non-empty; got: %s", result); - SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0, - "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result); - } - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty"); - } - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_AllocPalette and SDL_FreePalette - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocPalette - * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreePalette - */ -int -pixels_allocFreePalette(void *arg) -{ - const char *expectedError1 = "Parameter 'ncolors' is invalid"; - const char *expectedError2 = "Parameter 'palette' is invalid"; - const char *error; - int variation; - int i; - int ncolors; - SDL_Palette* result; - - /* Allocate palette */ - for (variation = 1; variation <= 3; variation++) { - switch (variation) { - /* Just one color */ - case 1: - ncolors = 1; - break; - /* Two colors */ - case 2: - ncolors = 2; - break; - /* More than two colors */ - case 3: - ncolors = SDLTest_RandomIntegerInRange(8, 16); - break; - } - - result = SDL_AllocPalette(ncolors); - SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); - if (result != NULL) { - SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors); - if (result->ncolors > 0) { - SDLTest_AssertCheck(result->colors != NULL, "Verify value of result.colors is not NULL"); - if (result->colors != NULL) { - for(i = 0; i < result->ncolors; i++) { - SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r); - SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g); - SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b); - } - } - } - - /* Deallocate again */ - SDL_FreePalette(result); - SDLTest_AssertPass("Call to SDL_FreePalette()"); - } - } - - /* Negative cases */ - - /* Invalid number of colors */ - for (ncolors = 0; ncolors > -3; ncolors--) { - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - result = SDL_AllocPalette(ncolors); - SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError1, error); - } - } - - /* Invalid free pointer */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_FreePalette(NULL); - SDLTest_AssertPass("Call to SDL_FreePalette(NULL)"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError2, error); - } - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_CalculateGammaRamp - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_CalculateGammaRamp - */ -int -pixels_calcGammaRamp(void *arg) -{ - const char *expectedError1 = "Parameter 'gamma' is invalid"; - const char *expectedError2 = "Parameter 'ramp' is invalid"; - const char *error; - float gamma; - Uint16 *ramp; - int variation; - int i; - int changed; - Uint16 magic = 0xbeef; - - /* Allocate temp ramp array and fill with some value */ - ramp = (Uint16 *)SDL_malloc(256 * sizeof(Uint16)); - SDLTest_AssertCheck(ramp != NULL, "Validate temp ramp array could be allocated"); - if (ramp == NULL) return TEST_ABORTED; - - /* Make call with different gamma values */ - for (variation = 0; variation < 4; variation++) { - switch (variation) { - /* gamma = 0 all black */ - case 0: - gamma = 0.0f; - break; - /* gamma = 1 identity */ - case 1: - gamma = 1.0f; - break; - /* gamma = [0.2,0.8] normal range */ - case 2: - gamma = 0.2f + 0.8f * SDLTest_RandomUnitFloat(); - break; - /* gamma = >1.1 non-standard range */ - case 3: - gamma = 1.1f + SDLTest_RandomUnitFloat(); - break; - } - - /* Make call and check that values were updated */ - for (i = 0; i < 256; i++) ramp[i] = magic; - SDL_CalculateGammaRamp(gamma, ramp); - SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma); - changed = 0; - for (i = 0; i < 256; i++) if (ramp[i] != magic) changed++; - SDLTest_AssertCheck(changed > 250, "Validate that ramp was calculated; expected: >250 values changed, got: %d values changed", changed); - - /* Additional value checks for some cases */ - i = SDLTest_RandomIntegerInRange(64,192); - switch (variation) { - case 0: - SDLTest_AssertCheck(ramp[i] == 0, "Validate value at position %d; expected: 0, got: %d", i, ramp[i]); - break; - case 1: - SDLTest_AssertCheck(ramp[i] == ((i << 8) | i), "Validate value at position %d; expected: %d, got: %d", i, (i << 8) | i, ramp[i]); - break; - case 2: - case 3: - SDLTest_AssertCheck(ramp[i] > 0, "Validate value at position %d; expected: >0, got: %d", i, ramp[i]); - break; - } - } - - /* Negative cases */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - gamma = -1; - for (i=0; i<256; i++) ramp[i] = magic; - SDL_CalculateGammaRamp(gamma, ramp); - SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError1, error); - } - changed = 0; - for (i = 0; i < 256; i++) if (ramp[i] != magic) changed++; - SDLTest_AssertCheck(changed ==0, "Validate that ramp unchanged; expected: 0 values changed got: %d values changed", changed); - - SDL_CalculateGammaRamp(0.5f, NULL); - SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(0.5,NULL)"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError2, error); - } - - /* Cleanup */ - SDL_free(ramp); - - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* Pixels test cases */ -static const SDLTest_TestCaseReference pixelsTest1 = - { (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED }; - -static const SDLTest_TestCaseReference pixelsTest2 = - { (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED }; - -static const SDLTest_TestCaseReference pixelsTest3 = - { (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED }; - -static const SDLTest_TestCaseReference pixelsTest4 = - { (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED }; - -/* Sequence of Pixels test cases */ -static const SDLTest_TestCaseReference *pixelsTests[] = { - &pixelsTest1, &pixelsTest2, &pixelsTest3, &pixelsTest4, NULL -}; - -/* Pixels test suite (global) */ -SDLTest_TestSuiteReference pixelsTestSuite = { - "Pixels", - NULL, - pixelsTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_platform.c b/3rdparty/SDL2/test/testautomation_platform.c deleted file mode 100644 index 5211a4a70cc..00000000000 --- a/3rdparty/SDL2/test/testautomation_platform.c +++ /dev/null @@ -1,584 +0,0 @@ -/** - * Original code: automated SDL platform test written by Edgar Simo "bobbens" - * Extended and updated by aschiffler at ferzkopp dot net - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -/* Helper functions */ - -/** - * @brief Compare sizes of types. - * - * @note 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 _compareSizeOfType( size_t sizeoftype, size_t hardcodetype ) -{ - return sizeoftype != hardcodetype; -} - -/* Test case functions */ - -/** - * @brief Tests type sizes. - */ -int platform_testTypes(void *arg) -{ - int ret; - - ret = _compareSizeOfType( sizeof(Uint8), 1 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint8) = %lu, expected 1", (unsigned long)sizeof(Uint8) ); - - ret = _compareSizeOfType( sizeof(Uint16), 2 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint16) = %lu, expected 2", (unsigned long)sizeof(Uint16) ); - - ret = _compareSizeOfType( sizeof(Uint32), 4 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint32) = %lu, expected 4", (unsigned long)sizeof(Uint32) ); - - ret = _compareSizeOfType( sizeof(Uint64), 8 ); - SDLTest_AssertCheck( ret == 0, "sizeof(Uint64) = %lu, expected 8", (unsigned long)sizeof(Uint64) ); - - return TEST_COMPLETED; -} - -/** - * @brief Tests platform endianness and SDL_SwapXY functions. - */ -int platform_testEndianessAndSwap(void *arg) -{ - int real_byteorder; - Uint16 value = 0x1234; - Uint16 value16 = 0xCDAB; - Uint16 swapped16 = 0xABCD; - Uint32 value32 = 0xEFBEADDE; - Uint32 swapped32 = 0xDEADBEEF; - - Uint64 value64, swapped64; - value64 = 0xEFBEADDE; - value64 <<= 32; - value64 |= 0xCDAB3412; - swapped64 = 0x1234ABCD; - swapped64 <<= 32; - swapped64 |= 0xDEADBEEF; - - if ((*((char *) &value) >> 4) == 0x1) { - real_byteorder = SDL_BIG_ENDIAN; - } else { - real_byteorder = SDL_LIL_ENDIAN; - } - - /* Test endianness. */ - SDLTest_AssertCheck( real_byteorder == SDL_BYTEORDER, - "Machine detected as %s endian, appears to be %s endian.", - (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big", - (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" ); - - /* Test 16 swap. */ - SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16, - "SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X", - value16, SDL_Swap16(value16) ); - - /* Test 32 swap. */ - SDLTest_AssertCheck( SDL_Swap32(value32) == swapped32, - "SDL_Swap32(): 32 bit swapped: 0x%X => 0x%X", - value32, SDL_Swap32(value32) ); - - /* Test 64 swap. */ - SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64, - "SDL_Swap64(): 64 bit swapped: 0x%"SDL_PRIX64" => 0x%"SDL_PRIX64, - value64, SDL_Swap64(value64) ); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_GetXYZ() functions - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform - * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCount - * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCacheLineSize - * http://wiki.libsdl.org/moin.cgi/SDL_GetRevision - * http://wiki.libsdl.org/moin.cgi/SDL_GetRevisionNumber - */ -int platform_testGetFunctions (void *arg) -{ - char *platform; - char *revision; - int ret; - int len; - - platform = (char *)SDL_GetPlatform(); - SDLTest_AssertPass("SDL_GetPlatform()"); - SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL"); - if (platform != NULL) { - len = SDL_strlen(platform); - SDLTest_AssertCheck(len > 0, - "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", - platform, - len); - } - - ret = SDL_GetCPUCount(); - SDLTest_AssertPass("SDL_GetCPUCount()"); - SDLTest_AssertCheck(ret > 0, - "SDL_GetCPUCount(): expected count > 0, was: %i", - ret); - - ret = SDL_GetCPUCacheLineSize(); - SDLTest_AssertPass("SDL_GetCPUCacheLineSize()"); - SDLTest_AssertCheck(ret >= 0, - "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i", - ret); - - revision = (char *)SDL_GetRevision(); - SDLTest_AssertPass("SDL_GetRevision()"); - SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL"); - - ret = SDL_GetRevisionNumber(); - SDLTest_AssertPass("SDL_GetRevisionNumber()"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_HasXYZ() functions - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow - * http://wiki.libsdl.org/moin.cgi/SDL_HasAltiVec - * http://wiki.libsdl.org/moin.cgi/SDL_HasMMX - * http://wiki.libsdl.org/moin.cgi/SDL_HasRDTSC - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE2 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42 - * http://wiki.libsdl.org/moin.cgi/SDL_HasAVX - */ -int platform_testHasFunctions (void *arg) -{ - int ret; - - /* TODO: independently determine and compare values as well */ - - ret = SDL_HasRDTSC(); - SDLTest_AssertPass("SDL_HasRDTSC()"); - - ret = SDL_HasAltiVec(); - SDLTest_AssertPass("SDL_HasAltiVec()"); - - ret = SDL_HasMMX(); - SDLTest_AssertPass("SDL_HasMMX()"); - - ret = SDL_Has3DNow(); - SDLTest_AssertPass("SDL_Has3DNow()"); - - ret = SDL_HasSSE(); - SDLTest_AssertPass("SDL_HasSSE()"); - - ret = SDL_HasSSE2(); - SDLTest_AssertPass("SDL_HasSSE2()"); - - ret = SDL_HasSSE3(); - SDLTest_AssertPass("SDL_HasSSE3()"); - - ret = SDL_HasSSE41(); - SDLTest_AssertPass("SDL_HasSSE41()"); - - ret = SDL_HasSSE42(); - SDLTest_AssertPass("SDL_HasSSE42()"); - - ret = SDL_HasAVX(); - SDLTest_AssertPass("SDL_HasAVX()"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_GetVersion - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetVersion - */ -int platform_testGetVersion(void *arg) -{ - SDL_version linked; - int major = SDL_MAJOR_VERSION; - int minor = SDL_MINOR_VERSION; - - SDL_GetVersion(&linked); - SDLTest_AssertCheck( linked.major >= major, - "SDL_GetVersion(): returned major %i (>= %i)", - linked.major, - major); - SDLTest_AssertCheck( linked.minor >= minor, - "SDL_GetVersion(): returned minor %i (>= %i)", - linked.minor, - minor); - - return TEST_COMPLETED; -} - - -/* ! - * \brief Tests SDL_VERSION macro - */ -int platform_testSDLVersion(void *arg) -{ - SDL_version compiled; - int major = SDL_MAJOR_VERSION; - int minor = SDL_MINOR_VERSION; - - SDL_VERSION(&compiled); - SDLTest_AssertCheck( compiled.major >= major, - "SDL_VERSION() returned major %i (>= %i)", - compiled.major, - major); - SDLTest_AssertCheck( compiled.minor >= minor, - "SDL_VERSION() returned minor %i (>= %i)", - compiled.minor, - minor); - - return TEST_COMPLETED; -} - - -/* ! - * \brief Tests default SDL_Init - */ -int platform_testDefaultInit(void *arg) -{ - int ret; - int subsystem; - - subsystem = SDL_WasInit(SDL_INIT_EVERYTHING); - SDLTest_AssertCheck( subsystem != 0, - "SDL_WasInit(0): returned %i, expected != 0", - subsystem); - - ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING)); - SDLTest_AssertCheck( ret == 0, - "SDL_Init(0): returned %i, expected 0, error: %s", - ret, - SDL_GetError()); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_Get/Set/ClearError - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetError - * http://wiki.libsdl.org/moin.cgi/SDL_SetError - * http://wiki.libsdl.org/moin.cgi/SDL_ClearError - */ -int platform_testGetSetClearError(void *arg) -{ - int result; - const char *testError = "Testing"; - char *lastError; - int len; - - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) - { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == 0, - "SDL_GetError(): no message expected, len: %i", len); - } - - result = SDL_SetError("%s", testError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) - { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == SDL_strlen(testError), - "SDL_GetError(): expected message len %i, was len: %i", - SDL_strlen(testError), - len); - SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, - "SDL_GetError(): expected message %s, was message: %s", - testError, - lastError); - } - - /* Clean up */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_SetError with empty input - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetError - */ -int platform_testSetErrorEmptyInput(void *arg) -{ - int result; - const char *testError = ""; - char *lastError; - int len; - - result = SDL_SetError("%s", testError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) - { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == SDL_strlen(testError), - "SDL_GetError(): expected message len %i, was len: %i", - SDL_strlen(testError), - len); - SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - testError, - lastError); - } - - /* Clean up */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_SetError with invalid input - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetError - */ -int platform_testSetErrorInvalidInput(void *arg) -{ - int result; - const char *invalidError = NULL; - const char *probeError = "Testing"; - char *lastError; - int len; - - /* Reset */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* Check for no-op */ - result = SDL_SetError(invalidError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) - { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == 0, - "SDL_GetError(): expected message len 0, was len: %i", - len); - } - - /* Set */ - result = SDL_SetError(probeError); - SDLTest_AssertPass("SDL_SetError('%s')", probeError); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - - /* Check for no-op */ - result = SDL_SetError(invalidError); - SDLTest_AssertPass("SDL_SetError(NULL)"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) - { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == 0, - "SDL_GetError(): expected message len 0, was len: %i", - len); - } - - /* Reset */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* Set and check */ - result = SDL_SetError(probeError); - SDLTest_AssertPass("SDL_SetError()"); - SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertCheck(lastError != NULL, - "SDL_GetError() != NULL"); - if (lastError != NULL) - { - len = SDL_strlen(lastError); - SDLTest_AssertCheck(len == SDL_strlen(probeError), - "SDL_GetError(): expected message len %i, was len: %i", - SDL_strlen(probeError), - len); - SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - probeError, - lastError); - } - - /* Clean up */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_GetPowerInfo - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo - */ -int platform_testGetPowerInfo(void *arg) -{ - SDL_PowerState state; - SDL_PowerState stateAgain; - int secs; - int secsAgain; - int pct; - int pctAgain; - - state = SDL_GetPowerInfo(&secs, &pct); - SDLTest_AssertPass("SDL_GetPowerInfo()"); - SDLTest_AssertCheck( - state==SDL_POWERSTATE_UNKNOWN || - state==SDL_POWERSTATE_ON_BATTERY || - state==SDL_POWERSTATE_NO_BATTERY || - state==SDL_POWERSTATE_CHARGING || - state==SDL_POWERSTATE_CHARGED, - "SDL_GetPowerInfo(): state %i is one of the expected values", - (int)state); - - if (state==SDL_POWERSTATE_ON_BATTERY) - { - SDLTest_AssertCheck( - secs >= 0, - "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i", - secs); - SDLTest_AssertCheck( - (pct >= 0) && (pct <= 100), - "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i", - pct); - } - - if (state==SDL_POWERSTATE_UNKNOWN || - state==SDL_POWERSTATE_NO_BATTERY) - { - SDLTest_AssertCheck( - secs == -1, - "SDL_GetPowerInfo(): no battery, secs == -1, was: %i", - secs); - SDLTest_AssertCheck( - pct == -1, - "SDL_GetPowerInfo(): no battery, pct == -1, was: %i", - pct); - } - - /* Partial return value variations */ - stateAgain = SDL_GetPowerInfo(&secsAgain, NULL); - SDLTest_AssertCheck( - state==stateAgain, - "State %i returned when only 'secs' requested", - stateAgain); - SDLTest_AssertCheck( - secs==secsAgain, - "Value %i matches when only 'secs' requested", - secsAgain); - stateAgain = SDL_GetPowerInfo(NULL, &pctAgain); - SDLTest_AssertCheck( - state==stateAgain, - "State %i returned when only 'pct' requested", - stateAgain); - SDLTest_AssertCheck( - pct==pctAgain, - "Value %i matches when only 'pct' requested", - pctAgain); - stateAgain = SDL_GetPowerInfo(NULL, NULL); - SDLTest_AssertCheck( - state==stateAgain, - "State %i returned when no value requested", - stateAgain); - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* Platform test cases */ -static const SDLTest_TestCaseReference platformTest1 = - { (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest2 = - { (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest3 = - { (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest4 = - { (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest5 = - { (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest6 = - { (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest7 = - { (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest8 = - { (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest9 = - { (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest10 = - { (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED}; - -static const SDLTest_TestCaseReference platformTest11 = - { (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED }; - -/* Sequence of Platform test cases */ -static const SDLTest_TestCaseReference *platformTests[] = { - &platformTest1, - &platformTest2, - &platformTest3, - &platformTest4, - &platformTest5, - &platformTest6, - &platformTest7, - &platformTest8, - &platformTest9, - &platformTest10, - &platformTest11, - NULL -}; - -/* Platform test suite (global) */ -SDLTest_TestSuiteReference platformTestSuite = { - "Platform", - NULL, - platformTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_rect.c b/3rdparty/SDL2/test/testautomation_rect.c deleted file mode 100644 index abf19f593df..00000000000 --- a/3rdparty/SDL2/test/testautomation_rect.c +++ /dev/null @@ -1,1696 +0,0 @@ -/** - * Original code: automated SDL rect test written by Edgar Simo "bobbens" - * New/updated tests: aschiffler at ferzkopp dot net - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -/* Helper functions */ - -/* ! - * \brief Private helper to check SDL_IntersectRectAndLine results - */ -void _validateIntersectRectAndLineResults( - SDL_bool intersection, SDL_bool expectedIntersection, - SDL_Rect *rect, SDL_Rect * refRect, - int x1, int y1, int x2, int y2, - int x1Ref, int y1Ref, int x2Ref, int y2Ref) -{ - SDLTest_AssertCheck(intersection == expectedIntersection, - "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)", - (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - refRect->x, refRect->y, refRect->w, refRect->h, - x1Ref, y1Ref, x2Ref, y2Ref); - SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h, - "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rect->x, rect->y, rect->w, rect->h, - refRect->x, refRect->y, refRect->w, refRect->h); - SDLTest_AssertCheck(x1 == x1Ref && y1 == y1Ref && x2 == x2Ref && y2 == y2Ref, - "Check if line was incorrectly clipped or modified: got (%d,%d - %d,%d) expected (%d,%d - %d,%d)", - x1, y1, x2, y2, - x1Ref, y1Ref, x2Ref, y2Ref); -} - -/* Test case functions */ - -/* ! - * \brief Tests SDL_IntersectRectAndLine() clipping cases - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine - */ -int -rect_testIntersectRectAndLine (void *arg) -{ - SDL_Rect refRect = { 0, 0, 32, 32 }; - SDL_Rect rect; - int x1, y1; - int x2, y2; - SDL_bool intersected; - - int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w); - int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w); - int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h); - int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h); - - x1 = xLeft; - y1 = 15; - x2 = xRight; - y2 = 15; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 15, 31, 15); - - x1 = 15; - y1 = yTop; - x2 = 15; - y2 = yBottom; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 15, 0, 15, 31); - - x1 = -refRect.w; - y1 = -refRect.h; - x2 = 2*refRect.w; - y2 = 2*refRect.h; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 0, 31, 31); - - x1 = 2*refRect.w; - y1 = 2*refRect.h; - x2 = -refRect.w; - y2 = -refRect.h; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 31, 0, 0); - - x1 = -1; - y1 = 32; - x2 = 32; - y2 = -1; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 0, 31, 31, 0); - - x1 = 32; - y1 = -1; - x2 = -1; - y2 = 32; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine - */ -int -rect_testIntersectRectAndLineInside (void *arg) -{ - SDL_Rect refRect = { 0, 0, 32, 32 }; - SDL_Rect rect; - int x1, y1; - int x2, y2; - SDL_bool intersected; - - int xmin = refRect.x; - int xmax = refRect.x + refRect.w - 1; - int ymin = refRect.y; - int ymax = refRect.y + refRect.h - 1; - int x1Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1); - int y1Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1); - int x2Ref = SDLTest_RandomIntegerInRange(xmin + 1, xmax - 1); - int y2Ref = SDLTest_RandomIntegerInRange(ymin + 1, ymax - 1); - - x1 = x1Ref; - y1 = y1Ref; - x2 = x2Ref; - y2 = y2Ref; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref); - - x1 = x1Ref; - y1 = y1Ref; - x2 = xmax; - y2 = ymax; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, xmax, ymax); - - x1 = xmin; - y1 = ymin; - x2 = x2Ref; - y2 = y2Ref; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, x2Ref, y2Ref); - - x1 = xmin; - y1 = ymin; - x2 = xmax; - y2 = ymax; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymin, xmax, ymax); - - x1 = xmin; - y1 = ymax; - x2 = xmax; - y2 = ymin; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine - */ -int -rect_testIntersectRectAndLineOutside (void *arg) -{ - SDL_Rect refRect = { 0, 0, 32, 32 }; - SDL_Rect rect; - int x1, y1; - int x2, y2; - SDL_bool intersected; - - int xLeft = -SDLTest_RandomIntegerInRange(1, refRect.w); - int xRight = refRect.w + SDLTest_RandomIntegerInRange(1, refRect.w); - int yTop = -SDLTest_RandomIntegerInRange(1, refRect.h); - int yBottom = refRect.h + SDLTest_RandomIntegerInRange(1, refRect.h); - - x1 = xLeft; - y1 = 0; - x2 = xLeft; - y2 = 31; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xLeft, 0, xLeft, 31); - - x1 = xRight; - y1 = 0; - x2 = xRight; - y2 = 31; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, xRight, 0, xRight, 31); - - x1 = 0; - y1 = yTop; - x2 = 31; - y2 = yTop; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yTop, 31, yTop); - - x1 = 0; - y1 = yBottom; - x2 = 31; - y2 = yBottom; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_IntersectRectAndLine() with empty rectangle - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine - */ -int -rect_testIntersectRectAndLineEmpty (void *arg) -{ - SDL_Rect refRect; - SDL_Rect rect; - int x1, y1, x1Ref, y1Ref; - int x2, y2, x2Ref, y2Ref; - SDL_bool intersected; - - refRect.x = SDLTest_RandomIntegerInRange(1, 1024); - refRect.y = SDLTest_RandomIntegerInRange(1, 1024); - refRect.w = 0; - refRect.h = 0; - x1Ref = refRect.x; - y1Ref = refRect.y; - x2Ref = SDLTest_RandomIntegerInRange(1, 1024); - y2Ref = SDLTest_RandomIntegerInRange(1, 1024); - - x1 = x1Ref; - y1 = y1Ref; - x2 = x2Ref; - y2 = y2Ref; - rect = refRect; - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref); - - return TEST_COMPLETED; -} - -/* ! - * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine - */ -int -rect_testIntersectRectAndLineParam (void *arg) -{ - SDL_Rect rect = { 0, 0, 32, 32 }; - int x1 = rect.w / 2; - int y1 = rect.h / 2; - int x2 = x1; - int y2 = 2 * rect.h; - SDL_bool intersected; - - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); - SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE"); - - intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2); - SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); - intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2); - SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); - intersected = SDL_IntersectRectAndLine(&rect, &x1, (int *)NULL, &x2, &y2); - SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 3rd parameter is NULL"); - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, (int *)NULL, &y2); - SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 4th parameter is NULL"); - intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, (int *)NULL); - SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 5th parameter is NULL"); - intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL); - SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Private helper to check SDL_HasIntersection results - */ -void _validateHasIntersectionResults( - SDL_bool intersection, SDL_bool expectedIntersection, - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) -{ - SDLTest_AssertCheck(intersection == expectedIntersection, - "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)", - (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h); - SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, - "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - refRectA->x, refRectA->y, refRectA->w, refRectA->h); - SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h, - "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectB->x, rectB->y, rectB->w, rectB->h, - refRectB->x, refRectB->y, refRectB->w, refRectB->h); -} - -/* ! - * \brief Private helper to check SDL_IntersectRect results - */ -void _validateIntersectRectResults( - SDL_bool intersection, SDL_bool expectedIntersection, - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, - SDL_Rect *result, SDL_Rect *expectedResult) -{ - _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB); - if (result && expectedResult) { - SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, - "Check that intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h, - result->x, result->y, result->w, result->h, - expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); - } -} - -/* ! - * \brief Private helper to check SDL_UnionRect results - */ -void _validateUnionRectResults( - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, - SDL_Rect *result, SDL_Rect *expectedResult) -{ - SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, - "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - refRectA->x, refRectA->y, refRectA->w, refRectA->h); - SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h, - "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectB->x, rectB->y, rectB->w, rectB->h, - refRectB->x, refRectB->y, refRectB->w, refRectB->h); - SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, - "Check that union of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h, - result->x, result->y, result->w, result->h, - expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); -} - -/* ! - * \brief Private helper to check SDL_RectEmpty results - */ -void _validateRectEmptyResults( - SDL_bool empty, SDL_bool expectedEmpty, - SDL_Rect *rect, SDL_Rect *refRect) -{ - SDLTest_AssertCheck(empty == expectedEmpty, - "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)", - (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rect->x, rect->y, rect->w, rect->h); - SDLTest_AssertCheck(rect->x == refRect->x && rect->y == refRect->y && rect->w == refRect->w && rect->h == refRect->h, - "Check that source rectangle was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rect->x, rect->y, rect->w, rect->h, - refRect->x, refRect->y, refRect->w, refRect->h); -} - -/* ! - * \brief Private helper to check SDL_RectEquals results - */ -void _validateRectEqualsResults( - SDL_bool equals, SDL_bool expectedEquals, - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) -{ - SDLTest_AssertCheck(equals == expectedEquals, - "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)", - (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rectA->x, rectA->y, rectA->w, rectA->h, - rectB->x, rectB->y, rectB->w, rectB->h); - SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, - "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, - refRectA->x, refRectA->y, refRectA->w, refRectA->h); - SDLTest_AssertCheck(rectB->x == refRectB->x && rectB->y == refRectB->y && rectB->w == refRectB->w && rectB->h == refRectB->h, - "Check that source rectangle B was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectB->x, rectB->y, rectB->w, rectB->h, - refRectB->x, refRectB->y, refRectB->w, refRectB->h); -} - -/* ! - * \brief Tests SDL_IntersectRect() with B fully inside A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect - */ -int rect_testIntersectRectInside (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 32, 32 }; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_Rect result; - SDL_bool intersection; - - /* rectB fully contained in rectA */ - refRectB.x = 0; - refRectB.y = 0; - refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); - refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_IntersectRect() with B fully outside A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect - */ -int rect_testIntersectRectOutside (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 32, 32 }; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_Rect result; - SDL_bool intersection; - - /* rectB fully outside of rectA */ - refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10); - refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10); - refRectB.w = refRectA.w; - refRectB.h = refRectA.h; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_IntersectRect() with B partially intersecting A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect - */ -int rect_testIntersectRectPartial (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 32, 32 }; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_Rect result; - SDL_Rect expectedResult; - SDL_bool intersection; - - /* rectB partially contained in rectA */ - refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); - refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); - refRectB.w = refRectA.w; - refRectB.h = refRectA.h; - rectA = refRectA; - rectB = refRectB; - expectedResult.x = refRectB.x; - expectedResult.y = refRectB.y; - expectedResult.w = refRectA.w - refRectB.x; - expectedResult.h = refRectA.h - refRectB.y; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* rectB right edge */ - refRectB.x = rectA.w - 1; - refRectB.y = rectA.y; - refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); - refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - expectedResult.x = refRectB.x; - expectedResult.y = refRectB.y; - expectedResult.w = 1; - expectedResult.h = refRectB.h; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* rectB left edge */ - refRectB.x = 1 - rectA.w; - refRectB.y = rectA.y; - refRectB.w = refRectA.w; - refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - expectedResult.x = 0; - expectedResult.y = refRectB.y; - expectedResult.w = 1; - expectedResult.h = refRectB.h; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* rectB bottom edge */ - refRectB.x = rectA.x; - refRectB.y = rectA.h - 1; - refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); - refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - expectedResult.x = refRectB.x; - expectedResult.y = refRectB.y; - expectedResult.w = refRectB.w; - expectedResult.h = 1; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* rectB top edge */ - refRectB.x = rectA.x; - refRectB.y = 1 - rectA.h; - refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); - refRectB.h = rectA.h; - rectA = refRectA; - rectB = refRectB; - expectedResult.x = refRectB.x; - expectedResult.y = 0; - expectedResult.w = refRectB.w; - expectedResult.h = 1; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect - */ -int rect_testIntersectRectPoint (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 1, 1 }; - SDL_Rect refRectB = { 0, 0, 1, 1 }; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_Rect result; - SDL_bool intersection; - int offsetX, offsetY; - - /* intersecting pixels */ - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectB.x = refRectA.x; - refRectB.y = refRectA.y; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA); - - /* non-intersecting pixels cases */ - for (offsetX = -1; offsetX <= 1; offsetX++) { - for (offsetY = -1; offsetY <= 1; offsetY++) { - if (offsetX != 0 || offsetY != 0) { - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectB.x = refRectA.x; - refRectB.y = refRectA.y; - refRectB.x += offsetX; - refRectB.y += offsetY; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - } - } - } - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_IntersectRect() with empty rectangles - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect - */ -int rect_testIntersectRectEmpty (void *arg) -{ - SDL_Rect refRectA; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_Rect result; - SDL_bool intersection; - SDL_bool empty; - - /* Rect A empty */ - result.w = SDLTest_RandomIntegerInRange(1, 100); - result.h = SDLTest_RandomIntegerInRange(1, 100); - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectA.w = SDLTest_RandomIntegerInRange(1, 100); - refRectA.h = SDLTest_RandomIntegerInRange(1, 100); - refRectB = refRectA; - refRectA.w = 0; - refRectA.h = 0; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - empty = (SDL_bool)SDL_RectEmpty(&result); - SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - - /* Rect B empty */ - result.w = SDLTest_RandomIntegerInRange(1, 100); - result.h = SDLTest_RandomIntegerInRange(1, 100); - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectA.w = SDLTest_RandomIntegerInRange(1, 100); - refRectA.h = SDLTest_RandomIntegerInRange(1, 100); - refRectB = refRectA; - refRectB.w = 0; - refRectB.h = 0; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - empty = (SDL_bool)SDL_RectEmpty(&result); - SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - - /* Rect A and B empty */ - result.w = SDLTest_RandomIntegerInRange(1, 100); - result.h = SDLTest_RandomIntegerInRange(1, 100); - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectA.w = SDLTest_RandomIntegerInRange(1, 100); - refRectA.h = SDLTest_RandomIntegerInRange(1, 100); - refRectB = refRectA; - refRectA.w = 0; - refRectA.h = 0; - refRectB.w = 0; - refRectB.h = 0; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - empty = (SDL_bool)SDL_RectEmpty(&result); - SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Negative tests against SDL_IntersectRect() with invalid parameters - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect - */ -int rect_testIntersectRectParam(void *arg) -{ - SDL_Rect rectA; - SDL_Rect rectB; - SDL_Rect result; - SDL_bool intersection; - - /* invalid parameter combinations */ - intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); - intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); - intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL"); - intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL"); - intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL "); - intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_HasIntersection() with B fully inside A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection - */ -int rect_testHasIntersectionInside (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 32, 32 }; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool intersection; - - /* rectB fully contained in rectA */ - refRectB.x = 0; - refRectB.y = 0; - refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); - refRectB.h = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_HasIntersection() with B fully outside A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection - */ -int rect_testHasIntersectionOutside (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 32, 32 }; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool intersection; - - /* rectB fully outside of rectA */ - refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10); - refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10); - refRectB.w = refRectA.w; - refRectB.h = refRectA.h; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_HasIntersection() with B partially intersecting A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection - */ -int rect_testHasIntersectionPartial (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 32, 32 }; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool intersection; - - /* rectB partially contained in rectA */ - refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); - refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); - refRectB.w = refRectA.w; - refRectB.h = refRectA.h; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - - /* rectB right edge */ - refRectB.x = rectA.w - 1; - refRectB.y = rectA.y; - refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); - refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - - /* rectB left edge */ - refRectB.x = 1 - rectA.w; - refRectB.y = rectA.y; - refRectB.w = refRectA.w; - refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - - /* rectB bottom edge */ - refRectB.x = rectA.x; - refRectB.y = rectA.h - 1; - refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); - refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - - /* rectB top edge */ - refRectB.x = rectA.x; - refRectB.y = 1 - rectA.h; - refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); - refRectB.h = rectA.h; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection - */ -int rect_testHasIntersectionPoint (void *arg) -{ - SDL_Rect refRectA = { 0, 0, 1, 1 }; - SDL_Rect refRectB = { 0, 0, 1, 1 }; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool intersection; - int offsetX, offsetY; - - /* intersecting pixels */ - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectB.x = refRectA.x; - refRectB.y = refRectA.y; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - - /* non-intersecting pixels cases */ - for (offsetX = -1; offsetX <= 1; offsetX++) { - for (offsetY = -1; offsetY <= 1; offsetY++) { - if (offsetX != 0 || offsetY != 0) { - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectB.x = refRectA.x; - refRectB.y = refRectA.y; - refRectB.x += offsetX; - refRectB.y += offsetY; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - } - } - } - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_HasIntersection() with empty rectangles - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection - */ -int rect_testHasIntersectionEmpty (void *arg) -{ - SDL_Rect refRectA; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool intersection; - - /* Rect A empty */ - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectA.w = SDLTest_RandomIntegerInRange(1, 100); - refRectA.h = SDLTest_RandomIntegerInRange(1, 100); - refRectB = refRectA; - refRectA.w = 0; - refRectA.h = 0; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - - /* Rect B empty */ - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectA.w = SDLTest_RandomIntegerInRange(1, 100); - refRectA.h = SDLTest_RandomIntegerInRange(1, 100); - refRectB = refRectA; - refRectB.w = 0; - refRectB.h = 0; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - - /* Rect A and B empty */ - refRectA.x = SDLTest_RandomIntegerInRange(1, 100); - refRectA.y = SDLTest_RandomIntegerInRange(1, 100); - refRectA.w = SDLTest_RandomIntegerInRange(1, 100); - refRectA.h = SDLTest_RandomIntegerInRange(1, 100); - refRectB = refRectA; - refRectA.w = 0; - refRectA.h = 0; - refRectB.w = 0; - refRectB.h = 0; - rectA = refRectA; - rectB = refRectB; - intersection = SDL_HasIntersection(&rectA, &rectB); - _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - - return TEST_COMPLETED; -} - -/* ! - * \brief Negative tests against SDL_HasIntersection() with invalid parameters - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection - */ -int rect_testHasIntersectionParam(void *arg) -{ - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool intersection; - - /* invalid parameter combinations */ - intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); - intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); - intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Test SDL_EnclosePoints() without clipping - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints - */ -int rect_testEnclosePoints(void *arg) -{ - const int numPoints = 16; - SDL_Point refPoints[16]; - SDL_Point points[16]; - SDL_Rect result; - SDL_bool anyEnclosed; - SDL_bool anyEnclosedNoResult; - SDL_bool expectedEnclosed = SDL_TRUE; - int newx, newy; - int minx = 0, maxx = 0, miny = 0, maxy = 0; - int i; - - /* Create input data, tracking result */ - for (i=0; i<numPoints; i++) { - newx = SDLTest_RandomIntegerInRange(-1024, 1024); - newy = SDLTest_RandomIntegerInRange(-1024, 1024); - refPoints[i].x = newx; - refPoints[i].y = newy; - points[i].x = newx; - points[i].y = newy; - if (i==0) { - minx = newx; - maxx = newx; - miny = newy; - maxy = newy; - } else { - if (newx < minx) minx = newx; - if (newx > maxx) maxx = newx; - if (newy < miny) miny = newy; - if (newy > maxy) maxy = newy; - } - } - - /* Call function and validate - special case: no result requested */ - anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, - "Check expected return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - for (i=0; i<numPoints; i++) { - SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y, - "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", - i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y); - } - - /* Call function and validate */ - anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, - "Check return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - for (i=0; i<numPoints; i++) { - SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y, - "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", - i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y); - } - SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1), - "Resulting enclosing rectangle incorrect: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)", - minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1); - - return TEST_COMPLETED; -} - -/* ! - * \brief Test SDL_EnclosePoints() with repeated input points - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints - */ -int rect_testEnclosePointsRepeatedInput(void *arg) -{ - const int numPoints = 8; - const int halfPoints = 4; - SDL_Point refPoints[8]; - SDL_Point points[8]; - SDL_Rect result; - SDL_bool anyEnclosed; - SDL_bool anyEnclosedNoResult; - SDL_bool expectedEnclosed = SDL_TRUE; - int newx, newy; - int minx = 0, maxx = 0, miny = 0, maxy = 0; - int i; - - /* Create input data, tracking result */ - for (i=0; i<numPoints; i++) { - if (i < halfPoints) { - newx = SDLTest_RandomIntegerInRange(-1024, 1024); - newy = SDLTest_RandomIntegerInRange(-1024, 1024); - } else { - newx = refPoints[i-halfPoints].x; - newy = refPoints[i-halfPoints].y; - } - refPoints[i].x = newx; - refPoints[i].y = newy; - points[i].x = newx; - points[i].y = newy; - if (i==0) { - minx = newx; - maxx = newx; - miny = newy; - maxy = newy; - } else { - if (newx < minx) minx = newx; - if (newx > maxx) maxx = newx; - if (newy < miny) miny = newy; - if (newy > maxy) maxy = newy; - } - } - - /* Call function and validate - special case: no result requested */ - anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, - "Check return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - for (i=0; i<numPoints; i++) { - SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y, - "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", - i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y); - } - - /* Call function and validate */ - anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, &result); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, - "Check return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - for (i=0; i<numPoints; i++) { - SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y, - "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", - i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y); - } - SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1), - "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)", - minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1); - - return TEST_COMPLETED; -} - -/* ! - * \brief Test SDL_EnclosePoints() with clipping - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints - */ -int rect_testEnclosePointsWithClipping(void *arg) -{ - const int numPoints = 16; - SDL_Point refPoints[16]; - SDL_Point points[16]; - SDL_Rect refClip; - SDL_Rect clip; - SDL_Rect result; - SDL_bool anyEnclosed; - SDL_bool anyEnclosedNoResult; - SDL_bool expectedEnclosed = SDL_FALSE; - int newx, newy; - int minx = 0, maxx = 0, miny = 0, maxy = 0; - int i; - - /* Setup clipping rectangle */ - refClip.x = SDLTest_RandomIntegerInRange(-1024, 1024); - refClip.y = SDLTest_RandomIntegerInRange(-1024, 1024); - refClip.w = SDLTest_RandomIntegerInRange(1, 1024); - refClip.h = SDLTest_RandomIntegerInRange(1, 1024); - - /* Create input data, tracking result */ - for (i=0; i<numPoints; i++) { - newx = SDLTest_RandomIntegerInRange(-1024, 1024); - newy = SDLTest_RandomIntegerInRange(-1024, 1024); - refPoints[i].x = newx; - refPoints[i].y = newy; - points[i].x = newx; - points[i].y = newy; - if ((newx>=refClip.x) && (newx<(refClip.x + refClip.w)) && - (newy>=refClip.y) && (newy<(refClip.y + refClip.h))) { - if (expectedEnclosed==SDL_FALSE) { - minx = newx; - maxx = newx; - miny = newy; - maxy = newy; - } else { - if (newx < minx) minx = newx; - if (newx > maxx) maxx = newx; - if (newy < miny) miny = newy; - if (newy > maxy) maxy = newy; - } - expectedEnclosed = SDL_TRUE; - } - } - - /* Call function and validate - special case: no result requested */ - clip = refClip; - anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, (SDL_Rect *)NULL); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, - "Expected return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - for (i=0; i<numPoints; i++) { - SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y, - "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", - i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y); - } - SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h, - "Check that source clipping rectangle was not modified"); - - /* Call function and validate */ - anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, - "Check return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - for (i=0; i<numPoints; i++) { - SDLTest_AssertCheck(refPoints[i].x==points[i].x && refPoints[i].y==points[i].y, - "Check that source point %i was not modified: expected (%i,%i) actual (%i,%i)", - i, refPoints[i].x, refPoints[i].y, points[i].x, points[i].y); - } - SDLTest_AssertCheck(refClip.x==clip.x && refClip.y==clip.y && refClip.w==clip.w && refClip.h==clip.h, - "Check that source clipping rectangle was not modified"); - if (expectedEnclosed==SDL_TRUE) { - SDLTest_AssertCheck(result.x==minx && result.y==miny && result.w==(maxx - minx + 1) && result.h==(maxy - miny + 1), - "Check resulting enclosing rectangle: expected (%i,%i - %i,%i), actual (%i,%i - %i,%i)", - minx, miny, maxx, maxy, result.x, result.y, result.x + result.w - 1, result.y + result.h - 1); - } - - /* Empty clipping rectangle */ - clip.w = 0; - clip.h = 0; - expectedEnclosed = SDL_FALSE; - anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)&clip, &result); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosed, - "Check return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Negative tests against SDL_EnclosePoints() with invalid parameters - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints - */ -int rect_testEnclosePointsParam(void *arg) -{ - SDL_Point points[1]; - int count; - SDL_Rect clip; - SDL_Rect result; - SDL_bool anyEnclosed; - - /* invalid parameter combinations */ - anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 1, (const SDL_Rect *)&clip, &result); - SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL"); - anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, 0, (const SDL_Rect *)&clip, &result); - SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is 0"); - count = SDLTest_RandomIntegerInRange(-100, -1); - anyEnclosed = SDL_EnclosePoints((const SDL_Point *)points, count, (const SDL_Rect *)&clip, &result); - SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 2nd parameter is %i (negative)", count); - anyEnclosed = SDL_EnclosePoints((SDL_Point *)NULL, 0, (const SDL_Rect *)&clip, &result); - SDLTest_AssertCheck(anyEnclosed == SDL_FALSE, "Check that functions returns SDL_FALSE when 1st parameter is NULL and 2nd parameter was 0"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_UnionRect() where rect B is outside rect A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect - */ -int rect_testUnionRectOutside(void *arg) -{ - SDL_Rect refRectA, refRectB; - SDL_Rect rectA, rectB; - SDL_Rect expectedResult; - SDL_Rect result; - int minx, maxx, miny, maxy; - int dx, dy; - - /* Union 1x1 outside */ - for (dx = -1; dx < 2; dx++) { - for (dy = -1; dy < 2; dy++) { - if ((dx != 0) || (dy != 0)) { - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=1; - refRectA.h=1; - refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048; - refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024) + dx*2048; - refRectB.w=1; - refRectB.h=1; - minx = (refRectA.x<refRectB.x) ? refRectA.x : refRectB.x; - maxx = (refRectA.x>refRectB.x) ? refRectA.x : refRectB.x; - miny = (refRectA.y<refRectB.y) ? refRectA.y : refRectB.y; - maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y; - expectedResult.x = minx; - expectedResult.y = miny; - expectedResult.w = maxx - minx + 1; - expectedResult.h = maxy - miny + 1; - rectA = refRectA; - rectB = refRectB; - SDL_UnionRect(&rectA, &rectB, &result); - _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - } - } - } - - /* Union outside overlap */ - for (dx = -1; dx < 2; dx++) { - for (dy = -1; dy < 2; dy++) { - if ((dx != 0) || (dy != 0)) { - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(256, 512); - refRectA.h=SDLTest_RandomIntegerInRange(256, 512); - refRectB.x=refRectA.x + 1 + dx*2; - refRectB.y=refRectA.y + 1 + dy*2; - refRectB.w=refRectA.w - 2; - refRectB.h=refRectA.h - 2; - expectedResult = refRectA; - if (dx == -1) expectedResult.x--; - if (dy == -1) expectedResult.y--; - if ((dx == 1) || (dx == -1)) expectedResult.w++; - if ((dy == 1) || (dy == -1)) expectedResult.h++; - rectA = refRectA; - rectB = refRectB; - SDL_UnionRect(&rectA, &rectB, &result); - _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - } - } - } - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_UnionRect() where rect A or rect B are empty - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect - */ -int rect_testUnionRectEmpty(void *arg) -{ - SDL_Rect refRectA, refRectB; - SDL_Rect rectA, rectB; - SDL_Rect expectedResult; - SDL_Rect result; - - /* A empty */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=0; - refRectA.h=0; - refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.w=SDLTest_RandomIntegerInRange(1, 1024); - refRectB.h=SDLTest_RandomIntegerInRange(1, 1024); - expectedResult = refRectB; - rectA = refRectA; - rectB = refRectB; - SDL_UnionRect(&rectA, &rectB, &result); - _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* B empty */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(1, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(1, 1024); - refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.w=0; - refRectB.h=0; - expectedResult = refRectA; - rectA = refRectA; - rectB = refRectB; - SDL_UnionRect(&rectA, &rectB, &result); - _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* A and B empty */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=0; - refRectA.h=0; - refRectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectB.w=0; - refRectB.h=0; - result.x=0; - result.y=0; - result.w=0; - result.h=0; - expectedResult = result; - rectA = refRectA; - rectB = refRectB; - SDL_UnionRect(&rectA, &rectB, &result); - _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_UnionRect() where rect B is inside rect A - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect - */ -int rect_testUnionRectInside(void *arg) -{ - SDL_Rect refRectA, refRectB; - SDL_Rect rectA, rectB; - SDL_Rect expectedResult; - SDL_Rect result; - int dx, dy; - - /* Union 1x1 with itself */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=1; - refRectA.h=1; - expectedResult = refRectA; - rectA = refRectA; - SDL_UnionRect(&rectA, &rectA, &result); - _validateUnionRectResults(&rectA, &rectA, &refRectA, &refRectA, &result, &expectedResult); - - /* Union 1x1 somewhere inside */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(256, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(256, 1024); - refRectB.x=refRectA.x + 1 + SDLTest_RandomIntegerInRange(1, refRectA.w - 2); - refRectB.y=refRectA.y + 1 + SDLTest_RandomIntegerInRange(1, refRectA.h - 2); - refRectB.w=1; - refRectB.h=1; - expectedResult = refRectA; - rectA = refRectA; - rectB = refRectB; - SDL_UnionRect(&rectA, &rectB, &result); - _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* Union inside with edges modified */ - for (dx = -1; dx < 2; dx++) { - for (dy = -1; dy < 2; dy++) { - if ((dx != 0) || (dy != 0)) { - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(256, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(256, 1024); - refRectB = refRectA; - if (dx == -1) refRectB.x++; - if ((dx == 1) || (dx == -1)) refRectB.w--; - if (dy == -1) refRectB.y++; - if ((dy == 1) || (dy == -1)) refRectB.h--; - expectedResult = refRectA; - rectA = refRectA; - rectB = refRectB; - SDL_UnionRect(&rectA, &rectB, &result); - _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - } - } - } - - return TEST_COMPLETED; -} - -/* ! - * \brief Negative tests against SDL_UnionRect() with invalid parameters - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect - */ -int rect_testUnionRectParam(void *arg) -{ - SDL_Rect rectA, rectB; - SDL_Rect result; - - /* invalid parameter combinations */ - SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result); - SDLTest_AssertPass("Check that function returns when 1st parameter is NULL"); - SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result); - SDLTest_AssertPass("Check that function returns when 2nd parameter is NULL"); - SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when 3rd parameter is NULL"); - SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when 1st and 3rd parameter are NULL"); - SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when 2nd and 3rd parameter are NULL"); - SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when all parameters are NULL"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_RectEmpty() with various inputs - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty - */ -int rect_testRectEmpty(void *arg) -{ - SDL_Rect refRect; - SDL_Rect rect; - SDL_bool expectedResult; - SDL_bool result; - int w, h; - - /* Non-empty case */ - refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.w=SDLTest_RandomIntegerInRange(256, 1024); - refRect.h=SDLTest_RandomIntegerInRange(256, 1024); - expectedResult = SDL_FALSE; - rect = refRect; - result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect); - _validateRectEmptyResults(result, expectedResult, &rect, &refRect); - - /* Empty case */ - for (w=-1; w<2; w++) { - for (h=-1; h<2; h++) { - if ((w != 1) || (h != 1)) { - refRect.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRect.w=w; - refRect.h=h; - expectedResult = SDL_TRUE; - rect = refRect; - result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect); - _validateRectEmptyResults(result, expectedResult, &rect, &refRect); - } - } - } - - return TEST_COMPLETED; -} - -/* ! - * \brief Negative tests against SDL_RectEmpty() with invalid parameters - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty - */ -int rect_testRectEmptyParam(void *arg) -{ - SDL_bool result; - - /* invalid parameter combinations */ - result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL); - SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL"); - - return TEST_COMPLETED; -} - -/* ! - * \brief Tests SDL_RectEquals() with various inputs - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals - */ -int rect_testRectEquals(void *arg) -{ - SDL_Rect refRectA; - SDL_Rect refRectB; - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool expectedResult; - SDL_bool result; - - /* Equals */ - refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - refRectA.w=SDLTest_RandomIntegerInRange(1, 1024); - refRectA.h=SDLTest_RandomIntegerInRange(1, 1024); - refRectB = refRectA; - expectedResult = SDL_TRUE; - rectA = refRectA; - rectB = refRectB; - result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB); - _validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB); - - return TEST_COMPLETED; -} - -/* ! - * \brief Negative tests against SDL_RectEquals() with invalid parameters - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals - */ -int rect_testRectEqualsParam(void *arg) -{ - SDL_Rect rectA; - SDL_Rect rectB; - SDL_bool result; - - /* data setup */ - rectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); - rectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); - rectA.w=SDLTest_RandomIntegerInRange(1, 1024); - rectA.h=SDLTest_RandomIntegerInRange(1, 1024); - rectB.x=SDLTest_RandomIntegerInRange(-1024, 1024); - rectB.y=SDLTest_RandomIntegerInRange(-1024, 1024); - rectB.w=SDLTest_RandomIntegerInRange(1, 1024); - rectB.h=SDLTest_RandomIntegerInRange(1, 1024); - - /* invalid parameter combinations */ - result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB); - SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); - result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL); - SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); - result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL); - SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL"); - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* Rect test cases */ - -/* SDL_IntersectRectAndLine */ -static const SDLTest_TestCaseReference rectTest1 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest2 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest3 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest4 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest5 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED }; - -/* SDL_IntersectRect */ -static const SDLTest_TestCaseReference rectTest6 = - { (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest7 = - { (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest8 = - { (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest9 = - { (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest10 = - { (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest11 = - { (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED }; - -/* SDL_HasIntersection */ -static const SDLTest_TestCaseReference rectTest12 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest13 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest14 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest15 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest16 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest17 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED }; - -/* SDL_EnclosePoints */ -static const SDLTest_TestCaseReference rectTest18 = - { (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest19 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest20 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest21 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED }; - -/* SDL_UnionRect */ -static const SDLTest_TestCaseReference rectTest22 = - { (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest23 = - { (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest24 = - { (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest25 = - { (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED }; - -/* SDL_RectEmpty */ -static const SDLTest_TestCaseReference rectTest26 = - { (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest27 = - { (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED }; - -/* SDL_RectEquals */ - -static const SDLTest_TestCaseReference rectTest28 = - { (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rectTest29 = - { (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED }; - - -/* ! - * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/CategoryRect - */ -static const SDLTest_TestCaseReference *rectTests[] = { - &rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, - &rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27, - &rectTest28, &rectTest29, NULL -}; - - -/* Rect test suite (global) */ -SDLTest_TestSuiteReference rectTestSuite = { - "Rect", - NULL, - rectTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_render.c b/3rdparty/SDL2/test/testautomation_render.c deleted file mode 100644 index 5a1bc9b8c5c..00000000000 --- a/3rdparty/SDL2/test/testautomation_render.c +++ /dev/null @@ -1,1099 +0,0 @@ -/** - * Original code: automated SDL platform test written by Edgar Simo "bobbens" - * Extended and extensively updated by aschiffler at ferzkopp dot net - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -#define TESTRENDER_SCREEN_W 80 -#define TESTRENDER_SCREEN_H 60 - -#define RENDER_COMPARE_FORMAT SDL_PIXELFORMAT_ARGB8888 -#define RENDER_COMPARE_AMASK 0xff000000 /**< Alpha bit mask. */ -#define RENDER_COMPARE_RMASK 0x00ff0000 /**< Red bit mask. */ -#define RENDER_COMPARE_GMASK 0x0000ff00 /**< Green bit mask. */ -#define RENDER_COMPARE_BMASK 0x000000ff /**< Blue bit mask. */ - -#define ALLOWABLE_ERROR_OPAQUE 0 -#define ALLOWABLE_ERROR_BLENDED 64 - -/* Test window and renderer */ -SDL_Window *window = NULL; -SDL_Renderer *renderer = NULL; - -/* Prototypes for helper functions */ - -static int _clearScreen (void); -static void _compare(SDL_Surface *reference, int allowable_error); -static int _hasTexAlpha(void); -static int _hasTexColor(void); -static SDL_Texture *_loadTestFace(void); -static int _hasBlendModes(void); -static int _hasDrawColor(void); -static int _isSupported(int code); - -/** - * Create software renderer for tests - */ -void InitCreateRenderer(void *arg) -{ - int posX = 100, posY = 100, width = 320, height = 240; - renderer = NULL; - window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0); - SDLTest_AssertPass("SDL_CreateWindow()"); - SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); - if (window == NULL) { - return; - } - - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); - SDLTest_AssertPass("SDL_CreateRenderer()"); - SDLTest_AssertCheck(renderer != 0, "Check SDL_CreateRenderer result"); - if (renderer == NULL) { - SDL_DestroyWindow(window); - return; - } -} - -/* - * Destroy renderer for tests - */ -void CleanupDestroyRenderer(void *arg) -{ - if (renderer != NULL) { - SDL_DestroyRenderer(renderer); - renderer = NULL; - SDLTest_AssertPass("SDL_DestroyRenderer()"); - } - - if (window != NULL) { - SDL_DestroyWindow(window); - window = NULL; - SDLTest_AssertPass("SDL_DestroyWindow"); - } -} - - -/** - * @brief Tests call to SDL_GetNumRenderDrivers - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers - */ -int -render_testGetNumRenderDrivers(void *arg) -{ - int n; - n = SDL_GetNumRenderDrivers(); - SDLTest_AssertCheck(n >= 1, "Number of renderers >= 1, reported as %i", n); - return TEST_COMPLETED; -} - - -/** - * @brief Tests the SDL primitives for rendering. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect - * http://wiki.libsdl.org/moin.cgi/SDL_RenderDrawLine - * - */ -int render_testPrimitives (void *arg) -{ - int ret; - int x, y; - SDL_Rect rect; - SDL_Surface *referenceSurface = NULL; - int checkFailCount1; - int checkFailCount2; - - /* Clear surface. */ - _clearScreen(); - - /* Need drawcolor or just skip test. */ - SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); - - /* Draw a rectangle. */ - rect.x = 40; - rect.y = 0; - rect.w = 40; - rect.h = 80; - - ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_RenderFillRect(renderer, &rect ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - - /* Draw a rectangle. */ - rect.x = 10; - rect.y = 10; - rect.w = 60; - rect.h = 40; - ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_RenderFillRect(renderer, &rect ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - - /* Draw some points like so: - * X.X.X.X.. - * .X.X.X.X. - * X.X.X.X.. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - for (y=0; y<3; y++) { - for (x = y % 2; x<TESTRENDER_SCREEN_W; x+=2) { - ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE ); - if (ret != 0) checkFailCount1++; - - ret = SDL_RenderDrawPoint(renderer, x, y ); - if (ret != 0) checkFailCount2++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount2); - - /* Draw some lines. */ - ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor"); - - ret = SDL_RenderDrawLine(renderer, 0, 30, TESTRENDER_SCREEN_W, 30 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); - - ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); - - ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); - - ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); - - ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); - - ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); - - /* Make current */ - SDL_RenderPresent(renderer); - - /* See if it's the same. */ - referenceSurface = SDLTest_ImagePrimitives(); - _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); - - /* Clean up. */ - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - return TEST_COMPLETED; -} - -/** - * @brief Tests the SDL primitives with alpha for rendering. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect - */ -int render_testPrimitivesBlend (void *arg) -{ - int ret; - int i, j; - SDL_Rect rect; - SDL_Surface *referenceSurface = NULL; - int checkFailCount1; - int checkFailCount2; - int checkFailCount3; - - /* Clear surface. */ - _clearScreen(); - - /* Need drawcolor and blendmode or just skip test. */ - SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); - SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes"); - - /* Create some rectangles for each blend mode. */ - ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); - - ret = SDL_RenderFillRect(renderer, NULL ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - - rect.x = 10; - rect.y = 25; - rect.w = 40; - rect.h = 25; - ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); - - ret = SDL_RenderFillRect(renderer, &rect ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - - rect.x = 30; - rect.y = 40; - rect.w = 45; - rect.h = 15; - ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); - - ret = SDL_RenderFillRect(renderer, &rect ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - - rect.x = 25; - rect.y = 25; - rect.w = 25; - rect.h = 25; - ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); - - ret = SDL_RenderFillRect(renderer, &rect ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); - - - /* Draw blended lines, lines for everyone. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - checkFailCount3 = 0; - for (i=0; i<TESTRENDER_SCREEN_W; i+=2) { - ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); - if (ret != 0) checkFailCount1++; - - ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : - (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); - if (ret != 0) checkFailCount2++; - - ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 ); - if (ret != 0) checkFailCount3++; - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); - SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3); - - checkFailCount1 = 0; - checkFailCount2 = 0; - checkFailCount3 = 0; - for (i=0; i<TESTRENDER_SCREEN_H; i+=2) { - ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); - if (ret != 0) checkFailCount1++; - - ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : - (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); - if (ret != 0) checkFailCount2++; - - ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i ); - if (ret != 0) checkFailCount3++; - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); - SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3); - - /* Draw points. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - checkFailCount3 = 0; - for (j=0; j<TESTRENDER_SCREEN_H; j+=3) { - for (i=0; i<TESTRENDER_SCREEN_W; i+=3) { - ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 ); - if (ret != 0) checkFailCount1++; - - ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : - ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); - if (ret != 0) checkFailCount2++; - - ret = SDL_RenderDrawPoint(renderer, i, j ); - if (ret != 0) checkFailCount3++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); - SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3); - - /* Make current */ - SDL_RenderPresent(renderer); - - /* See if it's the same. */ - referenceSurface = SDLTest_ImagePrimitivesBlend(); - _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - - /* Clean up. */ - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - return TEST_COMPLETED; -} - - - -/** - * @brief Tests some blitting routines. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture - */ -int -render_testBlit(void *arg) -{ - int ret; - SDL_Rect rect; - SDL_Texture *tface; - SDL_Surface *referenceSurface = NULL; - Uint32 tformat; - int taccess, tw, th; - int i, j, ni, nj; - int checkFailCount1; - - /* Clear surface. */ - _clearScreen(); - - /* Need drawcolor or just skip test. */ - SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor)"); - - /* Create face surface. */ - tface = _loadTestFace(); - SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); - if (tface == NULL) { - return TEST_ABORTED; - } - - /* Constant values. */ - ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); - rect.w = tw; - rect.h = th; - ni = TESTRENDER_SCREEN_W - tw; - nj = TESTRENDER_SCREEN_H - th; - - /* Loop blit. */ - checkFailCount1 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); - if (ret != 0) checkFailCount1++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount1); - - /* Make current */ - SDL_RenderPresent(renderer); - - /* See if it's the same */ - referenceSurface = SDLTest_ImageBlit(); - _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); - - /* Clean up. */ - SDL_DestroyTexture( tface ); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - return TEST_COMPLETED; -} - - -/** - * @brief Blits doing color tests. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture - */ -int -render_testBlitColor (void *arg) -{ - int ret; - SDL_Rect rect; - SDL_Texture *tface; - SDL_Surface *referenceSurface = NULL; - Uint32 tformat; - int taccess, tw, th; - int i, j, ni, nj; - int checkFailCount1; - int checkFailCount2; - - /* Clear surface. */ - _clearScreen(); - - /* Create face surface. */ - tface = _loadTestFace(); - SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); - if (tface == NULL) { - return TEST_ABORTED; - } - - /* Constant values. */ - ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); - rect.w = tw; - rect.h = th; - ni = TESTRENDER_SCREEN_W - tw; - nj = TESTRENDER_SCREEN_H - th; - - /* Test blitting with color mod. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - /* Set color mod. */ - ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j ); - if (ret != 0) checkFailCount1++; - - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); - if (ret != 0) checkFailCount2++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); - - /* Make current */ - SDL_RenderPresent(renderer); - - /* See if it's the same. */ - referenceSurface = SDLTest_ImageBlitColor(); - _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); - - /* Clean up. */ - SDL_DestroyTexture( tface ); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - return TEST_COMPLETED; -} - - -/** - * @brief Tests blitting with alpha. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture - */ -int -render_testBlitAlpha (void *arg) -{ - int ret; - SDL_Rect rect; - SDL_Texture *tface; - SDL_Surface *referenceSurface = NULL; - Uint32 tformat; - int taccess, tw, th; - int i, j, ni, nj; - int checkFailCount1; - int checkFailCount2; - - /* Clear surface. */ - _clearScreen(); - - /* Need alpha or just skip test. */ - SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha"); - - /* Create face surface. */ - tface = _loadTestFace(); - SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); - if (tface == NULL) { - return TEST_ABORTED; - } - - /* Constant values. */ - ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); - rect.w = tw; - rect.h = th; - ni = TESTRENDER_SCREEN_W - tw; - nj = TESTRENDER_SCREEN_H - th; - - /* Test blitting with alpha mod. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - /* Set alpha mod. */ - ret = SDL_SetTextureAlphaMod( tface, (255/ni)*i ); - if (ret != 0) checkFailCount1++; - - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); - if (ret != 0) checkFailCount2++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); - - /* Make current */ - SDL_RenderPresent(renderer); - - /* See if it's the same. */ - referenceSurface = SDLTest_ImageBlitAlpha(); - _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - - /* Clean up. */ - SDL_DestroyTexture( tface ); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - return TEST_COMPLETED; -} - -/* Helper functions */ - -/** - * @brief Tests a blend mode. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy - */ -static void -_testBlitBlendMode( SDL_Texture * tface, int mode ) -{ - int ret; - Uint32 tformat; - int taccess, tw, th; - int i, j, ni, nj; - SDL_Rect rect; - int checkFailCount1; - int checkFailCount2; - - /* Clear surface. */ - _clearScreen(); - - /* Constant values. */ - ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); - rect.w = tw; - rect.h = th; - ni = TESTRENDER_SCREEN_W - tw; - nj = TESTRENDER_SCREEN_H - th; - - /* Test blend mode. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - /* Set blend mode. */ - ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode ); - if (ret != 0) checkFailCount1++; - - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); - if (ret != 0) checkFailCount2++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); -} - - -/** - * @brief Tests some more blitting routines. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture - */ -int -render_testBlitBlend (void *arg) -{ - int ret; - SDL_Rect rect; - SDL_Texture *tface; - SDL_Surface *referenceSurface = NULL; - Uint32 tformat; - int taccess, tw, th; - int i, j, ni, nj; - int mode; - int checkFailCount1; - int checkFailCount2; - int checkFailCount3; - int checkFailCount4; - - SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes"); - SDLTest_AssertCheck(_hasTexColor(), "_hasTexColor"); - SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha"); - - /* Create face surface. */ - tface = _loadTestFace(); - SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); - if (tface == NULL) { - return TEST_ABORTED; - } - - /* Constant values. */ - ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); - rect.w = tw; - rect.h = th; - ni = TESTRENDER_SCREEN_W - tw; - nj = TESTRENDER_SCREEN_H - th; - - /* Set alpha mod. */ - ret = SDL_SetTextureAlphaMod( tface, 100 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetTextureAlphaMod, expected: 0, got: %i", ret); - - /* Test None. */ - _testBlitBlendMode( tface, SDL_BLENDMODE_NONE ); - referenceSurface = SDLTest_ImageBlitBlendNone(); - - /* Make current and compare */ - SDL_RenderPresent(renderer); - _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - /* Test Blend. */ - _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ); - referenceSurface = SDLTest_ImageBlitBlend(); - - /* Make current and compare */ - SDL_RenderPresent(renderer); - _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - /* Test Add. */ - _testBlitBlendMode( tface, SDL_BLENDMODE_ADD ); - referenceSurface = SDLTest_ImageBlitBlendAdd(); - - /* Make current and compare */ - SDL_RenderPresent(renderer); - _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - /* Test Mod. */ - _testBlitBlendMode( tface, SDL_BLENDMODE_MOD); - referenceSurface = SDLTest_ImageBlitBlendMod(); - - /* Make current and compare */ - SDL_RenderPresent(renderer); - _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - /* Clear surface. */ - _clearScreen(); - - /* Loop blit. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - checkFailCount3 = 0; - checkFailCount4 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - - /* Set color mod. */ - ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j ); - if (ret != 0) checkFailCount1++; - - /* Set alpha mod. */ - ret = SDL_SetTextureAlphaMod( tface, (100/ni)*i ); - if (ret != 0) checkFailCount2++; - - /* Crazy blending mode magic. */ - mode = (i/4*j/4) % 4; - if (mode==0) mode = SDL_BLENDMODE_NONE; - else if (mode==1) mode = SDL_BLENDMODE_BLEND; - else if (mode==2) mode = SDL_BLENDMODE_ADD; - else if (mode==3) mode = SDL_BLENDMODE_MOD; - ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode ); - if (ret != 0) checkFailCount3++; - - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); - if (ret != 0) checkFailCount4++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount2); - SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount3); - SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount4); - - /* Clean up. */ - SDL_DestroyTexture( tface ); - - /* Make current */ - SDL_RenderPresent(renderer); - - /* Check to see if final image matches. */ - referenceSurface = SDLTest_ImageBlitBlendAll(); - _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - - return TEST_COMPLETED; -} - - -/** - * @brief Checks to see if functionality is supported. Helper function. - */ -static int -_isSupported( int code ) -{ - return (code == 0); -} - -/** - * @brief Test to see if we can vary the draw color. Helper function. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawColor - */ -static int -_hasDrawColor (void) -{ - int ret, fail; - Uint8 r, g, b, a; - - fail = 0; - - /* Set color. */ - ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 ); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a ); - if (!_isSupported(ret)) - fail = 1; - - /* Restore natural. */ - ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); - if (!_isSupported(ret)) - fail = 1; - - /* Something failed, consider not available. */ - if (fail) - return 0; - - /* Not set properly, consider failed. */ - else if ((r != 100) || (g != 100) || (b != 100) || (a != 100)) - return 0; - return 1; -} - -/** - * @brief Test to see if we can vary the blend mode. Helper function. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawBlendMode - */ -static int -_hasBlendModes (void) -{ - int fail; - int ret; - SDL_BlendMode mode; - - fail = 0; - - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); - if (!_isSupported(ret)) - fail = 1; - ret = (mode != SDL_BLENDMODE_BLEND); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); - if (!_isSupported(ret)) - fail = 1; - ret = (mode != SDL_BLENDMODE_ADD); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD ); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); - if (!_isSupported(ret)) - fail = 1; - ret = (mode != SDL_BLENDMODE_MOD); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); - if (!_isSupported(ret)) - fail = 1; - ret = (mode != SDL_BLENDMODE_NONE); - if (!_isSupported(ret)) - fail = 1; - - return !fail; -} - - -/** - * @brief Loads the test image 'Face' as texture. Helper function. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_CreateTextureFromSurface - */ -static SDL_Texture * -_loadTestFace(void) -{ - SDL_Surface *face; - SDL_Texture *tface; - - face = SDLTest_ImageFace(); - if (face == NULL) { - return NULL; - } - - tface = SDL_CreateTextureFromSurface(renderer, face); - if (tface == NULL) { - SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError()); - } - - SDL_FreeSurface(face); - - return tface; -} - - -/** - * @brief Test to see if can set texture color mode. Helper function. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture - */ -static int -_hasTexColor (void) -{ - int fail; - int ret; - SDL_Texture *tface; - Uint8 r, g, b; - - /* Get test face. */ - tface = _loadTestFace(); - if (tface == NULL) - return 0; - - /* See if supported. */ - fail = 0; - ret = SDL_SetTextureColorMod( tface, 100, 100, 100 ); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_GetTextureColorMod( tface, &r, &g, &b ); - if (!_isSupported(ret)) - fail = 1; - - /* Clean up. */ - SDL_DestroyTexture( tface ); - - if (fail) - return 0; - else if ((r != 100) || (g != 100) || (b != 100)) - return 0; - return 1; -} - -/** - * @brief Test to see if we can vary the alpha of the texture. Helper function. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture - */ -static int -_hasTexAlpha(void) -{ - int fail; - int ret; - SDL_Texture *tface; - Uint8 a; - - /* Get test face. */ - tface = _loadTestFace(); - if (tface == NULL) - return 0; - - /* See if supported. */ - fail = 0; - ret = SDL_SetTextureAlphaMod( tface, 100 ); - if (!_isSupported(ret)) - fail = 1; - ret = SDL_GetTextureAlphaMod( tface, &a ); - if (!_isSupported(ret)) - fail = 1; - - /* Clean up. */ - SDL_DestroyTexture( tface ); - - if (fail) - return 0; - else if (a != 100) - return 0; - return 1; -} - -/** - * @brief Compares screen pixels with image pixels. Helper function. - * - * @param s Image to compare against. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RenderReadPixels - * http://wiki.libsdl.org/moin.cgi/SDL_CreateRGBSurfaceFrom - * http://wiki.libsdl.org/moin.cgi/SDL_FreeSurface - */ -static void -_compare(SDL_Surface *referenceSurface, int allowable_error) -{ - int result; - SDL_Rect rect; - Uint8 *pixels; - SDL_Surface *testSurface; - - /* Read pixels. */ - pixels = (Uint8 *)SDL_malloc(4*TESTRENDER_SCREEN_W*TESTRENDER_SCREEN_H); - SDLTest_AssertCheck(pixels != NULL, "Validate allocated temp pixel buffer"); - if (pixels == NULL) return; - - /* Explicitly specify the rect in case the window isn't the expected size... */ - rect.x = 0; - rect.y = 0; - rect.w = TESTRENDER_SCREEN_W; - rect.h = TESTRENDER_SCREEN_H; - result = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pixels, 80*4 ); - SDLTest_AssertCheck(result == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", result); - - /* Create surface. */ - testSurface = SDL_CreateRGBSurfaceFrom(pixels, TESTRENDER_SCREEN_W, TESTRENDER_SCREEN_H, 32, TESTRENDER_SCREEN_W*4, - RENDER_COMPARE_RMASK, RENDER_COMPARE_GMASK, RENDER_COMPARE_BMASK, RENDER_COMPARE_AMASK); - SDLTest_AssertCheck(testSurface != NULL, "Verify result from SDL_CreateRGBSurfaceFrom is not NULL"); - - /* Compare surface. */ - result = SDLTest_CompareSurfaces( testSurface, referenceSurface, allowable_error ); - SDLTest_AssertCheck(result == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", result); - - /* Clean up. */ - SDL_free(pixels); - SDL_FreeSurface(testSurface); -} - -/** - * @brief Clears the screen. Helper function. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_RenderClear - * http://wiki.libsdl.org/moin.cgi/SDL_RenderPresent - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode - */ -static int -_clearScreen(void) -{ - int ret; - - /* Set color. */ - ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - /* Clear screen. */ - ret = SDL_RenderClear(renderer); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderClear, expected: 0, got: %i", ret); - - /* Make current */ - SDL_RenderPresent(renderer); - - /* Set defaults. */ - ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); - - ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); - - return 0; -} - -/* ================= Test References ================== */ - -/* Render test cases */ -static const SDLTest_TestCaseReference renderTest1 = - { (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED }; - -static const SDLTest_TestCaseReference renderTest2 = - { (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED }; - -/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference renderTest3 = - { (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_DISABLED }; - -static const SDLTest_TestCaseReference renderTest4 = - { (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED }; - -static const SDLTest_TestCaseReference renderTest5 = - { (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED }; - -/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference renderTest6 = - { (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_DISABLED }; - -/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference renderTest7 = - { (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_DISABLED }; - -/* Sequence of Render test cases */ -static const SDLTest_TestCaseReference *renderTests[] = { - &renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL -}; - -/* Render test suite (global) */ -SDLTest_TestSuiteReference renderTestSuite = { - "Render", - InitCreateRenderer, - renderTests, - CleanupDestroyRenderer -}; diff --git a/3rdparty/SDL2/test/testautomation_rwops.c b/3rdparty/SDL2/test/testautomation_rwops.c deleted file mode 100644 index 16f2161fec3..00000000000 --- a/3rdparty/SDL2/test/testautomation_rwops.c +++ /dev/null @@ -1,748 +0,0 @@ - -/** - * Automated SDL_RWops test. - * - * Original code written by Edgar Simo "bobbens" - * Ported by Markus Kauppila (markus.kauppila@gmail.com) - * Updated and extended for SDL_test by aschiffler at ferzkopp dot net - * - * Released under Public Domain. - */ - -/* quiet windows compiler warnings */ -#define _CRT_SECURE_NO_WARNINGS - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* ================= Test Case Implementation ================== */ - -const char* RWopsReadTestFilename = "rwops_read"; -const char* RWopsWriteTestFilename = "rwops_write"; -const char* RWopsAlphabetFilename = "rwops_alphabet"; - -static const char RWopsHelloWorldTestString[] = "Hello World!"; -static const char RWopsHelloWorldCompString[] = "Hello World!"; -static const char RWopsAlphabetString[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - -/* Fixture */ - -void -RWopsSetUp(void *arg) -{ - int fileLen; - FILE *handle; - int writtenLen; - int result; - - /* Clean up from previous runs (if any); ignore errors */ - remove(RWopsReadTestFilename); - remove(RWopsWriteTestFilename); - remove(RWopsAlphabetFilename); - - /* Create a test file */ - handle = fopen(RWopsReadTestFilename, "w"); - SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename); - if (handle == NULL) return; - - /* Write some known text into it */ - fileLen = SDL_strlen(RWopsHelloWorldTestString); - writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle); - SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); - result = fclose(handle); - SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); - - /* Create a second test file */ - handle = fopen(RWopsAlphabetFilename, "w"); - SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename); - if (handle == NULL) return; - - /* Write alphabet text into it */ - fileLen = SDL_strlen(RWopsAlphabetString); - writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle); - SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); - result = fclose(handle); - SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); - - SDLTest_AssertPass("Creation of test file completed"); -} - -void -RWopsTearDown(void *arg) -{ - int result; - - /* Remove the created files to clean up; ignore errors for write filename */ - result = remove(RWopsReadTestFilename); - SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result); - remove(RWopsWriteTestFilename); - result = remove(RWopsAlphabetFilename); - SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result); - - SDLTest_AssertPass("Cleanup of test files completed"); -} - -/** - * @brief Makes sure parameters work properly. Local helper function. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWseek - * http://wiki.libsdl.org/moin.cgi/SDL_RWread - */ -void -_testGenericRWopsValidations(SDL_RWops *rw, int write) -{ - char buf[sizeof(RWopsHelloWorldTestString)]; - Sint64 i; - size_t s; - int seekPos = SDLTest_RandomIntegerInRange(4, 8); - - /* Clear buffer */ - SDL_zero(buf); - - /* Set to start. */ - i = SDL_RWseek(rw, 0, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i); - - /* Test write. */ - s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1); - SDLTest_AssertPass("Call to SDL_RWwrite succeeded"); - if (write) { - SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s); - } - else { - SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s); - } - - /* Test seek to random position */ - i = SDL_RWseek( rw, seekPos, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %"SDL_PRIs64, seekPos, seekPos, i); - - /* Test seek back to start */ - i = SDL_RWseek(rw, 0, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i); - - /* Test read */ - s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 ); - SDLTest_AssertPass("Call to SDL_RWread succeeded"); - SDLTest_AssertCheck( - s == (size_t)(sizeof(RWopsHelloWorldTestString)-1), - "Verify result from SDL_RWread, expected %i, got %i", - sizeof(RWopsHelloWorldTestString)-1, - s); - SDLTest_AssertCheck( - SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, - "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf); - - /* More seek tests. */ - i = SDL_RWseek( rw, -4, RW_SEEK_CUR ); - SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded"); - SDLTest_AssertCheck( - i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5), - "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %"SDL_PRIs64, - sizeof(RWopsHelloWorldTestString)-5, - i); - - i = SDL_RWseek( rw, -1, RW_SEEK_END ); - SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded"); - SDLTest_AssertCheck( - i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2), - "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %"SDL_PRIs64, - sizeof(RWopsHelloWorldTestString)-2, - i); - - /* Invalid whence seek */ - i = SDL_RWseek( rw, 0, 999 ); - SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded"); - SDLTest_AssertCheck( - i == (Sint64)(-1), - "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %"SDL_PRIs64, - i); -} - -/* ! - * Negative test for SDL_RWFromFile parameters - * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - * - */ -int -rwops_testParamNegative (void) -{ - SDL_RWops *rwops; - - /* These should all fail. */ - rwops = SDL_RWFromFile(NULL, NULL); - SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL"); - - rwops = SDL_RWFromFile(NULL, "ab+"); - SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL"); - - rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj"); - SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL"); - - rwops = SDL_RWFromFile("something", ""); - SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL"); - - rwops = SDL_RWFromFile("something", NULL); - SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL"); - - rwops = SDL_RWFromMem((void *)NULL, 10); - SDLTest_AssertPass("Call to SDL_RWFromMem(NULL, 10) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(NULL, 10) returns NULL"); - - rwops = SDL_RWFromMem((void *)RWopsAlphabetString, 0); - SDLTest_AssertPass("Call to SDL_RWFromMem(data, 0) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(data, 0) returns NULL"); - - rwops = SDL_RWFromConstMem((const void *)RWopsAlphabetString, 0); - SDLTest_AssertPass("Call to SDL_RWFromConstMem(data, 0) succeeded"); - SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromConstMem(data, 0) returns NULL"); - - return TEST_COMPLETED; -} - -/** - * @brief Tests opening from memory. - * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWClose - */ -int -rwops_testMem (void) -{ - char mem[sizeof(RWopsHelloWorldTestString)]; - SDL_RWops *rw; - int result; - - /* Clear buffer */ - SDL_zero(mem); - - /* Open */ - rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1); - SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL"); - - /* Bail out if NULL */ - if (rw == NULL) return TEST_ABORTED; - - /* Check type */ - SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %d", SDL_RWOPS_MEMORY, rw->type); - - /* Run generic tests */ - _testGenericRWopsValidations(rw, 1); - - /* Close */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests opening from memory. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose - */ -int -rwops_testConstMem (void) -{ - SDL_RWops *rw; - int result; - - /* Open handle */ - rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 ); - SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL"); - - /* Bail out if NULL */ - if (rw == NULL) return TEST_ABORTED; - - /* Check type */ - SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY_RO, "Verify RWops type is SDL_RWOPS_MEMORY_RO; expected: %d, got: %d", SDL_RWOPS_MEMORY_RO, rw->type); - - /* Run generic tests */ - _testGenericRWopsValidations( rw, 0 ); - - /* Close handle */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests reading from file. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose - */ -int -rwops_testFileRead(void) -{ - SDL_RWops *rw; - int result; - - /* Read test. */ - rw = SDL_RWFromFile(RWopsReadTestFilename, "r"); - SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL"); - - /* Bail out if NULL */ - if (rw == NULL) return TEST_ABORTED; - - /* Check type */ -#if defined(__ANDROID__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, - "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); -#elif defined(__WIN32__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_WINFILE, - "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); -#else - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, - "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); -#endif - - /* Run generic tests */ - _testGenericRWopsValidations( rw, 0 ); - - /* Close handle */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - return TEST_COMPLETED; -} - -/** - * @brief Tests writing from file. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose - */ -int -rwops_testFileWrite(void) -{ - SDL_RWops *rw; - int result; - - /* Write test. */ - rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); - SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); - - /* Bail out if NULL */ - if (rw == NULL) return TEST_ABORTED; - - /* Check type */ -#if defined(__ANDROID__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, - "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); -#elif defined(__WIN32__) - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_WINFILE, - "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); -#else - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, - "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); -#endif - - /* Run generic tests */ - _testGenericRWopsValidations( rw, 1 ); - - /* Close handle */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests reading from file handle - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose - * - */ -int -rwops_testFPRead(void) -{ - FILE *fp; - SDL_RWops *rw; - int result; - - /* Run read tests. */ - fp = fopen(RWopsReadTestFilename, "r"); - SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in read mode is not NULL", RWopsReadTestFilename); - - /* Bail out if NULL */ - if (fp == NULL) return TEST_ABORTED; - - /* Open */ - rw = SDL_RWFromFP( fp, SDL_TRUE ); - SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in read mode does not return NULL"); - - /* Bail out if NULL */ - if (rw == NULL) { - fclose(fp); - return TEST_ABORTED; - } - - /* Check type */ - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, - "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); - - /* Run generic tests */ - _testGenericRWopsValidations( rw, 0 ); - - /* Close handle - does fclose() */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests writing to file handle - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose - * - */ -int -rwops_testFPWrite(void) -{ - FILE *fp; - SDL_RWops *rw; - int result; - - /* Run write tests. */ - fp = fopen(RWopsWriteTestFilename, "w+"); - SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in write mode is not NULL", RWopsWriteTestFilename); - - /* Bail out if NULL */ - if (fp == NULL) return TEST_ABORTED; - - /* Open */ - rw = SDL_RWFromFP( fp, SDL_TRUE ); - SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in write mode does not return NULL"); - - /* Bail out if NULL */ - if (rw == NULL) { - fclose(fp); - return TEST_ABORTED; - } - - /* Check type */ - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, - "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); - - /* Run generic tests */ - _testGenericRWopsValidations( rw, 1 ); - - /* Close handle - does fclose() */ - result = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - return TEST_COMPLETED; -} - -/** - * @brief Tests alloc and free RW context. - * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_AllocRW - * \sa http://wiki.libsdl.org/moin.cgi/SDL_FreeRW - */ -int -rwops_testAllocFree (void) -{ - /* Allocate context */ - SDL_RWops *rw = SDL_AllocRW(); - SDLTest_AssertPass("Call to SDL_AllocRW() succeeded"); - SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_AllocRW() is not NULL"); - if (rw==NULL) return TEST_ABORTED; - - /* Check type */ - SDLTest_AssertCheck( - rw->type == SDL_RWOPS_UNKNOWN, - "Verify RWops type is SDL_RWOPS_UNKNOWN; expected: %d, got: %d", SDL_RWOPS_UNKNOWN, rw->type); - - /* Free context again */ - SDL_FreeRW(rw); - SDLTest_AssertPass("Call to SDL_FreeRW() succeeded"); - - return TEST_COMPLETED; -} - -/** - * @brief Compare memory and file reads - * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - */ -int -rwops_testCompareRWFromMemWithRWFromFile(void) -{ - int slen = 26; - char buffer_file[27]; - char buffer_mem[27]; - size_t rv_file; - size_t rv_mem; - Uint64 sv_file; - Uint64 sv_mem; - SDL_RWops* rwops_file; - SDL_RWops* rwops_mem; - int size; - int result; - - - for (size=5; size<10; size++) - { - /* Terminate buffer */ - buffer_file[slen] = 0; - buffer_mem[slen] = 0; - - /* Read/seek from memory */ - rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen); - SDLTest_AssertPass("Call to SDL_RWFromMem()"); - rv_mem = SDL_RWread(rwops_mem, buffer_mem, size, 6); - SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size); - sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END); - SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)"); - result = SDL_RWclose(rwops_mem); - SDLTest_AssertPass("Call to SDL_RWclose(mem)"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - /* Read/see from file */ - rwops_file = SDL_RWFromFile(RWopsAlphabetFilename, "r"); - SDLTest_AssertPass("Call to SDL_RWFromFile()"); - rv_file = SDL_RWread(rwops_file, buffer_file, size, 6); - SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size); - sv_file = SDL_RWseek(rwops_file, 0, SEEK_END); - SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)"); - result = SDL_RWclose(rwops_file); - SDLTest_AssertPass("Call to SDL_RWclose(file)"); - SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - - /* Compare */ - SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", rv_mem, rv_file); - SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%"SDL_PRIu64" sv_file=%"SDL_PRIu64, sv_mem, sv_file); - SDLTest_AssertCheck(buffer_mem[slen] == 0, "Verify mem buffer termination; expected: 0, got: %d", buffer_mem[slen]); - SDLTest_AssertCheck(buffer_file[slen] == 0, "Verify file buffer termination; expected: 0, got: %d", buffer_file[slen]); - SDLTest_AssertCheck( - SDL_strncmp(buffer_mem, RWopsAlphabetString, slen) == 0, - "Verify mem buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_mem); - SDLTest_AssertCheck( - SDL_strncmp(buffer_file, RWopsAlphabetString, slen) == 0, - "Verify file buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_file); - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests writing and reading from file using endian aware functions. - * - * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose - * http://wiki.libsdl.org/moin.cgi/SDL_ReadBE16 - * http://wiki.libsdl.org/moin.cgi/SDL_WriteBE16 - */ -int -rwops_testFileWriteReadEndian(void) -{ - SDL_RWops *rw; - Sint64 result; - int mode; - size_t objectsWritten; - Uint16 BE16value; - Uint32 BE32value; - Uint64 BE64value; - Uint16 LE16value; - Uint32 LE32value; - Uint64 LE64value; - Uint16 BE16test; - Uint32 BE32test; - Uint64 BE64test; - Uint16 LE16test; - Uint32 LE32test; - Uint64 LE64test; - int cresult; - - for (mode = 0; mode < 3; mode++) { - - /* Create test data */ - switch (mode) { - case 0: - SDLTest_Log("All 0 values"); - BE16value = 0; - BE32value = 0; - BE64value = 0; - LE16value = 0; - LE32value = 0; - LE64value = 0; - break; - case 1: - SDLTest_Log("All 1 values"); - BE16value = 1; - BE32value = 1; - BE64value = 1; - LE16value = 1; - LE32value = 1; - LE64value = 1; - break; - case 2: - SDLTest_Log("Random values"); - BE16value = SDLTest_RandomUint16(); - BE32value = SDLTest_RandomUint32(); - BE64value = SDLTest_RandomUint64(); - LE16value = SDLTest_RandomUint16(); - LE32value = SDLTest_RandomUint32(); - LE64value = SDLTest_RandomUint64(); - break; - } - - /* Write test. */ - rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); - SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")"); - SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); - - /* Bail out if NULL */ - if (rw == NULL) return TEST_ABORTED; - - /* Write test data */ - objectsWritten = SDL_WriteBE16(rw, BE16value); - SDLTest_AssertPass("Call to SDL_WriteBE16()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); - objectsWritten = SDL_WriteBE32(rw, BE32value); - SDLTest_AssertPass("Call to SDL_WriteBE32()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); - objectsWritten = SDL_WriteBE64(rw, BE64value); - SDLTest_AssertPass("Call to SDL_WriteBE64()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); - objectsWritten = SDL_WriteLE16(rw, LE16value); - SDLTest_AssertPass("Call to SDL_WriteLE16()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); - objectsWritten = SDL_WriteLE32(rw, LE32value); - SDLTest_AssertPass("Call to SDL_WriteLE32()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); - objectsWritten = SDL_WriteLE64(rw, LE64value); - SDLTest_AssertPass("Call to SDL_WriteLE64()"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); - - /* Test seek to start */ - result = SDL_RWseek( rw, 0, RW_SEEK_SET ); - SDLTest_AssertPass("Call to SDL_RWseek succeeded"); - SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %"SDL_PRIs64, result); - - /* Read test data */ - BE16test = SDL_ReadBE16(rw); - SDLTest_AssertPass("Call to SDL_ReadBE16()"); - SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test); - BE32test = SDL_ReadBE32(rw); - SDLTest_AssertPass("Call to SDL_ReadBE32()"); - SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test); - BE64test = SDL_ReadBE64(rw); - SDLTest_AssertPass("Call to SDL_ReadBE64()"); - SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, BE64value, BE64test); - LE16test = SDL_ReadLE16(rw); - SDLTest_AssertPass("Call to SDL_ReadLE16()"); - SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test); - LE32test = SDL_ReadLE32(rw); - SDLTest_AssertPass("Call to SDL_ReadLE32()"); - SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test); - LE64test = SDL_ReadLE64(rw); - SDLTest_AssertPass("Call to SDL_ReadLE64()"); - SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, LE64value, LE64test); - - /* Close handle */ - cresult = SDL_RWclose(rw); - SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult); - } - - return TEST_COMPLETED; -} - - -/* ================= Test References ================== */ - -/* RWops test cases */ -static const SDLTest_TestCaseReference rwopsTest1 = - { (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest2 = - { (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest3 = - { (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest4 = - { (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest5 = - { (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest6 = - { (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest7 = - { (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest8 = - { (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest9 = - { (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED }; - -static const SDLTest_TestCaseReference rwopsTest10 = - { (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED }; - -/* Sequence of RWops test cases */ -static const SDLTest_TestCaseReference *rwopsTests[] = { - &rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6, - &rwopsTest7, &rwopsTest8, &rwopsTest9, &rwopsTest10, NULL -}; - -/* RWops test suite (global) */ -SDLTest_TestSuiteReference rwopsTestSuite = { - "RWops", - RWopsSetUp, - rwopsTests, - RWopsTearDown -}; diff --git a/3rdparty/SDL2/test/testautomation_sdltest.c b/3rdparty/SDL2/test/testautomation_sdltest.c deleted file mode 100644 index 54cd6e2575e..00000000000 --- a/3rdparty/SDL2/test/testautomation_sdltest.c +++ /dev/null @@ -1,1315 +0,0 @@ -/** - * SDL_test test suite - */ - -/* Visual Studio 2008 doesn't have stdint.h */ -#if defined(_MSC_VER) && _MSC_VER <= 1500 -#define UINT8_MAX ~(Uint8)0 -#define UINT16_MAX ~(Uint16)0 -#define UINT32_MAX ~(Uint32)0 -#define UINT64_MAX ~(Uint64)0 -#else -#include <stdint.h> -#endif -#include <stdio.h> -#include <limits.h> -#include <float.h> -#include <ctype.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* Test case functions */ - -/* Forward declarations for internal harness functions */ -extern char *SDLTest_GenerateRunSeed(const int length); - -/** - * @brief Calls to SDLTest_GenerateRunSeed() - */ -int -sdltest_generateRunSeed(void *arg) -{ - char* result; - int i, l; - - for (i = 1; i <= 10; i += 3) { - result = SDLTest_GenerateRunSeed((const int)i); - SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); - SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL"); - if (result != NULL) { - l = SDL_strlen(result); - SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", i, l); - SDL_free(result); - } - } - - /* Negative cases */ - for (i = -2; i <= 0; i++) { - result = SDLTest_GenerateRunSeed((const int)i); - SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); - SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL"); - } - - return TEST_COMPLETED; -} - -/** - * @brief Calls to SDLTest_GetFuzzerInvocationCount() - */ -int -sdltest_getFuzzerInvocationCount(void *arg) -{ - Uint8 result; - int fuzzerCount1, fuzzerCount2; - - fuzzerCount1 = SDLTest_GetFuzzerInvocationCount(); - SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); - SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1); - - result = SDLTest_RandomUint8(); - SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result); - - fuzzerCount2 = SDLTest_GetFuzzerInvocationCount(); - SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); - SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2); - - return TEST_COMPLETED; -} - - -/** - * @brief Calls to random number generators - */ -int -sdltest_randomNumber(void *arg) -{ - Sint64 result; - Uint64 uresult; - double dresult; - Uint64 umax; - Sint64 min, max; - - result = (Sint64)SDLTest_RandomUint8(); - umax = (1 << 8) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomUint8"); - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result); - - result = (Sint64)SDLTest_RandomSint8(); - min = 0 - (1 << 7); - max = (1 << 7) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomSint8"); - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result); - - result = (Sint64)SDLTest_RandomUint16(); - umax = (1 << 16) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomUint16"); - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result); - - result = (Sint64)SDLTest_RandomSint16(); - min = 0 - (1 << 15); - max = (1 << 15) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomSint16"); - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result); - - result = (Sint64)SDLTest_RandomUint32(); - umax = ((Uint64)1 << 32) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomUint32"); - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result); - - result = (Sint64)SDLTest_RandomSint32(); - min = 0 - ((Sint64)1 << 31); - max = ((Sint64)1 << 31) - 1; - SDLTest_AssertPass("Call to SDLTest_RandomSint32"); - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result); - - uresult = SDLTest_RandomUint64(); - SDLTest_AssertPass("Call to SDLTest_RandomUint64"); - - result = SDLTest_RandomSint64(); - SDLTest_AssertPass("Call to SDLTest_RandomSint64"); - - dresult = (double)SDLTest_RandomUnitFloat(); - SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat"); - SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult); - - dresult = (double)SDLTest_RandomFloat(); - SDLTest_AssertPass("Call to SDLTest_RandomFloat"); - SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult); - - dresult = (double)SDLTest_RandomUnitDouble(); - SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble"); - SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult); - - dresult = SDLTest_RandomDouble(); - SDLTest_AssertPass("Call to SDLTest_RandomDouble"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Uint8 - */ -int -sdltest_randomBoundaryNumberUint8(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0xff, - "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Uint16 - */ -int -sdltest_randomBoundaryNumberUint16(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0xffff, - "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Uint32 - */ -int -sdltest_randomBoundaryNumberUint32(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0xffffffff, - "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Uint64 - */ -int -sdltest_randomBoundaryNumberUint64(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Uint64 uresult; - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult); - - /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == (Uint64)0xffffffffffffffffULL, - "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */ - uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); - SDLTest_AssertCheck( - uresult == 0, - "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Sint8 - */ -int -sdltest_randomBoundaryNumberSint8(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == SCHAR_MIN, - "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == SCHAR_MAX, - "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MAX, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */ - sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); - SDLTest_AssertCheck( - sresult == SCHAR_MIN, - "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Sint16 - */ -int -sdltest_randomBoundaryNumberSint16(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == SHRT_MIN, - "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == SHRT_MAX, - "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MAX, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */ - sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); - SDLTest_AssertCheck( - sresult == SHRT_MIN, - "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Sint32 - */ -int -sdltest_randomBoundaryNumberSint32(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; -#if ((ULONG_MAX) == (UINT_MAX)) - Sint32 long_min = LONG_MIN; - Sint32 long_max = LONG_MAX; -#else - Sint32 long_min = INT_MIN; - Sint32 long_max = INT_MAX; -#endif - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == long_min, - "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == long_max, - "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_max, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */ - sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); - SDLTest_AssertCheck( - sresult == long_min, - "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/* - * @brief Calls to random boundary number generators for Sint64 - */ -int -sdltest_randomBoundaryNumberSint64(void *arg) -{ - const char *expectedError = "That operation is not supported"; - char *lastError; - Sint64 sresult; - - /* Clean error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == 100, - "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult); - - /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == LLONG_MIN, - "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == LLONG_MAX, - "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MAX, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); - - /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */ - sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE); - SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); - SDLTest_AssertCheck( - sresult == LLONG_MIN, - "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/** - * @brief Calls to SDLTest_RandomIntegerInRange - */ -int -sdltest_randomIntegerInRange(void *arg) -{ - Sint32 min, max; - Sint32 result; -#if ((ULONG_MAX) == (UINT_MAX)) - Sint32 long_min = LONG_MIN; - Sint32 long_max = LONG_MAX; -#else - Sint32 long_min = INT_MIN; - Sint32 long_max = INT_MAX; -#endif - - /* Standard range */ - min = (Sint32)SDLTest_RandomSint16(); - max = min + (Sint32)SDLTest_RandomUint8() + 2; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,max)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result); - - /* One Range */ - min = (Sint32)SDLTest_RandomSint16(); - max = min + 1; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min+1)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result); - - /* Zero range */ - min = (Sint32)SDLTest_RandomSint16(); - max = min; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min)"); - SDLTest_AssertCheck(min == result, "Validated returned value; expected: %d, got: %d", min, result); - - /* Zero range at zero */ - min = 0; - max = 0; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(0,0)"); - SDLTest_AssertCheck(result == 0, "Validated returned value; expected: 0, got: %d", result); - - /* Swapped min-max */ - min = (Sint32)SDLTest_RandomSint16(); - max = min + (Sint32)SDLTest_RandomUint8() + 2; - result = SDLTest_RandomIntegerInRange(max, min); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(max,min)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result); - - /* Range with min at integer limit */ - min = long_min; - max = long_max + (Sint32)SDLTest_RandomSint16(); - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,...)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result); - - /* Range with max at integer limit */ - min = long_min - (Sint32)SDLTest_RandomSint16(); - max = long_max; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(...,SINT32_MAX)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result); - - /* Full integer range */ - min = long_min; - max = long_max; - result = SDLTest_RandomIntegerInRange(min, max); - SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,SINT32_MAX)"); - SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result); - - return TEST_COMPLETED; -} - -/** - * @brief Calls to SDLTest_RandomAsciiString - */ -int -sdltest_randomAsciiString(void *arg) -{ - char* result; - int len; - int nonAsciiCharacters; - int i; - - result = SDLTest_RandomAsciiString(); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiString()"); - SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); - if (result != NULL) { - len = SDL_strlen(result); - SDLTest_AssertCheck(len >= 0 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", len); - nonAsciiCharacters = 0; - for (i=0; i<len; i++) { - if (iscntrl(result[i])) { - nonAsciiCharacters++; - } - } - SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters); - if (nonAsciiCharacters) { - SDLTest_LogError("Invalid result from generator: '%s'", result); - } - SDL_free(result); - } - - return TEST_COMPLETED; -} - - -/** - * @brief Calls to SDLTest_RandomAsciiStringWithMaximumLength - */ -int -sdltest_randomAsciiStringWithMaximumLength(void *arg) -{ - const char* expectedError = "Parameter 'maxLength' is invalid"; - char* lastError; - char* result; - int targetLen; - int len; - int nonAsciiCharacters; - int i; - - targetLen = 16 + SDLTest_RandomUint8(); - result = SDLTest_RandomAsciiStringWithMaximumLength(targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen); - SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); - if (result != NULL) { - len = SDL_strlen(result); - SDLTest_AssertCheck(len >= 0 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", targetLen, len); - nonAsciiCharacters = 0; - for (i=0; i<len; i++) { - if (iscntrl(result[i])) { - nonAsciiCharacters++; - } - } - SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters); - if (nonAsciiCharacters) { - SDLTest_LogError("Invalid result from generator: '%s'", result); - } - SDL_free(result); - } - - /* Negative test */ - targetLen = 0; - result = SDLTest_RandomAsciiStringWithMaximumLength(targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - -/** - * @brief Calls to SDLTest_RandomAsciiStringOfSize - */ -int -sdltest_randomAsciiStringOfSize(void *arg) -{ - const char* expectedError = "Parameter 'size' is invalid"; - char* lastError; - char* result; - int targetLen; - int len; - int nonAsciiCharacters; - int i; - - /* Positive test */ - targetLen = 16 + SDLTest_RandomUint8(); - result = SDLTest_RandomAsciiStringOfSize(targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen); - SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL"); - if (result != NULL) { - len = SDL_strlen(result); - SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", targetLen, len); - nonAsciiCharacters = 0; - for (i=0; i<len; i++) { - if (iscntrl(result[i])) { - nonAsciiCharacters++; - } - } - SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-ASCII characters, got: %d", nonAsciiCharacters); - if (nonAsciiCharacters) { - SDLTest_LogError("Invalid result from generator: '%s'", result); - } - SDL_free(result); - } - - /* Negative test */ - targetLen = 0; - result = SDLTest_RandomAsciiStringOfSize(targetLen); - SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - - /* Clear error messages */ - SDL_ClearError(); - SDLTest_AssertPass("SDL_ClearError()"); - - return TEST_COMPLETED; -} - - -/* ================= Test References ================== */ - -/* SDL_test test cases */ -static const SDLTest_TestCaseReference sdltestTest1 = - { (SDLTest_TestCaseFp)sdltest_getFuzzerInvocationCount, "sdltest_getFuzzerInvocationCount", "Call to sdltest_GetFuzzerInvocationCount", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest2 = - { (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest3 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest4 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest5 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest6 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest7 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest8 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest9 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest10 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest11 = - { (SDLTest_TestCaseFp)sdltest_randomIntegerInRange, "sdltest_randomIntegerInRange", "Calls to ranged random number generator", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest12 = - { (SDLTest_TestCaseFp)sdltest_randomAsciiString, "sdltest_randomAsciiString", "Calls to default ASCII string generator", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest13 = - { (SDLTest_TestCaseFp)sdltest_randomAsciiStringWithMaximumLength, "sdltest_randomAsciiStringWithMaximumLength", "Calls to random maximum length ASCII string generator", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest14 = - { (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED }; - -static const SDLTest_TestCaseReference sdltestTest15 = - { (SDLTest_TestCaseFp)sdltest_generateRunSeed, "sdltest_generateRunSeed", "Checks internal harness function SDLTest_GenerateRunSeed", TEST_ENABLED }; - -/* Sequence of SDL_test test cases */ -static const SDLTest_TestCaseReference *sdltestTests[] = { - &sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6, - &sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12, - &sdltestTest13, &sdltestTest14, &sdltestTest15, NULL -}; - -/* SDL_test test suite (global) */ -SDLTest_TestSuiteReference sdltestTestSuite = { - "SDLtest", - NULL, - sdltestTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_stdlib.c b/3rdparty/SDL2/test/testautomation_stdlib.c deleted file mode 100644 index b541995f59b..00000000000 --- a/3rdparty/SDL2/test/testautomation_stdlib.c +++ /dev/null @@ -1,319 +0,0 @@ -/** - * Standard C library routine test suite - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - - -/* Test case functions */ - -/** - * @brief Call to SDL_strlcpy - */ -#undef SDL_strlcpy -int -stdlib_strlcpy(void *arg) -{ - size_t result; - char text[1024]; - const char *expected; - - result = SDL_strlcpy(text, "foo", sizeof(text)); - expected = "foo"; - SDLTest_AssertPass("Call to SDL_strlcpy(\"foo\")"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_strlcpy(text, "foo", 2); - expected = "f"; - SDLTest_AssertPass("Call to SDL_strlcpy(\"foo\") with buffer size 2"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result); - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_snprintf - */ -#undef SDL_snprintf -int -stdlib_snprintf(void *arg) -{ - int result; - char text[1024]; - const char *expected; - - result = SDL_snprintf(text, sizeof(text), "%s", "foo"); - expected = "foo"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%s\", \"foo\")"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, 2, "%s", "foo"); - expected = "f"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%s\", \"foo\") with buffer size 2"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result); - - result = SDL_snprintf(NULL, 0, "%s", "foo"); - SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result); - - result = SDL_snprintf(text, sizeof(text), "%f", 1.0); - expected = "1.000000"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 1.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, sizeof(text), "%.f", 1.0); - expected = "1"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%.f\", 1.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, sizeof(text), "%#.f", 1.0); - expected = "1."; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%#.f\", 1.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, sizeof(text), "%f", 1.0 + 1.0 / 3.0); - expected = "1.333333"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 1.0 + 1.0 / 3.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, sizeof(text), "%+f", 1.0 + 1.0 / 3.0); - expected = "+1.333333"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%+f\", 1.0 + 1.0 / 3.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, sizeof(text), "%.2f", 1.0 + 1.0 / 3.0); - expected = "1.33"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%.2f\", 1.0 + 1.0 / 3.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, sizeof(text), "%6.2f", 1.0 + 1.0 / 3.0); - expected = " 1.33"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%6.2f\", 1.0 + 1.0 / 3.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, sizeof(text), "%06.2f", 1.0 + 1.0 / 3.0); - expected = "001.33"; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%06.2f\", 1.0 + 1.0 / 3.0)"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text); - SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); - - result = SDL_snprintf(text, 5, "%06.2f", 1.0 + 1.0 / 3.0); - expected = "001."; - SDLTest_AssertPass("Call to SDL_snprintf(\"%%06.2f\", 1.0 + 1.0 / 3.0) with buffer size 5"); - SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text); - SDLTest_AssertCheck(result == 6, "Check result value, expected: 6, got: %d", result); - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_getenv and SDL_setenv - */ -int -stdlib_getsetenv(void *arg) -{ - const int nameLen = 16; - char name[17]; - int counter; - int result; - char * value1; - char * value2; - char * expected; - int overwrite; - char * text; - - /* Create a random name. This tests SDL_getenv, since we need to */ - /* make sure the variable is not set yet (it shouldn't). */ - do { - for(counter = 0; counter < nameLen; counter++) { - name[counter] = (char)SDLTest_RandomIntegerInRange(65, 90); - } - name[nameLen] = '\0'; - - text = SDL_getenv(name); - SDLTest_AssertPass("Call to SDL_getenv('%s')", name); - if (text != NULL) { - SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, SDL_strlen(text)); - } - } while (text != NULL); - - /* Create random values to set */ - value1 = SDLTest_RandomAsciiStringOfSize(10); - value2 = SDLTest_RandomAsciiStringOfSize(10); - - /* Set value 1 without overwrite */ - overwrite = 0; - expected = value1; - result = SDL_setenv(name, value1, overwrite); - SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite); - SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result); - - /* Check value */ - text = SDL_getenv(name); - SDLTest_AssertPass("Call to SDL_getenv('%s')", name); - SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL"); - if (text != NULL) { - SDLTest_AssertCheck( - SDL_strcmp(text, expected) == 0, - "Verify returned text, expected: %s, got: %s", - expected, - text); - } - - /* Set value 2 with overwrite */ - overwrite = 1; - expected = value2; - result = SDL_setenv(name, value2, overwrite); - SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value2, overwrite); - SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result); - - /* Check value */ - text = SDL_getenv(name); - SDLTest_AssertPass("Call to SDL_getenv('%s')", name); - SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL"); - if (text != NULL) { - SDLTest_AssertCheck( - SDL_strcmp(text, expected) == 0, - "Verify returned text, expected: %s, got: %s", - expected, - text); - } - - /* Set value 1 without overwrite */ - overwrite = 0; - expected = value2; - result = SDL_setenv(name, value1, overwrite); - SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite); - SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result); - - /* Check value */ - text = SDL_getenv(name); - SDLTest_AssertPass("Call to SDL_getenv('%s')", name); - SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL"); - if (text != NULL) { - SDLTest_AssertCheck( - SDL_strcmp(text, expected) == 0, - "Verify returned text, expected: %s, got: %s", - expected, - text); - } - - /* Set value 1 without overwrite */ - overwrite = 1; - expected = value1; - result = SDL_setenv(name, value1, overwrite); - SDLTest_AssertPass("Call to SDL_setenv('%s','%s', %i)", name, value1, overwrite); - SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result); - - /* Check value */ - text = SDL_getenv(name); - SDLTest_AssertPass("Call to SDL_getenv('%s')", name); - SDLTest_AssertCheck(text != NULL, "Verify returned text is not NULL"); - if (text != NULL) { - SDLTest_AssertCheck( - SDL_strcmp(text, expected) == 0, - "Verify returned text, expected: %s, got: %s", - expected, - text); - } - - /* Negative cases */ - for (overwrite=0; overwrite <= 1; overwrite++) { - result = SDL_setenv(NULL, value1, overwrite); - SDLTest_AssertPass("Call to SDL_setenv(NULL,'%s', %i)", value1, overwrite); - SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result); - result = SDL_setenv("", value1, overwrite); - SDLTest_AssertPass("Call to SDL_setenv('','%s', %i)", value1, overwrite); - SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result); - result = SDL_setenv("=", value1, overwrite); - SDLTest_AssertPass("Call to SDL_setenv('=','%s', %i)", value1, overwrite); - SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result); - result = SDL_setenv(name, NULL, overwrite); - SDLTest_AssertPass("Call to SDL_setenv('%s', NULL, %i)", name, overwrite); - SDLTest_AssertCheck(result == -1, "Check result, expected: -1, got: %i", result); - } - - /* Clean up */ - SDL_free(value1); - SDL_free(value2); - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_sscanf - */ -#undef SDL_sscanf -int -stdlib_sscanf(void *arg) -{ - int output; - int result; - int expected_output; - int expected_result; - - expected_output = output = 123; - expected_result = -1; - result = SDL_sscanf("", "%i", &output); - SDLTest_AssertPass("Call to SDL_sscanf(\"\", \"%%i\", &output)"); - SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output); - SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); - - expected_output = output = 123; - expected_result = 0; - result = SDL_sscanf("a", "%i", &output); - SDLTest_AssertPass("Call to SDL_sscanf(\"a\", \"%%i\", &output)"); - SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output); - SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); - - output = 123; - expected_output = 2; - expected_result = 1; - result = SDL_sscanf("2", "%i", &output); - SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i\", &output)"); - SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output); - SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* Standard C routine test cases */ -static const SDLTest_TestCaseReference stdlibTest1 = - { (SDLTest_TestCaseFp)stdlib_strlcpy, "stdlib_strlcpy", "Call to SDL_strlcpy", TEST_ENABLED }; - -static const SDLTest_TestCaseReference stdlibTest2 = - { (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED }; - -static const SDLTest_TestCaseReference stdlibTest3 = - { (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED }; - -static const SDLTest_TestCaseReference stdlibTest4 = - { (SDLTest_TestCaseFp)stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED }; - -/* Sequence of Standard C routine test cases */ -static const SDLTest_TestCaseReference *stdlibTests[] = { - &stdlibTest1, &stdlibTest2, &stdlibTest3, &stdlibTest4, NULL -}; - -/* Standard C routine test suite (global) */ -SDLTest_TestSuiteReference stdlibTestSuite = { - "Stdlib", - NULL, - stdlibTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_suites.h b/3rdparty/SDL2/test/testautomation_suites.h deleted file mode 100644 index b5f921e3dae..00000000000 --- a/3rdparty/SDL2/test/testautomation_suites.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Reference to all test suites. - * - */ - -#ifndef _testsuites_h -#define _testsuites_h - -#include "SDL_test.h" - -/* Test collections */ -extern SDLTest_TestSuiteReference audioTestSuite; -extern SDLTest_TestSuiteReference clipboardTestSuite; -extern SDLTest_TestSuiteReference eventsTestSuite; -extern SDLTest_TestSuiteReference keyboardTestSuite; -extern SDLTest_TestSuiteReference mainTestSuite; -extern SDLTest_TestSuiteReference mouseTestSuite; -extern SDLTest_TestSuiteReference pixelsTestSuite; -extern SDLTest_TestSuiteReference platformTestSuite; -extern SDLTest_TestSuiteReference rectTestSuite; -extern SDLTest_TestSuiteReference renderTestSuite; -extern SDLTest_TestSuiteReference rwopsTestSuite; -extern SDLTest_TestSuiteReference sdltestTestSuite; -extern SDLTest_TestSuiteReference stdlibTestSuite; -extern SDLTest_TestSuiteReference surfaceTestSuite; -extern SDLTest_TestSuiteReference syswmTestSuite; -extern SDLTest_TestSuiteReference timerTestSuite; -extern SDLTest_TestSuiteReference videoTestSuite; -extern SDLTest_TestSuiteReference hintsTestSuite; - -/* All test suites */ -SDLTest_TestSuiteReference *testSuites[] = { - &audioTestSuite, - &clipboardTestSuite, - &eventsTestSuite, - &keyboardTestSuite, - &mainTestSuite, - &mouseTestSuite, - &pixelsTestSuite, - &platformTestSuite, - &rectTestSuite, - &renderTestSuite, - &rwopsTestSuite, - &sdltestTestSuite, - &stdlibTestSuite, - &surfaceTestSuite, - &syswmTestSuite, - &timerTestSuite, - &videoTestSuite, - &hintsTestSuite, - NULL -}; - -#endif diff --git a/3rdparty/SDL2/test/testautomation_surface.c b/3rdparty/SDL2/test/testautomation_surface.c deleted file mode 100644 index ca41d4a0cd5..00000000000 --- a/3rdparty/SDL2/test/testautomation_surface.c +++ /dev/null @@ -1,647 +0,0 @@ -/** - * Original code: automated SDL surface test written by Edgar Simo "bobbens" - * Adapted/rewritten for test lib by Andreas Schiffler - */ - -/* Supress C4996 VS compiler warnings for unlink() */ -#define _CRT_SECURE_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE - -#include <stdio.h> -#ifndef _MSC_VER -#include <unistd.h> -#endif -#include <sys/stat.h> - -#include "SDL.h" -#include "SDL_test.h" - -#ifdef __MACOSX__ -#include <unistd.h> /* For unlink() */ -#endif - -/* ================= Test Case Implementation ================== */ - -/* Shared test surface */ - -static SDL_Surface *referenceSurface = NULL; -static SDL_Surface *testSurface = NULL; - -/* Helper functions for the test cases */ - -#define TEST_SURFACE_WIDTH testSurface->w -#define TEST_SURFACE_HEIGHT testSurface->h - -/* Fixture */ - -/* Create a 32-bit writable surface for blitting tests */ -void -_surfaceSetUp(void *arg) -{ - int result; - SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; - SDL_BlendMode currentBlendMode; - Uint32 rmask, gmask, bmask, amask; -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; -#else - rmask = 0x000000ff; - gmask = 0x0000ff00; - bmask = 0x00ff0000; - amask = 0xff000000; -#endif - - referenceSurface = SDLTest_ImageBlit(); /* For size info */ - testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask); - SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL"); - if (testSurface != NULL) { - /* Disable blend mode for target surface */ - result = SDL_SetSurfaceBlendMode(testSurface, blendMode); - SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result); - result = SDL_GetSurfaceBlendMode(testSurface, ¤tBlendMode); - SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result); - SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode); - } -} - -void -_surfaceTearDown(void *arg) -{ - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - SDL_FreeSurface(testSurface); - testSurface = NULL; -} - -/** - * Helper that clears the test surface - */ -void _clearTestSurface() -{ - int ret; - Uint32 color; - - /* Clear surface. */ - color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0); - SDLTest_AssertPass("Call to SDL_MapRGBA()"); - ret = SDL_FillRect( testSurface, NULL, color); - SDLTest_AssertPass("Call to SDL_FillRect()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret); -} - -/** - * Helper that blits in a specific blend mode, -1 for basic blitting, -2 for color mod, -3 for alpha mod, -4 for mixed blend modes. - */ -void _testBlitBlendMode(int mode) -{ - int ret; - int i, j, ni, nj; - SDL_Surface *face; - SDL_Rect rect; - int nmode; - SDL_BlendMode bmode; - int checkFailCount1; - int checkFailCount2; - int checkFailCount3; - int checkFailCount4; - - /* Check test surface */ - SDLTest_AssertCheck(testSurface != NULL, "Verify testSurface is not NULL"); - if (testSurface == NULL) return; - - /* Create sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); - if (face == NULL) return; - - /* Reset alpha modulation */ - ret = SDL_SetSurfaceAlphaMod(face, 255); - SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret); - - /* Reset color modulation */ - ret = SDL_SetSurfaceColorMod(face, 255, 255, 255); - SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret); - - /* Reset color key */ - ret = SDL_SetColorKey(face, SDL_FALSE, 0); - SDLTest_AssertPass("Call to SDL_SetColorKey()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret); - - /* Clear the test surface */ - _clearTestSurface(); - - /* Target rect size */ - rect.w = face->w; - rect.h = face->h; - - /* Steps to take */ - ni = testSurface->w - face->w; - nj = testSurface->h - face->h; - - /* Optionally set blend mode. */ - if (mode >= 0) { - ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode ); - SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret); - } - - /* Test blend mode. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - checkFailCount3 = 0; - checkFailCount4 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - if (mode == -2) { - /* Set color mod. */ - ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j ); - if (ret != 0) checkFailCount2++; - } - else if (mode == -3) { - /* Set alpha mod. */ - ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i ); - if (ret != 0) checkFailCount3++; - } - else if (mode == -4) { - /* Crazy blending mode magic. */ - nmode = (i/4*j/4) % 4; - if (nmode==0) { - bmode = SDL_BLENDMODE_NONE; - } else if (nmode==1) { - bmode = SDL_BLENDMODE_BLEND; - } else if (nmode==2) { - bmode = SDL_BLENDMODE_ADD; - } else if (nmode==3) { - bmode = SDL_BLENDMODE_MOD; - } - ret = SDL_SetSurfaceBlendMode( face, bmode ); - if (ret != 0) checkFailCount4++; - } - - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_BlitSurface( face, NULL, testSurface, &rect ); - if (ret != 0) checkFailCount1++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2); - SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", checkFailCount3); - SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4); - - /* Clean up */ - SDL_FreeSurface(face); - face = NULL; -} - -/* Helper to check that a file exists */ -void -_AssertFileExist(const char *filename) -{ - struct stat st; - int ret = stat(filename, &st); - - SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename); -} - - -/* Test case functions */ - -/** - * @brief Tests sprite saving and loading - */ -int -surface_testSaveLoadBitmap(void *arg) -{ - int ret; - const char *sampleFilename = "testSaveLoadBitmap.bmp"; - SDL_Surface *face; - SDL_Surface *rface; - - /* Create sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); - if (face == NULL) return TEST_ABORTED; - - /* Delete test file; ignore errors */ - unlink(sampleFilename); - - /* Save a surface */ - ret = SDL_SaveBMP(face, sampleFilename); - SDLTest_AssertPass("Call to SDL_SaveBMP()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret); - _AssertFileExist(sampleFilename); - - /* Load a surface */ - rface = SDL_LoadBMP(sampleFilename); - SDLTest_AssertPass("Call to SDL_LoadBMP()"); - SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_LoadBMP is not NULL"); - if (rface != NULL) { - SDLTest_AssertCheck(face->w == rface->w, "Verify width of loaded surface, expected: %i, got: %i", face->w, rface->w); - SDLTest_AssertCheck(face->h == rface->h, "Verify height of loaded surface, expected: %i, got: %i", face->h, rface->h); - } - - /* Delete test file; ignore errors */ - unlink(sampleFilename); - - /* Clean up */ - SDL_FreeSurface(face); - face = NULL; - SDL_FreeSurface(rface); - rface = NULL; - - return TEST_COMPLETED; -} - -/* ! - * Tests surface conversion. - */ -int -surface_testSurfaceConversion(void *arg) -{ - SDL_Surface *rface = NULL, *face = NULL; - int ret = 0; - - /* Create sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); - if (face == NULL) - return TEST_ABORTED; - - /* Set transparent pixel as the pixel at (0,0) */ - if (face->format->palette) { - ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); - SDLTest_AssertPass("Call to SDL_SetColorKey()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); - } - - /* Convert to 32 bit to compare. */ - rface = SDL_ConvertSurface( face, testSurface->format, 0 ); - SDLTest_AssertPass("Call to SDL_ConvertSurface()"); - SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL"); - - /* Compare surface. */ - ret = SDLTest_CompareSurfaces( rface, face, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(face); - face = NULL; - SDL_FreeSurface(rface); - rface = NULL; - - return TEST_COMPLETED; -} - - -/* ! - * Tests surface conversion across all pixel formats. - */ -int -surface_testCompleteSurfaceConversion(void *arg) -{ - Uint32 pixel_formats[] = { - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB332, - SDL_PIXELFORMAT_RGB444, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_BGR555, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_RGBA4444, - SDL_PIXELFORMAT_ABGR4444, - SDL_PIXELFORMAT_BGRA4444, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGBA5551, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGRA5551, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_BGR565, - SDL_PIXELFORMAT_RGB24, - SDL_PIXELFORMAT_BGR24, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_RGBX8888, - SDL_PIXELFORMAT_BGR888, - SDL_PIXELFORMAT_BGRX8888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_ARGB2101010, - }; - SDL_Surface *face = NULL, *cvt1, *cvt2, *final; - SDL_PixelFormat *fmt1, *fmt2; - int i, j, ret = 0; - - /* Create sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); - if (face == NULL) - return TEST_ABORTED; - - /* Set transparent pixel as the pixel at (0,0) */ - if (face->format->palette) { - ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); - SDLTest_AssertPass("Call to SDL_SetColorKey()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); - } - - for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) { - for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) { - fmt1 = SDL_AllocFormat(pixel_formats[i]); - SDL_assert(fmt1 != NULL); - cvt1 = SDL_ConvertSurface(face, fmt1, 0); - SDL_assert(cvt1 != NULL); - - fmt2 = SDL_AllocFormat(pixel_formats[j]); - SDL_assert(fmt1 != NULL); - cvt2 = SDL_ConvertSurface(cvt1, fmt2, 0); - SDL_assert(cvt2 != NULL); - - if ( fmt1->BytesPerPixel == face->format->BytesPerPixel && - fmt2->BytesPerPixel == face->format->BytesPerPixel && - (fmt1->Amask != 0) == (face->format->Amask != 0) && - (fmt2->Amask != 0) == (face->format->Amask != 0) ) { - final = SDL_ConvertSurface( cvt2, face->format, 0 ); - SDL_assert(final != NULL); - - /* Compare surface. */ - ret = SDLTest_CompareSurfaces( face, final, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - SDL_FreeSurface(final); - } - - SDL_FreeSurface(cvt1); - SDL_FreeFormat(fmt1); - SDL_FreeSurface(cvt2); - SDL_FreeFormat(fmt2); - } - } - - /* Clean up. */ - SDL_FreeSurface( face ); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests sprite loading. A failure case. - */ -int -surface_testLoadFailure(void *arg) -{ - SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp"); - SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp"); - - return TEST_COMPLETED; -} - -/** - * @brief Tests some blitting routines. - */ -int -surface_testBlit(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Basic blitting */ - _testBlitBlendMode(-1); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlit(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; -} - -/** - * @brief Tests some blitting routines with color mod - */ -int -surface_testBlitColorMod(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Basic blitting with color mod */ - _testBlitBlendMode(-2); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitColor(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; -} - -/** - * @brief Tests some blitting routines with alpha mod - */ -int -surface_testBlitAlphaMod(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Basic blitting with alpha mod */ - _testBlitBlendMode(-3); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitAlpha(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests some more blitting routines. - */ -int -surface_testBlitBlendNone(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Basic blitting */ - _testBlitBlendMode(SDL_BLENDMODE_NONE); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendNone(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; -} - -/** - * @brief Tests some more blitting routines. - */ -int -surface_testBlitBlendBlend(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Blend blitting */ - _testBlitBlendMode(SDL_BLENDMODE_BLEND); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlend(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; -} - -/** - * @brief Tests some more blitting routines. - */ -int -surface_testBlitBlendAdd(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Add blitting */ - _testBlitBlendMode(SDL_BLENDMODE_ADD); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendAdd(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; -} - -/** - * @brief Tests some more blitting routines. - */ -int -surface_testBlitBlendMod(void *arg) -{ - int ret; - SDL_Surface *compareSurface; - - /* Mod blitting */ - _testBlitBlendMode(SDL_BLENDMODE_MOD); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendMod(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; -} - -/** - * @brief Tests some more blitting routines with loop - */ -int -surface_testBlitBlendLoop(void *arg) { - - int ret; - SDL_Surface *compareSurface; - - /* All blitting modes */ - _testBlitBlendMode(-4); - - /* Verify result by comparing surfaces */ - compareSurface = SDLTest_ImageBlitBlendAll(); - ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - SDL_FreeSurface(compareSurface); - - return TEST_COMPLETED; - -} - -/* ================= Test References ================== */ - -/* Surface test cases */ -static const SDLTest_TestCaseReference surfaceTest1 = - { (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED}; - -static const SDLTest_TestCaseReference surfaceTest2 = - { (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED}; - -static const SDLTest_TestCaseReference surfaceTest3 = - { (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED}; - -static const SDLTest_TestCaseReference surfaceTest4 = - { (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED}; - -static const SDLTest_TestCaseReference surfaceTest5 = - { (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED}; - -static const SDLTest_TestCaseReference surfaceTest6 = - { (SDLTest_TestCaseFp)surface_testCompleteSurfaceConversion, "surface_testCompleteSurfaceConversion", "Tests surface conversion across all pixel formats", TEST_ENABLED}; - -static const SDLTest_TestCaseReference surfaceTest7 = - { (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED}; - -static const SDLTest_TestCaseReference surfaceTest8 = - { (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED}; - -/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference surfaceTest9 = - { (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blitting routines with various blending modes", TEST_DISABLED}; - -/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference surfaceTest10 = - { (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED}; - -/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ -static const SDLTest_TestCaseReference surfaceTest11 = - { (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED}; - -static const SDLTest_TestCaseReference surfaceTest12 = - { (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED}; - -/* Sequence of Surface test cases */ -static const SDLTest_TestCaseReference *surfaceTests[] = { - &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5, - &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10, - &surfaceTest11, &surfaceTest12, NULL -}; - -/* Surface test suite (global) */ -SDLTest_TestSuiteReference surfaceTestSuite = { - "Surface", - _surfaceSetUp, - surfaceTests, - _surfaceTearDown - -}; diff --git a/3rdparty/SDL2/test/testautomation_syswm.c b/3rdparty/SDL2/test/testautomation_syswm.c deleted file mode 100644 index d9fd982b37a..00000000000 --- a/3rdparty/SDL2/test/testautomation_syswm.c +++ /dev/null @@ -1,61 +0,0 @@ -/** - * SysWM test suite - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_syswm.h" -#include "SDL_test.h" - -/* Test case functions */ - -/** - * @brief Call to SDL_GetWindowWMInfo - */ -int -syswm_getWindowWMInfo(void *arg) -{ - SDL_bool result; - SDL_Window *window; - SDL_SysWMinfo info; - - window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN); - SDLTest_AssertPass("Call to SDL_CreateWindow()"); - SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); - if (window == NULL) { - return TEST_ABORTED; - } - - /* Initialize info structure with SDL version info */ - SDL_VERSION(&info.version); - - /* Make call */ - result = SDL_GetWindowWMInfo(window, &info); - SDLTest_AssertPass("Call to SDL_GetWindowWMInfo()"); - SDLTest_Log((result == SDL_TRUE) ? "Got window information" : "Couldn't get window information"); - - SDL_DestroyWindow(window); - SDLTest_AssertPass("Call to SDL_DestroyWindow()"); - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* SysWM test cases */ -static const SDLTest_TestCaseReference syswmTest1 = - { (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED }; - -/* Sequence of SysWM test cases */ -static const SDLTest_TestCaseReference *syswmTests[] = { - &syswmTest1, NULL -}; - -/* SysWM test suite (global) */ -SDLTest_TestSuiteReference syswmTestSuite = { - "SysWM", - NULL, - syswmTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_timer.c b/3rdparty/SDL2/test/testautomation_timer.c deleted file mode 100644 index 6d73856ee2f..00000000000 --- a/3rdparty/SDL2/test/testautomation_timer.c +++ /dev/null @@ -1,201 +0,0 @@ -/** - * Timer test suite - */ - -#include <stdio.h> - -#include "SDL.h" -#include "SDL_test.h" - -/* Flag indicating if the param should be checked */ -int _paramCheck = 0; - -/* Userdata value to check */ -int _paramValue = 0; - -/* Flag indicating that the callback was called */ -int _timerCallbackCalled = 0; - -/* Fixture */ - -void -_timerSetUp(void *arg) -{ - /* Start SDL timer subsystem */ - int ret = SDL_InitSubSystem( SDL_INIT_TIMER ); - SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)"); - SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)"); - if (ret != 0) { - SDLTest_LogError("%s", SDL_GetError()); - } -} - -/* Test case functions */ - -/** - * @brief Call to SDL_GetPerformanceCounter - */ -int -timer_getPerformanceCounter(void *arg) -{ - Uint64 result; - - result = SDL_GetPerformanceCounter(); - SDLTest_AssertPass("Call to SDL_GetPerformanceCounter()"); - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %"SDL_PRIu64, result); - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_GetPerformanceFrequency - */ -int -timer_getPerformanceFrequency(void *arg) -{ - Uint64 result; - - result = SDL_GetPerformanceFrequency(); - SDLTest_AssertPass("Call to SDL_GetPerformanceFrequency()"); - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %"SDL_PRIu64, result); - - return TEST_COMPLETED; -} - -/** - * @brief Call to SDL_Delay and SDL_GetTicks - */ -int -timer_delayAndGetTicks(void *arg) -{ - const Uint32 testDelay = 100; - const Uint32 marginOfError = 25; - Uint32 result; - Uint32 result2; - Uint32 difference; - - /* Zero delay */ - SDL_Delay(0); - SDLTest_AssertPass("Call to SDL_Delay(0)"); - - /* Non-zero delay */ - SDL_Delay(1); - SDLTest_AssertPass("Call to SDL_Delay(1)"); - - SDL_Delay(SDLTest_RandomIntegerInRange(5, 15)); - SDLTest_AssertPass("Call to SDL_Delay()"); - - /* Get ticks count - should be non-zero by now */ - result = SDL_GetTicks(); - SDLTest_AssertPass("Call to SDL_GetTicks()"); - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %d", result); - - /* Delay a bit longer and measure ticks and verify difference */ - SDL_Delay(testDelay); - SDLTest_AssertPass("Call to SDL_Delay(%d)", testDelay); - result2 = SDL_GetTicks(); - SDLTest_AssertPass("Call to SDL_GetTicks()"); - SDLTest_AssertCheck(result2 > 0, "Check result value, expected: >0, got: %d", result2); - difference = result2 - result; - SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%d, got: %d", testDelay - marginOfError, difference); - SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%d, got: %d", testDelay + marginOfError, difference); - - return TEST_COMPLETED; -} - -/* Test callback */ -Uint32 _timerTestCallback(Uint32 interval, void *param) -{ - _timerCallbackCalled = 1; - - if (_paramCheck != 0) { - SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL"); - if (param != NULL) { - SDLTest_AssertCheck(*(int *)param == _paramValue, "Check param value, expected: %i, got: %i", _paramValue, *(int *)param); - } - } - - return 0; -} - -/** - * @brief Call to SDL_AddTimer and SDL_RemoveTimer - */ -int -timer_addRemoveTimer(void *arg) -{ - SDL_TimerID id; - SDL_bool result; - int param; - - /* Reset state */ - _paramCheck = 0; - _timerCallbackCalled = 0; - - /* Set timer with a long delay */ - id = SDL_AddTimer(10000, _timerTestCallback, NULL); - SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)"); - SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); - - /* Remove timer again and check that callback was not called */ - result = SDL_RemoveTimer(id); - SDLTest_AssertPass("Call to SDL_RemoveTimer()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Check result value, expected: %i, got: %i", SDL_TRUE, result); - SDLTest_AssertCheck(_timerCallbackCalled == 0, "Check callback WAS NOT called, expected: 0, got: %i", _timerCallbackCalled); - - /* Try to remove timer again (should be a NOOP) */ - result = SDL_RemoveTimer(id); - SDLTest_AssertPass("Call to SDL_RemoveTimer()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); - - /* Reset state */ - param = SDLTest_RandomIntegerInRange(-1024, 1024); - _paramCheck = 1; - _paramValue = param; - _timerCallbackCalled = 0; - - /* Set timer with a short delay */ - id = SDL_AddTimer(10, _timerTestCallback, (void *)¶m); - SDLTest_AssertPass("Call to SDL_AddTimer(10, param)"); - SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); - - /* Wait to let timer trigger callback */ - SDL_Delay(100); - SDLTest_AssertPass("Call to SDL_Delay(100)"); - - /* Remove timer again and check that callback was called */ - result = SDL_RemoveTimer(id); - SDLTest_AssertPass("Call to SDL_RemoveTimer()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); - SDLTest_AssertCheck(_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", _timerCallbackCalled); - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* Timer test cases */ -static const SDLTest_TestCaseReference timerTest1 = - { (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED }; - -static const SDLTest_TestCaseReference timerTest2 = - { (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED }; - -static const SDLTest_TestCaseReference timerTest3 = - { (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED }; - -static const SDLTest_TestCaseReference timerTest4 = - { (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED }; - -/* Sequence of Timer test cases */ -static const SDLTest_TestCaseReference *timerTests[] = { - &timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL -}; - -/* Timer test suite (global) */ -SDLTest_TestSuiteReference timerTestSuite = { - "Timer", - _timerSetUp, - timerTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testautomation_video.c b/3rdparty/SDL2/test/testautomation_video.c deleted file mode 100644 index 7b86cfba908..00000000000 --- a/3rdparty/SDL2/test/testautomation_video.c +++ /dev/null @@ -1,1811 +0,0 @@ -/** - * Video test suite - */ - -#include <stdio.h> -#include <string.h> - -/* Visual Studio 2008 doesn't have stdint.h */ -#if defined(_MSC_VER) && _MSC_VER <= 1500 -#define UINT8_MAX ~(Uint8)0 -#define UINT16_MAX ~(Uint16)0 -#define UINT32_MAX ~(Uint32)0 -#define UINT64_MAX ~(Uint64)0 -#else -#include <stdint.h> -#endif - -#include "SDL.h" -#include "SDL_test.h" - -/* Private helpers */ - -/* - * Create a test window - */ -SDL_Window *_createVideoSuiteTestWindow(const char *title) -{ - SDL_Window* window; - int x, y, w, h; - SDL_WindowFlags flags; - - /* Standard window */ - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); - w = SDLTest_RandomIntegerInRange(320, 1024); - h = SDLTest_RandomIntegerInRange(320, 768); - flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; - - window = SDL_CreateWindow(title, x, y, w, h, flags); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - - return window; -} - -/* - * Destroy test window - */ -void _destroyVideoSuiteTestWindow(SDL_Window *window) -{ - if (window != NULL) { - SDL_DestroyWindow(window); - window = NULL; - SDLTest_AssertPass("Call to SDL_DestroyWindow()"); - } -} - -/* Test case functions */ - -/** - * @brief Enable and disable screensaver while checking state - */ -int -video_enableDisableScreensaver(void *arg) -{ - SDL_bool initialResult; - SDL_bool result; - - /* Get current state and proceed according to current state */ - initialResult = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - if (initialResult == SDL_TRUE) { - - /* Currently enabled: disable first, then enable again */ - - /* Disable screensaver and check */ - SDL_DisableScreenSaver(); - SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); - - /* Enable screensaver and check */ - SDL_EnableScreenSaver(); - SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); - - } else { - - /* Currently disabled: enable first, then disable again */ - - /* Enable screensaver and check */ - SDL_EnableScreenSaver(); - SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); - - /* Disable screensaver and check */ - SDL_DisableScreenSaver(); - SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests the functionality of the SDL_CreateWindow function using different positions - */ -int -video_createWindowVariousPositions(void *arg) -{ - SDL_Window* window; - const char* title = "video_createWindowVariousPositions Test Window"; - int x, y, w, h; - int xVariation, yVariation; - - for (xVariation = 0; xVariation < 6; xVariation++) { - for (yVariation = 0; yVariation < 6; yVariation++) { - switch(xVariation) { - case 0: - /* Zero X Position */ - x = 0; - break; - case 1: - /* Random X position inside screen */ - x = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - x = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random X position outside screen (negative) */ - x = SDLTest_RandomIntegerInRange(-1000, -100); - break; - case 4: - /* Centered X position */ - x = SDL_WINDOWPOS_CENTERED; - break; - case 5: - /* Undefined X position */ - x = SDL_WINDOWPOS_UNDEFINED; - break; - } - - switch(yVariation) { - case 0: - /* Zero X Position */ - y = 0; - break; - case 1: - /* Random X position inside screen */ - y = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - y = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random Y position outside screen (negative) */ - y = SDLTest_RandomIntegerInRange(-1000, -100); - break; - case 4: - /* Centered Y position */ - y = SDL_WINDOWPOS_CENTERED; - break; - case 5: - /* Undefined Y position */ - y = SDL_WINDOWPOS_UNDEFINED; - break; - } - - w = SDLTest_RandomIntegerInRange(32, 96); - h = SDLTest_RandomIntegerInRange(32, 96); - window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - } - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests the functionality of the SDL_CreateWindow function using different sizes - */ -int -video_createWindowVariousSizes(void *arg) -{ - SDL_Window* window; - const char* title = "video_createWindowVariousSizes Test Window"; - int x, y, w, h; - int wVariation, hVariation; - - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); - for (wVariation = 0; wVariation < 3; wVariation++) { - for (hVariation = 0; hVariation < 3; hVariation++) { - switch(wVariation) { - case 0: - /* Width of 1 */ - w = 1; - break; - case 1: - /* Random "normal" width */ - w = SDLTest_RandomIntegerInRange(320, 1920); - break; - case 2: - /* Random "large" width */ - w = SDLTest_RandomIntegerInRange(2048, 4095); - break; - } - - switch(hVariation) { - case 0: - /* Height of 1 */ - h = 1; - break; - case 1: - /* Random "normal" height */ - h = SDLTest_RandomIntegerInRange(320, 1080); - break; - case 2: - /* Random "large" height */ - h = SDLTest_RandomIntegerInRange(2048, 4095); - break; - } - - window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - } - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests the functionality of the SDL_CreateWindow function using different flags - */ -int -video_createWindowVariousFlags(void *arg) -{ - SDL_Window* window; - const char* title = "video_createWindowVariousFlags Test Window"; - int x, y, w, h; - int fVariation; - SDL_WindowFlags flags; - - /* Standard window */ - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); - w = SDLTest_RandomIntegerInRange(320, 1024); - h = SDLTest_RandomIntegerInRange(320, 768); - - for (fVariation = 0; fVariation < 13; fVariation++) { - switch(fVariation) { - case 0: - flags = SDL_WINDOW_FULLSCREEN; - /* Skip - blanks screen; comment out next line to run test */ - continue; - break; - case 1: - flags = SDL_WINDOW_FULLSCREEN_DESKTOP; - /* Skip - blanks screen; comment out next line to run test */ - continue; - break; - case 2: - flags = SDL_WINDOW_OPENGL; - break; - case 3: - flags = SDL_WINDOW_SHOWN; - break; - case 4: - flags = SDL_WINDOW_HIDDEN; - break; - case 5: - flags = SDL_WINDOW_BORDERLESS; - break; - case 6: - flags = SDL_WINDOW_RESIZABLE; - break; - case 7: - flags = SDL_WINDOW_MINIMIZED; - break; - case 8: - flags = SDL_WINDOW_MAXIMIZED; - break; - case 9: - flags = SDL_WINDOW_INPUT_GRABBED; - break; - case 10: - flags = SDL_WINDOW_INPUT_FOCUS; - break; - case 11: - flags = SDL_WINDOW_MOUSE_FOCUS; - break; - case 12: - flags = SDL_WINDOW_FOREIGN; - break; - } - - window = SDL_CreateWindow(title, x, y, w, h, flags); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); - SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - } - - return TEST_COMPLETED; -} - - -/** - * @brief Tests the functionality of the SDL_GetWindowFlags function - */ -int -video_getWindowFlags(void *arg) -{ - SDL_Window* window; - const char* title = "video_getWindowFlags Test Window"; - SDL_WindowFlags flags; - Uint32 actualFlags; - - /* Reliable flag set always set in test window */ - flags = SDL_WINDOW_SHOWN; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window != NULL) { - actualFlags = SDL_GetWindowFlags(window); - SDLTest_AssertPass("Call to SDL_GetWindowFlags()"); - SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags); - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - return TEST_COMPLETED; -} - -/** - * @brief Tests the functionality of the SDL_GetNumDisplayModes function - */ -int -video_getNumDisplayModes(void *arg) -{ - int result; - int displayNum; - int i; - - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - - /* Make call for each display */ - for (i=0; i<displayNum; i++) { - result = SDL_GetNumDisplayModes(i); - SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i); - SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result); - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests negative call to SDL_GetNumDisplayModes function - */ -int -video_getNumDisplayModesNegative(void *arg) -{ - int result; - int displayNum; - int displayIndex; - - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - - /* Invalid boundary values */ - displayIndex = SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE); - result = SDL_GetNumDisplayModes(displayIndex); - SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex); - SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); - - /* Large (out-of-bounds) display index */ - displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000); - result = SDL_GetNumDisplayModes(displayIndex); - SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex); - SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); - - displayIndex = SDLTest_RandomIntegerInRange(1000, 2000); - result = SDL_GetNumDisplayModes(displayIndex); - SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex); - SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result); - - return TEST_COMPLETED; -} - -/** - * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution - */ -int -video_getClosestDisplayModeCurrentResolution(void *arg) -{ - int result; - SDL_DisplayMode current; - SDL_DisplayMode target; - SDL_DisplayMode closest; - SDL_DisplayMode* dResult; - int displayNum; - int i; - int variation; - - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - - /* Make calls for each display */ - for (i=0; i<displayNum; i++) { - SDLTest_Log("Testing against display: %d", i); - - /* Get first display mode to get a sane resolution; this should always work */ - result = SDL_GetDisplayMode(i, 0, ¤t); - SDLTest_AssertPass("Call to SDL_GetDisplayMode()"); - SDLTest_AssertCheck(result == 0, "Verify return value, expected: 0, got: %d", result); - if (result != 0) { - return TEST_ABORTED; - } - - /* Set the desired resolution equals to current resolution */ - target.w = current.w; - target.h = current.h; - for (variation = 0; variation < 8; variation ++) { - /* Vary constraints on other query parameters */ - target.format = (variation & 1) ? current.format : 0; - target.refresh_rate = (variation & 2) ? current.refresh_rate : 0; - target.driverdata = (variation & 4) ? current.driverdata : 0; - - /* Make call */ - dResult = SDL_GetClosestDisplayMode(i, &target, &closest); - SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation); - SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL"); - - /* Check that one gets the current resolution back again */ - SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w); - SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h); - SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w); - SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h); - } - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution - */ -int -video_getClosestDisplayModeRandomResolution(void *arg) -{ - SDL_DisplayMode target; - SDL_DisplayMode closest; - SDL_DisplayMode* dResult; - int displayNum; - int i; - int variation; - - /* Get number of displays */ - displayNum = SDL_GetNumVideoDisplays(); - SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()"); - - /* Make calls for each display */ - for (i=0; i<displayNum; i++) { - SDLTest_Log("Testing against display: %d", i); - - for (variation = 0; variation < 16; variation ++) { - - /* Set random constraints */ - target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0; - target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0; - target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0; - target.refresh_rate = (variation & 8) ? SDLTest_RandomIntegerInRange(25, 120) : 0; - target.driverdata = 0; - - /* Make call; may or may not find anything, so don't validate any further */ - dResult = SDL_GetClosestDisplayMode(i, &target, &closest); - SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation); - } - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowBrightness - * -* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness - */ -int -video_getWindowBrightness(void *arg) -{ - SDL_Window* window; - const char* title = "video_getWindowBrightness Test Window"; - float result; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window != NULL) { - result = SDL_GetWindowBrightness(window); - SDLTest_AssertPass("Call to SDL_GetWindowBrightness()"); - SDLTest_AssertCheck(result >= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result); - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowBrightness with invalid input - * -* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness - */ -int -video_getWindowBrightnessNegative(void *arg) -{ - const char *invalidWindowError = "Invalid window"; - char *lastError; - float result; - - /* Call against invalid window */ - result = SDL_GetWindowBrightness(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)"); - SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); - if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - invalidWindowError, - lastError); - } - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowDisplayMode - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode - */ -int -video_getWindowDisplayMode(void *arg) -{ - SDL_Window* window; - const char* title = "video_getWindowDisplayMode Test Window"; - SDL_DisplayMode mode; - int result; - - /* Invalidate part of the mode content so we can check values later */ - mode.w = -1; - mode.h = -1; - mode.refresh_rate = -1; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window != NULL) { - result = SDL_GetWindowDisplayMode(window, &mode); - SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w); - SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h); - SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate); - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - return TEST_COMPLETED; -} - -/* Helper function that checks for an 'Invalid window' error */ -void _checkInvalidWindowError() -{ - const char *invalidWindowError = "Invalid window"; - char *lastError; - - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); - if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - invalidWindowError, - lastError); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } -} - -/** - * @brief Tests call to SDL_GetWindowDisplayMode with invalid input - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode - */ -int -video_getWindowDisplayModeNegative(void *arg) -{ - const char *expectedError = "Parameter 'mode' is invalid"; - char *lastError; - SDL_Window* window; - const char* title = "video_getWindowDisplayModeNegative Test Window"; - SDL_DisplayMode mode; - int result; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window != NULL) { - result = SDL_GetWindowDisplayMode(window, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)"); - SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result); - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); - if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - expectedError, - lastError); - } - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Call against invalid window */ - result = SDL_GetWindowDisplayMode(NULL, &mode); - SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)"); - SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowGammaRamp - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp - */ -int -video_getWindowGammaRamp(void *arg) -{ - SDL_Window* window; - const char* title = "video_getWindowGammaRamp Test Window"; - Uint16 red[256]; - Uint16 green[256]; - Uint16 blue[256]; - int result; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - /* Retrieve no channel */ - result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - /* Retrieve single channel */ - result = SDL_GetWindowGammaRamp(window, red, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - result = SDL_GetWindowGammaRamp(window, NULL, green, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - /* Retrieve two channels */ - result = SDL_GetWindowGammaRamp(window, red, green, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - result = SDL_GetWindowGammaRamp(window, NULL, green, blue); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - result = SDL_GetWindowGammaRamp(window, red, NULL, blue); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - /* Retrieve all channels */ - result = SDL_GetWindowGammaRamp(window, red, green, blue); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowGammaRamp with invalid input - * -* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp - */ -int -video_getWindowGammaRampNegative(void *arg) -{ - Uint16 red[256]; - Uint16 green[256]; - Uint16 blue[256]; - int result; - - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* Call against invalid window */ - result = SDL_GetWindowGammaRamp(NULL, red, green, blue); - SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)"); - SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %i", result); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - -/* Helper for setting and checking the window grab state */ -void -_setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState) -{ - SDL_bool currentState; - - /* Set state */ - SDL_SetWindowGrab(window, desiredState); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); - - /* Get and check state */ - currentState = SDL_GetWindowGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); - SDLTest_AssertCheck( - currentState == desiredState, - "Validate returned state; expected: %s, got: %s", - (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", - (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); -} - -/** - * @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab - */ -int -video_getSetWindowGrab(void *arg) -{ - const char* title = "video_getSetWindowGrab Test Window"; - SDL_Window* window; - SDL_bool originalState, dummyState, currentState, desiredState; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - /* Get state */ - originalState = SDL_GetWindowGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); - - /* F */ - _setAndCheckWindowGrabState(window, SDL_FALSE); - - /* F --> F */ - _setAndCheckWindowGrabState(window, SDL_FALSE); - - /* F --> T */ - _setAndCheckWindowGrabState(window, SDL_TRUE); - - /* T --> T */ - _setAndCheckWindowGrabState(window, SDL_TRUE); - - /* T --> F */ - _setAndCheckWindowGrabState(window, SDL_FALSE); - - /* Negative tests */ - dummyState = SDL_GetWindowGrab(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)"); - _checkInvalidWindowError(); - - SDL_SetWindowGrab(NULL, SDL_FALSE); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); - _checkInvalidWindowError(); - - SDL_SetWindowGrab(NULL, SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); - _checkInvalidWindowError(); - - /* State should still be F */ - desiredState = SDL_FALSE; - currentState = SDL_GetWindowGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); - SDLTest_AssertCheck( - currentState == desiredState, - "Validate returned state; expected: %s, got: %s", - (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", - (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); - - /* Restore state */ - _setAndCheckWindowGrabState(window, originalState); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID - */ -int -video_getWindowId(void *arg) -{ - const char* title = "video_getWindowId Test Window"; - SDL_Window* window; - SDL_Window* result; - Uint32 id, randomId; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - /* Get ID */ - id = SDL_GetWindowID(window); - SDLTest_AssertPass("Call to SDL_GetWindowID()"); - - /* Get window from ID */ - result = SDL_GetWindowFromID(id); - SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id); - SDLTest_AssertCheck(result == window, "Verify result matches window pointer"); - - /* Get window from random large ID, no result check */ - randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX); - result = SDL_GetWindowFromID(randomId); - SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId); - - /* Get window from 0 and Uint32 max ID, no result check */ - result = SDL_GetWindowFromID(0); - SDLTest_AssertPass("Call to SDL_GetWindowID(0)"); - result = SDL_GetWindowFromID(UINT32_MAX); - SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Get window from ID for closed window */ - result = SDL_GetWindowFromID(id); - SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); - - /* Negative test */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - id = SDL_GetWindowID(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowPixelFormat - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat - */ -int -video_getWindowPixelFormat(void *arg) -{ - const char* title = "video_getWindowPixelFormat Test Window"; - SDL_Window* window; - Uint32 format; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - /* Get format */ - format = SDL_GetWindowPixelFormat(window); - SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()"); - SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Negative test */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - format = SDL_GetWindowPixelFormat(NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition - */ -int -video_getSetWindowPosition(void *arg) -{ - const char* title = "video_getSetWindowPosition Test Window"; - SDL_Window* window; - int xVariation, yVariation; - int referenceX, referenceY; - int currentX, currentY; - int desiredX, desiredY; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - for (xVariation = 0; xVariation < 4; xVariation++) { - for (yVariation = 0; yVariation < 4; yVariation++) { - switch(xVariation) { - case 0: - /* Zero X Position */ - desiredX = 0; - break; - case 1: - /* Random X position inside screen */ - desiredX = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - desiredX = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random X position outside screen (negative) */ - desiredX = SDLTest_RandomIntegerInRange(-1000, -100); - break; - } - - switch(yVariation) { - case 0: - /* Zero X Position */ - desiredY = 0; - break; - case 1: - /* Random X position inside screen */ - desiredY = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - desiredY = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random Y position outside screen (negative) */ - desiredY = SDLTest_RandomIntegerInRange(-1000, -100); - break; - } - - /* Set position */ - SDL_SetWindowPosition(window, desiredX, desiredY); - SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY); - - /* Get position */ - currentX = desiredX + 1; - currentY = desiredY + 1; - SDL_GetWindowPosition(window, ¤tX, ¤tY); - SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); - SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); - SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); - - /* Get position X */ - currentX = desiredX + 1; - SDL_GetWindowPosition(window, ¤tX, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)"); - SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); - - /* Get position Y */ - currentY = desiredY + 1; - SDL_GetWindowPosition(window, NULL, ¤tY); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)"); - SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); - } - } - - /* Dummy call with both pointers NULL */ - SDL_GetWindowPosition(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)"); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Set some 'magic' value for later check that nothing was changed */ - referenceX = SDLTest_RandomSint32(); - referenceY = SDLTest_RandomSint32(); - currentX = referenceX; - currentY = referenceY; - desiredX = SDLTest_RandomSint32(); - desiredY = SDLTest_RandomSint32(); - - /* Negative tests */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowPosition(NULL, ¤tX, ¤tY); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)"); - SDLTest_AssertCheck( - currentX == referenceX && currentY == referenceY, - "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceX, referenceY, - currentX, currentY); - _checkInvalidWindowError(); - - SDL_GetWindowPosition(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)"); - _checkInvalidWindowError(); - - SDL_SetWindowPosition(NULL, desiredX, desiredY); - SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - -/* Helper function that checks for an 'Invalid parameter' error */ -void _checkInvalidParameterError() -{ - const char *invalidParameterError = "Parameter"; - char *lastError; - - lastError = (char *)SDL_GetError(); - SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); - if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0, - "SDL_GetError(): expected message starts with '%s', was message: '%s'", - invalidParameterError, - lastError); - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - } -} - -/** - * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize - */ -int -video_getSetWindowSize(void *arg) -{ - const char* title = "video_getSetWindowSize Test Window"; - SDL_Window* window; - int result; - SDL_Rect display; - int maxwVariation, maxhVariation; - int wVariation, hVariation; - int referenceW, referenceH; - int currentW, currentH; - int desiredW, desiredH; - - /* Get display bounds for size range */ - result = SDL_GetDisplayBounds(0, &display); - SDLTest_AssertPass("SDL_GetDisplayBounds()"); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); - if (result != 0) return TEST_ABORTED; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - -#ifdef __WIN32__ - /* Platform clips window size to screen size */ - maxwVariation = 4; - maxhVariation = 4; -#else - /* Platform allows window size >= screen size */ - maxwVariation = 5; - maxhVariation = 5; -#endif - - for (wVariation = 0; wVariation < maxwVariation; wVariation++) { - for (hVariation = 0; hVariation < maxhVariation; hVariation++) { - switch(wVariation) { - case 0: - /* 1 Pixel Wide */ - desiredW = 1; - break; - case 1: - /* Random width inside screen */ - desiredW = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Width 1 pixel smaller than screen */ - desiredW = display.w - 1; - break; - case 3: - /* Width at screen size */ - desiredW = display.w; - break; - case 4: - /* Width 1 pixel larger than screen */ - desiredW = display.w + 1; - break; - } - - switch(hVariation) { - case 0: - /* 1 Pixel High */ - desiredH = 1; - break; - case 1: - /* Random height inside screen */ - desiredH = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Height 1 pixel smaller than screen */ - desiredH = display.h - 1; - break; - case 3: - /* Height at screen size */ - desiredH = display.h; - break; - case 4: - /* Height 1 pixel larger than screen */ - desiredH = display.h + 1; - break; - } - - /* Set size */ - SDL_SetWindowSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); - - /* Get size */ - currentW = desiredW + 1; - currentH = desiredH + 1; - SDL_GetWindowSize(window, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowSize()"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); - - /* Get just width */ - currentW = desiredW + 1; - SDL_GetWindowSize(window, ¤tW, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); - - /* Get just height */ - currentH = desiredH + 1; - SDL_GetWindowSize(window, NULL, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)"); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); - } - } - - /* Dummy call with both pointers NULL */ - SDL_GetWindowSize(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)"); - - /* Negative tests for parameter input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (desiredH = -2; desiredH < 2; desiredH++) { - for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { - SDL_SetWindowSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); - _checkInvalidParameterError(); - } - } - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Set some 'magic' value for later check that nothing was changed */ - referenceW = SDLTest_RandomSint32(); - referenceH = SDLTest_RandomSint32(); - currentW = referenceW; - currentH = referenceH; - desiredW = SDLTest_RandomSint32(); - desiredH = SDLTest_RandomSint32(); - - /* Negative tests for window input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowSize(NULL, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)"); - SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); - _checkInvalidWindowError(); - - SDL_GetWindowSize(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)"); - _checkInvalidWindowError(); - - SDL_SetWindowSize(NULL, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize - * - */ -int -video_getSetWindowMinimumSize(void *arg) -{ - const char* title = "video_getSetWindowMinimumSize Test Window"; - SDL_Window* window; - int result; - SDL_Rect display; - int wVariation, hVariation; - int referenceW, referenceH; - int currentW, currentH; - int desiredW, desiredH; - - /* Get display bounds for size range */ - result = SDL_GetDisplayBounds(0, &display); - SDLTest_AssertPass("SDL_GetDisplayBounds()"); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); - if (result != 0) return TEST_ABORTED; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - for (wVariation = 0; wVariation < 5; wVariation++) { - for (hVariation = 0; hVariation < 5; hVariation++) { - switch(wVariation) { - case 0: - /* 1 Pixel Wide */ - desiredW = 1; - break; - case 1: - /* Random width inside screen */ - desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); - break; - case 2: - /* Width at screen size */ - desiredW = display.w; - break; - } - - switch(hVariation) { - case 0: - /* 1 Pixel High */ - desiredH = 1; - break; - case 1: - /* Random height inside screen */ - desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); - break; - case 2: - /* Height at screen size */ - desiredH = display.h; - break; - case 4: - /* Height 1 pixel larger than screen */ - desiredH = display.h + 1; - break; - } - - /* Set size */ - SDL_SetWindowMinimumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); - - /* Get size */ - currentW = desiredW + 1; - currentH = desiredH + 1; - SDL_GetWindowMinimumSize(window, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); - - /* Get just width */ - currentW = desiredW + 1; - SDL_GetWindowMinimumSize(window, ¤tW, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); - - /* Get just height */ - currentH = desiredH + 1; - SDL_GetWindowMinimumSize(window, NULL, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)"); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); - } - } - - /* Dummy call with both pointers NULL */ - SDL_GetWindowMinimumSize(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)"); - - /* Negative tests for parameter input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (desiredH = -2; desiredH < 2; desiredH++) { - for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { - SDL_SetWindowMinimumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); - _checkInvalidParameterError(); - } - } - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Set some 'magic' value for later check that nothing was changed */ - referenceW = SDLTest_RandomSint32(); - referenceH = SDLTest_RandomSint32(); - currentW = referenceW; - currentH = referenceH; - desiredW = SDLTest_RandomSint32(); - desiredH = SDLTest_RandomSint32(); - - /* Negative tests for window input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowMinimumSize(NULL, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)"); - SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); - _checkInvalidWindowError(); - - SDL_GetWindowMinimumSize(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)"); - _checkInvalidWindowError(); - - SDL_SetWindowMinimumSize(NULL, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - -/** - * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize - * - */ -int -video_getSetWindowMaximumSize(void *arg) -{ - const char* title = "video_getSetWindowMaximumSize Test Window"; - SDL_Window* window; - int result; - SDL_Rect display; - int wVariation, hVariation; - int referenceW, referenceH; - int currentW, currentH; - int desiredW, desiredH; - - /* Get display bounds for size range */ - result = SDL_GetDisplayBounds(0, &display); - SDLTest_AssertPass("SDL_GetDisplayBounds()"); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); - if (result != 0) return TEST_ABORTED; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - for (wVariation = 0; wVariation < 3; wVariation++) { - for (hVariation = 0; hVariation < 3; hVariation++) { - switch(wVariation) { - case 0: - /* 1 Pixel Wide */ - desiredW = 1; - break; - case 1: - /* Random width inside screen */ - desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); - break; - case 2: - /* Width at screen size */ - desiredW = display.w; - break; - } - - switch(hVariation) { - case 0: - /* 1 Pixel High */ - desiredH = 1; - break; - case 1: - /* Random height inside screen */ - desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); - break; - case 2: - /* Height at screen size */ - desiredH = display.h; - break; - } - - /* Set size */ - SDL_SetWindowMaximumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); - - /* Get size */ - currentW = desiredW + 1; - currentH = desiredH + 1; - SDL_GetWindowMaximumSize(window, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); - - /* Get just width */ - currentW = desiredW + 1; - SDL_GetWindowMaximumSize(window, ¤tW, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)"); - SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); - - /* Get just height */ - currentH = desiredH + 1; - SDL_GetWindowMaximumSize(window, NULL, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)"); - SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); - } - } - - /* Dummy call with both pointers NULL */ - SDL_GetWindowMaximumSize(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)"); - - /* Negative tests for parameter input */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - for (desiredH = -2; desiredH < 2; desiredH++) { - for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { - SDL_SetWindowMaximumSize(window, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); - _checkInvalidParameterError(); - } - } - } - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - /* Set some 'magic' value for later check that nothing was changed */ - referenceW = SDLTest_RandomSint32(); - referenceH = SDLTest_RandomSint32(); - currentW = referenceW; - currentH = referenceH; - desiredW = SDLTest_RandomSint32(); - desiredH = SDLTest_RandomSint32(); - - /* Negative tests */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_GetWindowMaximumSize(NULL, ¤tW, ¤tH); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)"); - SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); - _checkInvalidWindowError(); - - SDL_GetWindowMaximumSize(NULL, NULL, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)"); - _checkInvalidWindowError(); - - SDL_SetWindowMaximumSize(NULL, desiredW, desiredH); - SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)"); - _checkInvalidWindowError(); - - return TEST_COMPLETED; -} - - -/** - * @brief Tests call to SDL_SetWindowData and SDL_GetWindowData - * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowData - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowData - */ -int -video_getSetWindowData(void *arg) -{ - int returnValue = TEST_COMPLETED; - const char* title = "video_setGetWindowData Test Window"; - SDL_Window* window; - const char *referenceName = "TestName"; - const char *name = "TestName"; - const char *referenceName2 = "TestName2"; - const char *name2 = "TestName2"; - int datasize; - char *referenceUserdata = NULL; - char *userdata = NULL; - char *referenceUserdata2 = NULL; - char *userdata2 = NULL; - char *result; - int iteration; - - /* Call against new test window */ - window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; - - /* Create testdata */ - datasize = SDLTest_RandomIntegerInRange(1, 32); - referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } - userdata = SDL_strdup(referenceUserdata); - if (userdata == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } - datasize = SDLTest_RandomIntegerInRange(1, 32); - referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata2 == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } - userdata2 = (char *)SDL_strdup(referenceUserdata2); - if (userdata2 == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; - } - - /* Get non-existent data */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - - /* Set data */ - result = (char *)SDL_SetWindowData(window, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - - /* Get data (twice) */ - for (iteration = 1; iteration <= 2; iteration++) { - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - } - - /* Set data again twice */ - for (iteration = 1; iteration <= 2; iteration++) { - result = (char *)SDL_SetWindowData(window, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - } - - /* Get data again */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - - /* Set data with new data */ - result = (char *)SDL_SetWindowData(window, name, userdata2); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - - /* Set data with new data again */ - result = (char *)SDL_SetWindowData(window, name, userdata2); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - - /* Get new data */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - - /* Set data with NULL to clear */ - result = (char *)SDL_SetWindowData(window, name, NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - - /* Set data with NULL to clear again */ - result = (char *)SDL_SetWindowData(window, name, NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - - /* Get non-existent data */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - - /* Get non-existent data new name */ - result = (char *)SDL_GetWindowData(window, name2); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2); - - /* Set data (again) */ - result = (char *)SDL_SetWindowData(window, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - - /* Get data (again) */ - result = (char *)SDL_GetWindowData(window, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name); - SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); - SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - - /* Negative test */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - - /* Set with invalid window */ - result = (char *)SDL_SetWindowData(NULL, name, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidWindowError(); - - /* Set data with NULL name, valid userdata */ - result = (char *)SDL_SetWindowData(window, NULL, userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); - - /* Set data with empty name, valid userdata */ - result = (char *)SDL_SetWindowData(window, "", userdata); - SDLTest_AssertPass("Call to SDL_SetWindowData(name='')"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); - - /* Set data with NULL name, NULL userdata */ - result = (char *)SDL_SetWindowData(window, NULL, NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); - - /* Set data with empty name, NULL userdata */ - result = (char *)SDL_SetWindowData(window, "", NULL); - SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); - - /* Get with invalid window */ - result = (char *)SDL_GetWindowData(NULL, name); - SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidWindowError(); - - /* Get data with NULL name */ - result = (char *)SDL_GetWindowData(window, NULL); - SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); - - /* Get data with empty name */ - result = (char *)SDL_GetWindowData(window, ""); - SDLTest_AssertPass("Call to SDL_GetWindowData(name='')"); - SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); - _checkInvalidParameterError(); - - /* Clean up */ - _destroyVideoSuiteTestWindow(window); - - cleanup: - SDL_free(referenceUserdata); - SDL_free(referenceUserdata2); - SDL_free(userdata); - SDL_free(userdata2); - - return returnValue; -} - - -/* ================= Test References ================== */ - -/* Video test cases */ -static const SDLTest_TestCaseReference videoTest1 = - { (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest2 = - { (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest3 = - { (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest4 = - { (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest5 = - { (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest6 = - { (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest7 = - { (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest8 = - { (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest9 = - { (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest10 = - { (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness", "Get window brightness", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest11 = - { (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative", "Get window brightness with invalid input", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest12 = - { (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest13 = - { (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest14 = - { (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp", "Get window gamma ramp", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest15 = - { (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest16 = - { (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest17 = - { (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest18 = - { (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest19 = - { (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest20 = - { (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest21 = - { (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest22 = - { (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED }; - -static const SDLTest_TestCaseReference videoTest23 = - { (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED }; - -/* Sequence of Video test cases */ -static const SDLTest_TestCaseReference *videoTests[] = { - &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, - &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, - &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, - &videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22, - &videoTest23, NULL -}; - -/* Video test suite (global) */ -SDLTest_TestSuiteReference videoTestSuite = { - "Video", - NULL, - videoTests, - NULL -}; diff --git a/3rdparty/SDL2/test/testbounds.c b/3rdparty/SDL2/test/testbounds.c deleted file mode 100644 index b410be96c18..00000000000 --- a/3rdparty/SDL2/test/testbounds.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include "SDL.h" - -int main(int argc, char **argv) -{ - int total, i; - - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError()); - return 1; - } - - total = SDL_GetNumVideoDisplays(); - for (i = 0; i < total; i++) { - SDL_Rect bounds = { -1,-1,-1,-1 }, usable = { -1,-1,-1,-1 }; - SDL_GetDisplayBounds(i, &bounds); - SDL_GetDisplayUsableBounds(i, &usable); - SDL_Log("Display #%d ('%s'): bounds={(%d,%d),%dx%d}, usable={(%d,%d),%dx%d}", - i, SDL_GetDisplayName(i), - bounds.x, bounds.y, bounds.w, bounds.h, - usable.x, usable.y, usable.w, usable.h); - } - - SDL_Quit(); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ - diff --git a/3rdparty/SDL2/test/testcustomcursor.c b/3rdparty/SDL2/test/testcustomcursor.c deleted file mode 100644 index 88b5c322de2..00000000000 --- a/3rdparty/SDL2/test/testcustomcursor.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - -/* Stolen from the mailing list */ -/* Creates a new mouse cursor from an XPM */ - - -/* 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* -init_color_cursor(const char *file) -{ - SDL_Cursor *cursor = NULL; - SDL_Surface *surface = SDL_LoadBMP(file); - if (surface) { - cursor = SDL_CreateColorCursor(surface, 0, 0); - SDL_FreeSurface(surface); - } - return cursor; -} - -static SDL_Cursor* -init_system_cursor(const char *image[]) -{ - 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 (image[4+row][col]) { - case 'X': - data[i] |= 0x01; - mask[i] |= 0x01; - break; - case '.': - mask[i] |= 0x01; - break; - case ' ': - break; - } - } - } - sscanf(image[4+row], "%d,%d", &hot_x, &hot_y); - return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y); -} - -static SDLTest_CommonState *state; -int done; -SDL_Cursor *cursor = NULL; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -void -loop() -{ - int i; - SDL_Event event; - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - const char *color_cursor = NULL; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - color_cursor = argv[i]; - break; - } - if (consumed < 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - - if (color_cursor) { - cursor = init_color_cursor(color_cursor); - } else { - cursor = init_system_cursor(arrow); - } - if (!cursor) { - SDL_Log("Error, couldn't create cursor\n"); - quit(2); - } - SDL_SetCursor(cursor); - - /* Main render loop */ - done = 0; -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - - SDL_FreeCursor(cursor); - quit(0); - - /* keep the compiler happy ... */ - return(0); -} diff --git a/3rdparty/SDL2/test/testdisplayinfo.c b/3rdparty/SDL2/test/testdisplayinfo.c deleted file mode 100644 index f06722e88bc..00000000000 --- a/3rdparty/SDL2/test/testdisplayinfo.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Program to test querying of display info */ - -#include "SDL.h" - -#include <stdio.h> -#include <stdlib.h> - -static void -print_mode(const char *prefix, const SDL_DisplayMode *mode) -{ - if (!mode) - return; - - SDL_Log("%s: fmt=%s w=%d h=%d refresh=%d\n", - prefix, SDL_GetPixelFormatName(mode->format), - mode->w, mode->h, mode->refresh_rate); -} - -int -main(int argc, char *argv[]) -{ - SDL_DisplayMode mode; - int num_displays, dpy; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return 1; - } - - SDL_Log("Using video target '%s'.\n", SDL_GetCurrentVideoDriver()); - num_displays = SDL_GetNumVideoDisplays(); - - SDL_Log("See %d displays.\n", num_displays); - - for (dpy = 0; dpy < num_displays; dpy++) { - const int num_modes = SDL_GetNumDisplayModes(dpy); - SDL_Rect rect = { 0, 0, 0, 0 }; - float ddpi, hdpi, vdpi; - int m; - - SDL_GetDisplayBounds(dpy, &rect); - SDL_Log("%d: \"%s\" (%dx%d, (%d, %d)), %d modes.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, num_modes); - - if (SDL_GetDisplayDPI(dpy, &ddpi, &hdpi, &vdpi) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " DPI: failed to query (%s)\n", SDL_GetError()); - } else { - SDL_Log(" DPI: ddpi=%f; hdpi=%f; vdpi=%f\n", ddpi, hdpi, vdpi); - } - - if (SDL_GetCurrentDisplayMode(dpy, &mode) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " CURRENT: failed to query (%s)\n", SDL_GetError()); - } else { - print_mode("CURRENT", &mode); - } - - if (SDL_GetDesktopDisplayMode(dpy, &mode) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " DESKTOP: failed to query (%s)\n", SDL_GetError()); - } else { - print_mode("DESKTOP", &mode); - } - - for (m = 0; m < num_modes; m++) { - if (SDL_GetDisplayMode(dpy, m, &mode) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " MODE %d: failed to query (%s)\n", m, SDL_GetError()); - } else { - char prefix[64]; - SDL_snprintf(prefix, sizeof (prefix), " MODE %d", m); - print_mode(prefix, &mode); - } - } - - SDL_Log("\n"); - } - - SDL_Quit(); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ - diff --git a/3rdparty/SDL2/test/testdraw2.c b/3rdparty/SDL2/test/testdraw2.c deleted file mode 100644 index 77bd8c1fe67..00000000000 --- a/3rdparty/SDL2/test/testdraw2.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple program: draw as many random objects on the screen as possible */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - -#define NUM_OBJECTS 100 - -static SDLTest_CommonState *state; -static int num_objects; -static SDL_bool cycle_color; -static SDL_bool cycle_alpha; -static int cycle_direction = 1; -static int current_alpha = 255; -static int current_color = 255; -static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; - -int done; - -void -DrawPoints(SDL_Renderer * renderer) -{ - int i; - int x, y; - SDL_Rect viewport; - - /* Query the sizes */ - SDL_RenderGetViewport(renderer, &viewport); - - for (i = 0; i < num_objects * 4; ++i) { - /* Cycle the color and alpha, if desired */ - if (cycle_color) { - current_color += cycle_direction; - if (current_color < 0) { - current_color = 0; - cycle_direction = -cycle_direction; - } - if (current_color > 255) { - current_color = 255; - cycle_direction = -cycle_direction; - } - } - if (cycle_alpha) { - current_alpha += cycle_direction; - if (current_alpha < 0) { - current_alpha = 0; - cycle_direction = -cycle_direction; - } - if (current_alpha > 255) { - current_alpha = 255; - cycle_direction = -cycle_direction; - } - } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); - - x = rand() % viewport.w; - y = rand() % viewport.h; - SDL_RenderDrawPoint(renderer, x, y); - } -} - -void -DrawLines(SDL_Renderer * renderer) -{ - int i; - int x1, y1, x2, y2; - SDL_Rect viewport; - - /* Query the sizes */ - SDL_RenderGetViewport(renderer, &viewport); - - for (i = 0; i < num_objects; ++i) { - /* Cycle the color and alpha, if desired */ - if (cycle_color) { - current_color += cycle_direction; - if (current_color < 0) { - current_color = 0; - cycle_direction = -cycle_direction; - } - if (current_color > 255) { - current_color = 255; - cycle_direction = -cycle_direction; - } - } - if (cycle_alpha) { - current_alpha += cycle_direction; - if (current_alpha < 0) { - current_alpha = 0; - cycle_direction = -cycle_direction; - } - if (current_alpha > 255) { - current_alpha = 255; - cycle_direction = -cycle_direction; - } - } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); - - if (i == 0) { - SDL_RenderDrawLine(renderer, 0, 0, viewport.w - 1, viewport.h - 1); - SDL_RenderDrawLine(renderer, 0, viewport.h - 1, viewport.w - 1, 0); - SDL_RenderDrawLine(renderer, 0, viewport.h / 2, viewport.w - 1, viewport.h / 2); - SDL_RenderDrawLine(renderer, viewport.w / 2, 0, viewport.w / 2, viewport.h - 1); - } else { - x1 = (rand() % (viewport.w*2)) - viewport.w; - x2 = (rand() % (viewport.w*2)) - viewport.w; - y1 = (rand() % (viewport.h*2)) - viewport.h; - y2 = (rand() % (viewport.h*2)) - viewport.h; - SDL_RenderDrawLine(renderer, x1, y1, x2, y2); - } - } -} - -void -DrawRects(SDL_Renderer * renderer) -{ - int i; - SDL_Rect rect; - SDL_Rect viewport; - - /* Query the sizes */ - SDL_RenderGetViewport(renderer, &viewport); - - for (i = 0; i < num_objects / 4; ++i) { - /* Cycle the color and alpha, if desired */ - if (cycle_color) { - current_color += cycle_direction; - if (current_color < 0) { - current_color = 0; - cycle_direction = -cycle_direction; - } - if (current_color > 255) { - current_color = 255; - cycle_direction = -cycle_direction; - } - } - if (cycle_alpha) { - current_alpha += cycle_direction; - if (current_alpha < 0) { - current_alpha = 0; - cycle_direction = -cycle_direction; - } - if (current_alpha > 255) { - current_alpha = 255; - cycle_direction = -cycle_direction; - } - } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); - - rect.w = rand() % (viewport.h / 2); - rect.h = rand() % (viewport.h / 2); - rect.x = (rand() % (viewport.w*2) - viewport.w) - (rect.w / 2); - rect.y = (rand() % (viewport.h*2) - viewport.h) - (rect.h / 2); - SDL_RenderFillRect(renderer, &rect); - } -} - -void -loop() -{ - int i; - SDL_Event event; - - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - if (state->windows[i] == NULL) - continue; - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - - DrawRects(renderer); - DrawLines(renderer); - DrawPoints(renderer); - - SDL_RenderPresent(renderer); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - Uint32 then, now, frames; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize parameters */ - num_objects = NUM_OBJECTS; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - if (SDL_strcasecmp(argv[i], "--blend") == 0) { - if (argv[i + 1]) { - if (SDL_strcasecmp(argv[i + 1], "none") == 0) { - blendMode = SDL_BLENDMODE_NONE; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { - blendMode = SDL_BLENDMODE_BLEND; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { - blendMode = SDL_BLENDMODE_ADD; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { - blendMode = SDL_BLENDMODE_MOD; - consumed = 2; - } - } - } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { - cycle_color = SDL_TRUE; - consumed = 1; - } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) { - cycle_alpha = SDL_TRUE; - consumed = 1; - } else if (SDL_isdigit(*argv[i])) { - num_objects = SDL_atoi(argv[i]); - consumed = 1; - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", - argv[0], SDLTest_CommonUsage(state)); - return 1; - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - return 2; - } - - /* Create the windows and initialize the renderers */ - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawBlendMode(renderer, blendMode); - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - - srand((unsigned int)time(NULL)); - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - ++frames; - loop(); - } -#endif - - - SDLTest_CommonQuit(state); - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testdrawchessboard.c b/3rdparty/SDL2/test/testdrawchessboard.c deleted file mode 100644 index af929e9c3bb..00000000000 --- a/3rdparty/SDL2/test/testdrawchessboard.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. - - This file is created by : Nitin Jain (nitin.j4@samsung.com) -*/ - -/* Sample program: Draw a Chess Board by using SDL_CreateSoftwareRenderer API */ - -#include <stdlib.h> -#include <stdio.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL.h" - -SDL_Window *window; -SDL_Renderer *renderer; -int done; - -void -DrawChessBoard(SDL_Renderer * renderer) -{ - int row = 0,column = 0,x = 0; - SDL_Rect rect, darea; - - /* Get the Size of drawing surface */ - SDL_RenderGetViewport(renderer, &darea); - - for( ; row < 8; row++) - { - column = row%2; - x = column; - for( ; column < 4+(row%2); column++) - { - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF); - - rect.w = darea.w/8; - rect.h = darea.h/8; - rect.x = x * rect.w; - rect.y = row * rect.h; - x = x + 2; - SDL_RenderFillRect(renderer, &rect); - } - } -} - -void -loop() -{ - SDL_Event e; - while (SDL_PollEvent(&e)) { - if (e.type == SDL_QUIT) { - done = 1; -#ifdef __EMSCRIPTEN__ - emscripten_cancel_main_loop(); -#endif - return; - } - - if ((e.type == SDL_KEYDOWN) && (e.key.keysym.sym == SDLK_ESCAPE)) { - done = 1; -#ifdef __EMSCRIPTEN__ - emscripten_cancel_main_loop(); -#endif - return; - } - } - - DrawChessBoard(renderer); - - /* Got everything on rendering surface, - now Update the drawing image on window screen */ - SDL_UpdateWindowSurface(window); -} - -int -main(int argc, char *argv[]) -{ - SDL_Surface *surface; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize SDL */ - if(SDL_Init(SDL_INIT_VIDEO) != 0) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError()); - return 1; - } - - - /* Create window and renderer for given surface */ - window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0); - if(!window) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError()); - return 1; - } - surface = SDL_GetWindowSurface(window); - renderer = SDL_CreateSoftwareRenderer(surface); - if(!renderer) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError()); - return 1; - } - - /* Clear the rendering surface with the specified color */ - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); - SDL_RenderClear(renderer); - - - /* Draw the Image on rendering surface */ - done = 0; -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - - SDL_Quit(); - return 0; -} - diff --git a/3rdparty/SDL2/test/testdropfile.c b/3rdparty/SDL2/test/testdropfile.c deleted file mode 100644 index b729b2f645c..00000000000 --- a/3rdparty/SDL2/test/testdropfile.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "SDL_test_common.h" - -static SDLTest_CommonState *state; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -int -main(int argc, char *argv[]) -{ - int i, done; - SDL_Event event; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - /* needed voodoo to allow app to launch via OS X Finder */ - if (SDL_strncmp(argv[i], "-psn", 4)==0) { - consumed = 1; - } - if (consumed == 0) { - consumed = -1; - } - if (consumed < 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - } - - SDL_EventState(SDL_DROPFILE, SDL_ENABLE); - - /* Main render loop */ - done = 0; - while (!done) { - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - - if (event.type == SDL_DROPBEGIN) { - SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID); - } else if (event.type == SDL_DROPCOMPLETE) { - SDL_Log("Drop complete on window %u", (unsigned int) event.drop.windowID); - } else if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) { - const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text"; - char *dropped_filedir = event.drop.file; - SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir); - SDL_free(dropped_filedir); - } - } - } - - quit(0); - /* keep the compiler happy ... */ - return(0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testerror.c b/3rdparty/SDL2/test/testerror.c deleted file mode 100644 index b5fa3fbc08f..00000000000 --- a/3rdparty/SDL2/test/testerror.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple test of the SDL threading code and error handling */ - -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> - -#include "SDL.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 (%lu) had a problem: %s", - (char *) data, SDL_ThreadID(), "nevermind"); - while (alive) { - SDL_Log("Thread '%s' is alive!\n", (char *) data); - SDL_Delay(1 * 1000); - } - SDL_Log("Child thread error string: %s\n", SDL_GetError()); - return (0); -} - -int -main(int argc, char *argv[]) -{ - SDL_Thread *thread; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(0) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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, NULL, "#1"); - if (thread == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); - quit(1); - } - SDL_Delay(5 * 1000); - SDL_Log("Waiting for thread #1\n"); - alive = 0; - SDL_WaitThread(thread, NULL); - - SDL_Log("Main thread error string: %s\n", SDL_GetError()); - - SDL_Quit(); - return (0); -} diff --git a/3rdparty/SDL2/test/testfile.c b/3rdparty/SDL2/test/testfile.c deleted file mode 100644 index b45795f6304..00000000000 --- a/3rdparty/SDL2/test/testfile.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* sanity tests on SDL_rwops.c (usefull for alternative implementations of stdio rwops) */ - -/* quiet windows compiler warnings */ -#define _CRT_NONSTDC_NO_WARNINGS - -#include <stdlib.h> - -#ifndef _MSC_VER -#include <unistd.h> -#endif - -#include "SDL.h" - - -#include <stdio.h> - -/* WARNING ! those 2 files will be destroyed by this test program */ - -#ifdef __IPHONEOS__ -#define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */ -#define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */ -#else -#define FBASENAME1 "sdldata1" /* this file will be created during tests */ -#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */ -#endif - -#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) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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]; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - 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); - SDL_Log("test1 OK\n"); - -/* test 2 : check that inexistent file is not successfully opened/created when required */ -/* modes : r, r+ imply 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); - SDL_Log("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); - SDL_Log("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); - SDL_Log("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); - SDL_Log("test5 OK\n"); - cleanup(); - return 0; /* all ok */ -} diff --git a/3rdparty/SDL2/test/testfilesystem.c b/3rdparty/SDL2/test/testfilesystem.c deleted file mode 100644 index 61a6d5a5a97..00000000000 --- a/3rdparty/SDL2/test/testfilesystem.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple test of filesystem functions. */ - -#include <stdio.h> -#include "SDL.h" - -int -main(int argc, char *argv[]) -{ - char *base_path; - char *pref_path; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_Init(0) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); - return 1; - } - - base_path = SDL_GetBasePath(); - if(base_path == NULL){ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n", - SDL_GetError()); - return 1; - } - SDL_Log("base path: '%s'\n", base_path); - SDL_free(base_path); - - pref_path = SDL_GetPrefPath("libsdl", "testfilesystem"); - if(pref_path == NULL){ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n", - SDL_GetError()); - return 1; - } - SDL_Log("pref path: '%s'\n", pref_path); - SDL_free(pref_path); - - SDL_Quit(); - return 0; -} diff --git a/3rdparty/SDL2/test/testgamecontroller.c b/3rdparty/SDL2/test/testgamecontroller.c deleted file mode 100644 index 38d2f770848..00000000000 --- a/3rdparty/SDL2/test/testgamecontroller.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple program to test the SDL game controller routines */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "SDL.h" - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#ifndef SDL_JOYSTICK_DISABLED - -#ifdef __IPHONEOS__ -#define SCREEN_WIDTH 480 -#define SCREEN_HEIGHT 320 -#else -#define SCREEN_WIDTH 512 -#define SCREEN_HEIGHT 320 -#endif - -/* This is indexed by SDL_GameControllerButton. */ -static const struct { int x; int y; } button_positions[] = { - {387, 167}, /* A */ - {431, 132}, /* B */ - {342, 132}, /* X */ - {389, 101}, /* Y */ - {174, 132}, /* BACK */ - {233, 132}, /* GUIDE */ - {289, 132}, /* START */ - {75, 154}, /* LEFTSTICK */ - {305, 230}, /* RIGHTSTICK */ - {77, 40}, /* LEFTSHOULDER */ - {396, 36}, /* RIGHTSHOULDER */ - {154, 188}, /* DPAD_UP */ - {154, 249}, /* DPAD_DOWN */ - {116, 217}, /* DPAD_LEFT */ - {186, 217}, /* DPAD_RIGHT */ -}; - -/* This is indexed by SDL_GameControllerAxis. */ -static const struct { int x; int y; double angle; } axis_positions[] = { - {75, 154, 0.0}, /* LEFTX */ - {75, 154, 90.0}, /* LEFTY */ - {305, 230, 0.0}, /* RIGHTX */ - {305, 230, 90.0}, /* RIGHTY */ - {91, 0, 90.0}, /* TRIGGERLEFT */ - {375, 0, 90.0}, /* TRIGGERRIGHT */ -}; - -SDL_Renderer *screen = NULL; -SDL_bool retval = SDL_FALSE; -SDL_bool done = SDL_FALSE; -SDL_Texture *background, *button, *axis; - -static SDL_Texture * -LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent) -{ - SDL_Surface *temp = NULL; - SDL_Texture *texture = NULL; - - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); - } else { - /* Set transparent pixel as the pixel at (0,0) */ - if (transparent) { - if (temp->format->BytesPerPixel == 1) { - SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *)temp->pixels); - } else { - SDL_assert(!temp->format->palette); - SDL_assert(temp->format->BitsPerPixel == 24); - SDL_SetColorKey(temp, SDL_TRUE, (*(Uint32 *)temp->pixels) & 0x00FFFFFF); - } - } - - texture = SDL_CreateTextureFromSurface(renderer, temp); - if (!texture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - } - } - if (temp) { - SDL_FreeSurface(temp); - } - return texture; -} - -void -loop(void *arg) -{ - SDL_Event event; - int i; - SDL_GameController *gamecontroller = (SDL_GameController *)arg; - - /* blank screen, set up for drawing this frame. */ - SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE); - SDL_RenderClear(screen); - SDL_RenderCopy(screen, background, NULL, NULL); - - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_KEYDOWN: - if (event.key.keysym.sym != SDLK_ESCAPE) { - break; - } - /* Fall through to signal quit */ - case SDL_QUIT: - done = SDL_TRUE; - break; - default: - break; - } - } - - /* Update visual controller state */ - for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; ++i) { - if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) { - const SDL_Rect dst = { button_positions[i].x, button_positions[i].y, 50, 50 }; - SDL_RenderCopyEx(screen, button, NULL, &dst, 0, NULL, SDL_FLIP_NONE); - } - } - - for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) { - const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */ - const Sint16 value = SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i)); - if (value < -deadzone) { - const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; - const double angle = axis_positions[i].angle; - SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE); - } else if (value > deadzone) { - const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; - const double angle = axis_positions[i].angle + 180.0; - SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE); - } - } - - SDL_RenderPresent(screen); - - if (!SDL_GameControllerGetAttached(gamecontroller)) { - done = SDL_TRUE; - retval = SDL_TRUE; /* keep going, wait for reattach. */ - } - -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -SDL_bool -WatchGameController(SDL_GameController * gamecontroller) -{ - const char *name = SDL_GameControllerName(gamecontroller); - const char *basetitle = "Game Controller Test: "; - const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1; - char *title = (char *)SDL_malloc(titlelen); - SDL_Window *window = NULL; - - retval = SDL_FALSE; - done = SDL_FALSE; - - if (title) { - SDL_snprintf(title, titlelen, "%s%s", basetitle, name); - } - - /* Create a window to display controller state */ - window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); - SDL_free(title); - title = NULL; - if (window == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); - return SDL_FALSE; - } - - screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); - SDL_DestroyWindow(window); - return SDL_FALSE; - } - - SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE); - SDL_RenderClear(screen); - SDL_RenderPresent(screen); - SDL_RaiseWindow(window); - - /* scale for platforms that don't give you the window size you asked for. */ - SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT); - - background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); - button = LoadTexture(screen, "button.bmp", SDL_TRUE); - axis = LoadTexture(screen, "axis.bmp", SDL_TRUE); - - if (!background || !button || !axis) { - SDL_DestroyRenderer(screen); - SDL_DestroyWindow(window); - return SDL_FALSE; - } - SDL_SetTextureColorMod(button, 10, 255, 21); - SDL_SetTextureColorMod(axis, 10, 255, 21); - - /* !!! FIXME: */ - /*SDL_RenderSetLogicalSize(screen, background->w, background->h);*/ - - /* Print info about the controller we are watching */ - SDL_Log("Watching controller %s\n", name ? name : "Unknown Controller"); - - /* Loop, getting controller events! */ -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop_arg(loop, gamecontroller, 0, 1); -#else - while (!done) { - loop(gamecontroller); - } -#endif - - SDL_DestroyRenderer(screen); - screen = NULL; - background = NULL; - button = NULL; - axis = NULL; - SDL_DestroyWindow(window); - return retval; -} - -int -main(int argc, char *argv[]) -{ - int i; - int nController = 0; - int retcode = 0; - char guid[64]; - SDL_GameController *gamecontroller; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize SDL (Note: video is required to start event loop) */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return 1; - } - - SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt"); - - /* Print information about the controller */ - for (i = 0; i < SDL_NumJoysticks(); ++i) { - const char *name; - const char *description; - - SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i), - guid, sizeof (guid)); - - if ( SDL_IsGameController(i) ) - { - nController++; - name = SDL_GameControllerNameForIndex(i); - description = "Controller"; - } else { - name = SDL_JoystickNameForIndex(i); - description = "Joystick"; - } - SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid); - } - SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks()); - - if (argv[1]) { - SDL_bool reportederror = SDL_FALSE; - SDL_bool keepGoing = SDL_TRUE; - SDL_Event event; - int device = atoi(argv[1]); - if (device >= SDL_NumJoysticks()) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%i is an invalid joystick index.\n", device); - retcode = 1; - } else { - SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device), - guid, sizeof (guid)); - SDL_Log("Attempting to open device %i, guid %s\n", device, guid); - gamecontroller = SDL_GameControllerOpen(device); - - if (gamecontroller != NULL) { - SDL_assert(SDL_GameControllerFromInstanceID(SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller))) == gamecontroller); - } - - while (keepGoing) { - if (gamecontroller == NULL) { - if (!reportederror) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open gamecontroller %d: %s\n", device, SDL_GetError()); - retcode = 1; - keepGoing = SDL_FALSE; - reportederror = SDL_TRUE; - } - } else { - reportederror = SDL_FALSE; - keepGoing = WatchGameController(gamecontroller); - SDL_GameControllerClose(gamecontroller); - } - - gamecontroller = NULL; - if (keepGoing) { - SDL_Log("Waiting for attach\n"); - } - while (keepGoing) { - SDL_WaitEvent(&event); - if ((event.type == SDL_QUIT) || (event.type == SDL_FINGERDOWN) - || (event.type == SDL_MOUSEBUTTONDOWN)) { - keepGoing = SDL_FALSE; - } else if (event.type == SDL_CONTROLLERDEVICEADDED) { - gamecontroller = SDL_GameControllerOpen(event.cdevice.which); - if (gamecontroller != NULL) { - SDL_assert(SDL_GameControllerFromInstanceID(SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller))) == gamecontroller); - } - break; - } - } - } - } - } - - SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); - - return retcode; -} - -#else - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n"); - exit(1); -} - -#endif diff --git a/3rdparty/SDL2/test/testgesture.c b/3rdparty/SDL2/test/testgesture.c deleted file mode 100644 index a289ce133a8..00000000000 --- a/3rdparty/SDL2/test/testgesture.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Usage: - * Spacebar to begin recording a gesture on all touches. - * s to save all touches into "./gestureSave" - * l to load all touches from "./gestureSave" - */ - -#include "SDL.h" -#include <stdlib.h> /* for exit() */ - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#define WIDTH 640 -#define HEIGHT 480 -#define BPP 4 -#define DEPTH 32 - -/* MUST BE A POWER OF 2! */ -#define EVENT_BUF_SIZE 256 - - -#define VERBOSE 0 - -static SDL_Event events[EVENT_BUF_SIZE]; -static int eventWrite; - - -static int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF}; - -SDL_Surface *screen; -SDL_Window *window; -SDL_bool quitting = SDL_FALSE; - -typedef struct { - float x,y; -} Point; - -typedef struct { - float ang,r; - Point p; -} Knob; - -static Knob knob; - -void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) -{ - Uint32 *pixmem32; - Uint32 colour; - Uint8 r,g,b; - int x = (int)_x; - int y = (int)_y; - float a; - - if(x < 0 || x >= screen->w) return; - if(y < 0 || y >= screen->h) return; - - pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x; - - SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel); - - SDL_GetRGB(colour,screen->format,&r,&g,&b); - /* r = 0;g = 0; b = 0; */ - a = (float)((col>>24)&0xFF); - if(a == 0) a = 0xFF; /* Hack, to make things easier. */ - a /= 0xFF; - r = (Uint8)(r*(1-a) + ((col>>16)&0xFF)*(a)); - g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a)); - b = (Uint8)(b*(1-a) + ((col>> 0)&0xFF)*(a)); - colour = SDL_MapRGB( screen->format,r, g, b); - - - *pixmem32 = colour; -} - -void drawLine(SDL_Surface *screen,float x0,float y0,float x1,float y1,unsigned int col) { - float t; - for(t=0;t<1;t+=(float)(1.f/SDL_max(SDL_fabs(x0-x1),SDL_fabs(y0-y1)))) - setpix(screen,x1+t*(x0-x1),y1+t*(y0-y1),col); -} - -void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) -{ - float tx,ty; - float xr; - for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) { - xr = (float)SDL_sqrt(r*r - ty*ty); - if(r > 0) { /* r > 0 ==> filled circle */ - for(tx=-xr+.5f;tx<=xr-.5;tx++) { - setpix(screen,x+tx,y+ty,c); - } - } - else { - setpix(screen,x-xr+.5f,y+ty,c); - setpix(screen,x+xr-.5f,y+ty,c); - } - } -} - -void drawKnob(SDL_Surface* screen,Knob k) { - drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF); - drawCircle(screen,(k.p.x+k.r/2*SDL_cosf(k.ang))*screen->w, - (k.p.y+k.r/2*SDL_sinf(k.ang))*screen->h,k.r/4*screen->w,0); -} - -void DrawScreen(SDL_Surface* screen, SDL_Window* window) -{ - int i; -#if 1 - SDL_FillRect(screen, NULL, 0); -#else - int x, y; - for(y = 0;y < screen->h;y++) - for(x = 0;x < screen->w;x++) - setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); -#endif - - /* draw Touch History */ - for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) { - const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)]; - float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; - float x, y; - unsigned int c, col; - - if(event->type == SDL_FINGERMOTION || - event->type == SDL_FINGERDOWN || - event->type == SDL_FINGERUP) { - x = event->tfinger.x; - y = event->tfinger.y; - - /* draw the touch: */ - c = colors[event->tfinger.fingerId%7]; - col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24; - - if(event->type == SDL_FINGERMOTION) - drawCircle(screen,x*screen->w,y*screen->h,5,col); - else if(event->type == SDL_FINGERDOWN) - drawCircle(screen,x*screen->w,y*screen->h,-10,col); - } - } - - if(knob.p.x > 0) - drawKnob(screen,knob); - - SDL_UpdateWindowSurface(window); -} - -/* Returns a new SDL_Window if window is NULL or window if not. */ -SDL_Window* initWindow(SDL_Window *window, int width,int height) -{ - if (!window) { - window = SDL_CreateWindow("Gesture Test", - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - width, height, SDL_WINDOW_RESIZABLE); - } - return window; -} - -void loop() -{ - SDL_Event event; - SDL_RWops *stream; - - while(SDL_PollEvent(&event)) - { - /* Record _all_ events */ - events[eventWrite & (EVENT_BUF_SIZE-1)] = event; - eventWrite++; - - switch (event.type) - { - case SDL_QUIT: - quitting = SDL_TRUE; - break; - case SDL_KEYDOWN: - switch (event.key.keysym.sym) - { - case SDLK_i: - { - int i; - for (i = 0; i < SDL_GetNumTouchDevices(); ++i) { - SDL_TouchID id = SDL_GetTouchDevice(i); - SDL_Log("Fingers Down on device %"SDL_PRIs64": %d", id, SDL_GetNumTouchFingers(id)); - } - break; - } - case SDLK_SPACE: - SDL_RecordGesture(-1); - break; - case SDLK_s: - stream = SDL_RWFromFile("gestureSave", "w"); - SDL_Log("Wrote %i templates", SDL_SaveAllDollarTemplates(stream)); - SDL_RWclose(stream); - break; - case SDLK_l: - stream = SDL_RWFromFile("gestureSave", "r"); - SDL_Log("Loaded: %i", SDL_LoadDollarTemplates(-1, stream)); - SDL_RWclose(stream); - break; - case SDLK_ESCAPE: - quitting = SDL_TRUE; - break; - } - break; - case SDL_WINDOWEVENT: - if (event.window.event == SDL_WINDOWEVENT_RESIZED) { - if (!(window = initWindow(window, event.window.data1, event.window.data2)) || - !(screen = SDL_GetWindowSurface(window))) - { - SDL_Quit(); - exit(1); - } - } - break; - case SDL_FINGERMOTION: -#if VERBOSE - SDL_Log("Finger: %"SDL_PRIs64",x: %f, y: %f",event.tfinger.fingerId, - event.tfinger.x,event.tfinger.y); -#endif - break; - case SDL_FINGERDOWN: -#if VERBOSE - SDL_Log("Finger: %"SDL_PRIs64" down - x: %f, y: %f", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); -#endif - break; - case SDL_FINGERUP: -#if VERBOSE - SDL_Log("Finger: %"SDL_PRIs64" up - x: %f, y: %f", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); -#endif - break; - case SDL_MULTIGESTURE: -#if VERBOSE - SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f", - event.mgesture.x, - event.mgesture.y, - event.mgesture.dTheta, - event.mgesture.dDist); - SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers); -#endif - knob.p.x = event.mgesture.x; - knob.p.y = event.mgesture.y; - knob.ang += event.mgesture.dTheta; - knob.r += event.mgesture.dDist; - break; - case SDL_DOLLARGESTURE: - SDL_Log("Gesture %"SDL_PRIs64" performed, error: %f", - event.dgesture.gestureId, - event.dgesture.error); - break; - case SDL_DOLLARRECORD: - SDL_Log("Recorded gesture: %"SDL_PRIs64"",event.dgesture.gestureId); - break; - } - } - DrawScreen(screen, window); - -#ifdef __EMSCRIPTEN__ - if (quitting) { - emscripten_cancel_main_loop(); - } -#endif -} - -int main(int argc, char* argv[]) -{ - window = NULL; - screen = NULL; - quitting = SDL_FALSE; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* gesture variables */ - knob.r = .1f; - knob.ang = 0; - - if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1; - - if (!(window = initWindow(window, WIDTH, HEIGHT)) || - !(screen = SDL_GetWindowSurface(window))) - { - SDL_Quit(); - return 1; - } - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while(!quitting) { - loop(); - } -#endif - - SDL_Quit(); - return 0; -} - diff --git a/3rdparty/SDL2/test/testgl2.c b/3rdparty/SDL2/test/testgl2.c deleted file mode 100644 index 74147f9fb99..00000000000 --- a/3rdparty/SDL2/test/testgl2.c +++ /dev/null @@ -1,416 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#include "SDL_test_common.h" - -#ifdef __MACOS__ -#define HAVE_OPENGL -#endif - -#ifdef HAVE_OPENGL - -#include "SDL_opengl.h" - -typedef struct GL_Context -{ -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; -#include "../src/render/opengl/SDL_glfuncs.h" -#undef SDL_PROC -} GL_Context; - - -/* Undefine this if you want a flat cube instead of a rainbow cube */ -#define SHADED_CUBE - -static SDLTest_CommonState *state; -static SDL_GLContext context; -static GL_Context ctx; - -static int LoadContext(GL_Context * data) -{ -#if SDL_VIDEO_DRIVER_UIKIT -#define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_ANDROID -#define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_PANDORA -#define __SDL_NOGETPROCADDR__ -#endif - -#if defined __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; -#else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ - return SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \ - } \ - } while ( 0 ); -#endif /* __SDL_NOGETPROCADDR__ */ - -#include "../src/render/opengl/SDL_glfuncs.h" -#undef SDL_PROC - return 0; -} - - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - if (context) { - /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */ - SDL_GL_DeleteContext(context); - } - SDLTest_CommonQuit(state); - exit(rc); -} - -static void -Render() -{ - static 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} - }; - static 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} - }; - - /* Do our drawing, too. */ - ctx.glClearColor(0.0, 0.0, 0.0, 1.0); - ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - ctx.glBegin(GL_QUADS); - -#ifdef SHADED_CUBE - ctx.glColor3fv(color[0]); - ctx.glVertex3fv(cube[0]); - ctx.glColor3fv(color[1]); - ctx.glVertex3fv(cube[1]); - ctx.glColor3fv(color[2]); - ctx.glVertex3fv(cube[2]); - ctx.glColor3fv(color[3]); - ctx.glVertex3fv(cube[3]); - - ctx.glColor3fv(color[3]); - ctx.glVertex3fv(cube[3]); - ctx.glColor3fv(color[4]); - ctx.glVertex3fv(cube[4]); - ctx.glColor3fv(color[7]); - ctx.glVertex3fv(cube[7]); - ctx.glColor3fv(color[2]); - ctx.glVertex3fv(cube[2]); - - ctx.glColor3fv(color[0]); - ctx.glVertex3fv(cube[0]); - ctx.glColor3fv(color[5]); - ctx.glVertex3fv(cube[5]); - ctx.glColor3fv(color[6]); - ctx.glVertex3fv(cube[6]); - ctx.glColor3fv(color[1]); - ctx.glVertex3fv(cube[1]); - - ctx.glColor3fv(color[5]); - ctx.glVertex3fv(cube[5]); - ctx.glColor3fv(color[4]); - ctx.glVertex3fv(cube[4]); - ctx.glColor3fv(color[7]); - ctx.glVertex3fv(cube[7]); - ctx.glColor3fv(color[6]); - ctx.glVertex3fv(cube[6]); - - ctx.glColor3fv(color[5]); - ctx.glVertex3fv(cube[5]); - ctx.glColor3fv(color[0]); - ctx.glVertex3fv(cube[0]); - ctx.glColor3fv(color[3]); - ctx.glVertex3fv(cube[3]); - ctx.glColor3fv(color[4]); - ctx.glVertex3fv(cube[4]); - - ctx.glColor3fv(color[6]); - ctx.glVertex3fv(cube[6]); - ctx.glColor3fv(color[1]); - ctx.glVertex3fv(cube[1]); - ctx.glColor3fv(color[2]); - ctx.glVertex3fv(cube[2]); - ctx.glColor3fv(color[7]); - ctx.glVertex3fv(cube[7]); -#else /* flat cube */ - ctx.glColor3f(1.0, 0.0, 0.0); - ctx.glVertex3fv(cube[0]); - ctx.glVertex3fv(cube[1]); - ctx.glVertex3fv(cube[2]); - ctx.glVertex3fv(cube[3]); - - ctx.glColor3f(0.0, 1.0, 0.0); - ctx.glVertex3fv(cube[3]); - ctx.glVertex3fv(cube[4]); - ctx.glVertex3fv(cube[7]); - ctx.glVertex3fv(cube[2]); - - ctx.glColor3f(0.0, 0.0, 1.0); - ctx.glVertex3fv(cube[0]); - ctx.glVertex3fv(cube[5]); - ctx.glVertex3fv(cube[6]); - ctx.glVertex3fv(cube[1]); - - ctx.glColor3f(0.0, 1.0, 1.0); - ctx.glVertex3fv(cube[5]); - ctx.glVertex3fv(cube[4]); - ctx.glVertex3fv(cube[7]); - ctx.glVertex3fv(cube[6]); - - ctx.glColor3f(1.0, 1.0, 0.0); - ctx.glVertex3fv(cube[5]); - ctx.glVertex3fv(cube[0]); - ctx.glVertex3fv(cube[3]); - ctx.glVertex3fv(cube[4]); - - ctx.glColor3f(1.0, 0.0, 1.0); - ctx.glVertex3fv(cube[6]); - ctx.glVertex3fv(cube[1]); - ctx.glVertex3fv(cube[2]); - ctx.glVertex3fv(cube[7]); -#endif /* SHADED_CUBE */ - - ctx.glEnd(); - - ctx.glMatrixMode(GL_MODELVIEW); - ctx.glRotatef(5.0, 1.0, 1.0, 1.0); -} - -int -main(int argc, char *argv[]) -{ - int fsaa, accel; - int value; - int i, done; - SDL_DisplayMode mode; - SDL_Event event; - Uint32 then, now, frames; - int status; - int dw, dh; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize parameters */ - fsaa = 0; - accel = -1; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i+1 < argc) { - fsaa = atoi(argv[i+1]); - consumed = 2; - } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) { - accel = atoi(argv[i+1]); - consumed = 2; - } else { - consumed = -1; - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0], - SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - - /* Set OpenGL parameters */ - state->window_flags |= SDL_WINDOW_OPENGL; - state->gl_red_size = 5; - state->gl_green_size = 5; - state->gl_blue_size = 5; - state->gl_depth_size = 16; - state->gl_double_buffer = 1; - if (fsaa) { - state->gl_multisamplebuffers = 1; - state->gl_multisamplesamples = fsaa; - } - if (accel >= 0) { - state->gl_accelerated = accel; - } - - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - /* Create OpenGL context */ - context = SDL_GL_CreateContext(state->windows[0]); - if (!context) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); - quit(2); - } - - /* Important: call this *after* creating the context */ - if (LoadContext(&ctx) < 0) { - SDL_Log("Could not load GL functions\n"); - quit(2); - return 0; - } - - if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { - /* try late-swap-tearing first. If not supported, try normal vsync. */ - if (SDL_GL_SetSwapInterval(-1) == -1) { - SDL_GL_SetSwapInterval(1); - } - } else { - SDL_GL_SetSwapInterval(0); /* disable vsync. */ - } - - SDL_GetCurrentDisplayMode(0, &mode); - SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format)); - SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); - SDL_GetWindowSize(state->windows[0], &dw, &dh); - SDL_Log("Window Size : %d,%d\n", dw, dh); - SDL_GL_GetDrawableSize(state->windows[0], &dw, &dh); - SDL_Log("Draw Size : %d,%d\n", dw, dh); - SDL_Log("\n"); - SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR)); - SDL_Log("Renderer : %s\n", ctx.glGetString(GL_RENDERER)); - SDL_Log("Version : %s\n", ctx.glGetString(GL_VERSION)); - SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS)); - SDL_Log("\n"); - - status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); - } - if (fsaa) { - status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); - if (!status) { - SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); - if (!status) { - SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", - SDL_GetError()); - } - } - if (accel >= 0) { - status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); - if (!status) { - SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, - value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", - SDL_GetError()); - } - } - - /* Set rendering settings */ - ctx.glMatrixMode(GL_PROJECTION); - ctx.glLoadIdentity(); - ctx.glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); - ctx.glMatrixMode(GL_MODELVIEW); - ctx.glLoadIdentity(); - ctx.glEnable(GL_DEPTH_TEST); - ctx.glDepthFunc(GL_LESS); - ctx.glShadeModel(GL_SMOOTH); - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - while (!done) { - /* Check for events */ - ++frames; - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - for (i = 0; i < state->num_windows; ++i) { - int w, h; - if (state->windows[i] == NULL) - continue; - SDL_GL_MakeCurrent(state->windows[i], context); - SDL_GL_GetDrawableSize(state->windows[i], &w, &h); - ctx.glViewport(0, 0, w, h); - Render(); - SDL_GL_SwapWindow(state->windows[i]); - } - } - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - SDL_Log("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); - } - quit(0); - return 0; -} - -#else /* HAVE_OPENGL */ - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); - return 1; -} - -#endif /* HAVE_OPENGL */ diff --git a/3rdparty/SDL2/test/testgles.c b/3rdparty/SDL2/test/testgles.c deleted file mode 100644 index 5be48ac56de..00000000000 --- a/3rdparty/SDL2/test/testgles.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#include "SDL_test_common.h" - -#if defined(__IPHONEOS__) || defined(__ANDROID__) -#define HAVE_OPENGLES -#endif - -#ifdef HAVE_OPENGLES - -#include "SDL_opengles.h" - -static SDLTest_CommonState *state; -static SDL_GLContext *context = NULL; -static int depth = 16; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - int i; - - if (context != NULL) { - for (i = 0; i < state->num_windows; i++) { - if (context[i]) { - SDL_GL_DeleteContext(context[i]); - } - } - - SDL_free(context); - } - - SDLTest_CommonQuit(state); - exit(rc); -} - -static void -Render() -{ - static GLubyte color[8][4] = { {255, 0, 0, 0}, - {255, 0, 0, 255}, - {0, 255, 0, 255}, - {0, 255, 0, 255}, - {0, 255, 0, 255}, - {255, 255, 255, 255}, - {255, 0, 255, 255}, - {0, 0, 255, 255} - }; - static GLfloat cube[8][3] = { {0.5, 0.5, -0.5}, - {0.5f, -0.5f, -0.5f}, - {-0.5f, -0.5f, -0.5f}, - {-0.5f, 0.5f, -0.5f}, - {-0.5f, 0.5f, 0.5f}, - {0.5f, 0.5f, 0.5f}, - {0.5f, -0.5f, 0.5f}, - {-0.5f, -0.5f, 0.5f} - }; - static GLubyte indices[36] = { 0, 3, 4, - 4, 5, 0, - 0, 5, 6, - 6, 1, 0, - 6, 7, 2, - 2, 1, 6, - 7, 4, 3, - 3, 2, 7, - 5, 4, 7, - 7, 6, 5, - 2, 3, 1, - 3, 0, 1 - }; - - - /* Do our drawing, too. */ - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - /* Draw the cube */ - glColorPointer(4, GL_UNSIGNED_BYTE, 0, color); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, cube); - glEnableClientState(GL_VERTEX_ARRAY); - glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices); - - glMatrixMode(GL_MODELVIEW); - glRotatef(5.0, 1.0, 1.0, 1.0); -} - -int -main(int argc, char *argv[]) -{ - int fsaa, accel; - int value; - int i, done; - SDL_DisplayMode mode; - SDL_Event event; - Uint32 then, now, frames; - int status; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize parameters */ - fsaa = 0; - accel = 0; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { - ++fsaa; - consumed = 1; - } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { - ++accel; - consumed = 1; - } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) { - i++; - if (!argv[i]) { - consumed = -1; - } else { - depth = SDL_atoi(argv[i]); - consumed = 1; - } - } else { - consumed = -1; - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], - SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - - /* Set OpenGL parameters */ - state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; - state->gl_red_size = 5; - state->gl_green_size = 5; - state->gl_blue_size = 5; - state->gl_depth_size = depth; - state->gl_major_version = 1; - state->gl_minor_version = 1; - state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; - if (fsaa) { - state->gl_multisamplebuffers=1; - state->gl_multisamplesamples=fsaa; - } - if (accel) { - state->gl_accelerated=1; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context)); - if (context == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); - quit(2); - } - - /* Create OpenGL ES contexts */ - for (i = 0; i < state->num_windows; i++) { - context[i] = SDL_GL_CreateContext(state->windows[i]); - if (!context[i]) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); - quit(2); - } - } - - if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { - SDL_GL_SetSwapInterval(1); - } else { - SDL_GL_SetSwapInterval(0); - } - - SDL_GetCurrentDisplayMode(0, &mode); - SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); - SDL_Log("\n"); - SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR)); - SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER)); - SDL_Log("Version : %s\n", glGetString(GL_VERSION)); - SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS)); - SDL_Log("\n"); - - status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", - SDL_GetError()); - } - if (fsaa) { - status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); - if (!status) { - SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); - if (!status) { - SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", - SDL_GetError()); - } - } - if (accel) { - status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); - if (!status) { - SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", - SDL_GetError()); - } - } - - /* Set rendering settings for each context */ - for (i = 0; i < state->num_windows; ++i) { - float aspectAdjust; - - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - - /* Continue for next window */ - continue; - } - - aspectAdjust = (4.0f / 3.0f) / ((float)state->window_w / state->window_h); - glViewport(0, 0, state->window_w, state->window_h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrthof(-2.0, 2.0, -2.0 * aspectAdjust, 2.0 * aspectAdjust, -20.0, 20.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - glShadeModel(GL_SMOOTH); - } - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - while (!done) { - /* Check for events */ - ++frames; - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_WINDOWEVENT: - switch (event.window.event) { - case SDL_WINDOWEVENT_RESIZED: - for (i = 0; i < state->num_windows; ++i) { - if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - break; - } - /* Change view port to the new window dimensions */ - glViewport(0, 0, event.window.data1, event.window.data2); - /* Update window content */ - Render(); - SDL_GL_SwapWindow(state->windows[i]); - break; - } - } - break; - } - } - SDLTest_CommonEvent(state, &event, &done); - } - for (i = 0; i < state->num_windows; ++i) { - if (state->windows[i] == NULL) - continue; - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - - /* Continue for next window */ - continue; - } - Render(); - SDL_GL_SwapWindow(state->windows[i]); - } - } - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - SDL_Log("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); - } -#if !defined(__ANDROID__) - quit(0); -#endif - return 0; -} - -#else /* HAVE_OPENGLES */ - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n"); - return 1; -} - -#endif /* HAVE_OPENGLES */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testgles2.c b/3rdparty/SDL2/test/testgles2.c deleted file mode 100644 index 45b3d79a3dd..00000000000 --- a/3rdparty/SDL2/test/testgles2.c +++ /dev/null @@ -1,731 +0,0 @@ -/* - Copyright (r) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - -#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) -#define HAVE_OPENGLES2 -#endif - -#ifdef HAVE_OPENGLES2 - -#include "SDL_opengles2.h" - -typedef struct GLES2_Context -{ -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; -#include "../src/render/opengles2/SDL_gles2funcs.h" -#undef SDL_PROC -} GLES2_Context; - - -static SDLTest_CommonState *state; -static SDL_GLContext *context = NULL; -static int depth = 16; -static GLES2_Context ctx; - -static int LoadContext(GLES2_Context * data) -{ -#if SDL_VIDEO_DRIVER_UIKIT -#define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_ANDROID -#define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_PANDORA -#define __SDL_NOGETPROCADDR__ -#endif - -#if defined __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; -#else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ - return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \ - } \ - } while ( 0 ); -#endif /* __SDL_NOGETPROCADDR__ */ - -#include "../src/render/opengles2/SDL_gles2funcs.h" -#undef SDL_PROC - return 0; -} - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - int i; - - if (context != NULL) { - for (i = 0; i < state->num_windows; i++) { - if (context[i]) { - SDL_GL_DeleteContext(context[i]); - } - } - - SDL_free(context); - } - - SDLTest_CommonQuit(state); - exit(rc); -} - -#define GL_CHECK(x) \ - x; \ - { \ - GLenum glError = ctx.glGetError(); \ - if(glError != GL_NO_ERROR) { \ - SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \ - quit(1); \ - } \ - } - -/* - * Simulates desktop's glRotatef. The matrix is returned in column-major - * order. - */ -static void -rotate_matrix(float angle, float x, float y, float z, float *r) -{ - float radians, c, s, c1, u[3], length; - int i, j; - - radians = (float)(angle * M_PI) / 180.0f; - - c = SDL_cosf(radians); - s = SDL_sinf(radians); - - c1 = 1.0f - SDL_cosf(radians); - - length = (float)SDL_sqrt(x * x + y * y + z * z); - - u[0] = x / length; - u[1] = y / length; - u[2] = z / length; - - for (i = 0; i < 16; i++) { - r[i] = 0.0; - } - - r[15] = 1.0; - - for (i = 0; i < 3; i++) { - r[i * 4 + (i + 1) % 3] = u[(i + 2) % 3] * s; - r[i * 4 + (i + 2) % 3] = -u[(i + 1) % 3] * s; - } - - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - r[i * 4 + j] += c1 * u[i] * u[j] + (i == j ? c : 0.0f); - } - } -} - -/* - * Simulates gluPerspectiveMatrix - */ -static void -perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r) -{ - int i; - float f; - - f = 1.0f/SDL_tanf(fovy * 0.5f); - - for (i = 0; i < 16; i++) { - r[i] = 0.0; - } - - r[0] = f / aspect; - r[5] = f; - r[10] = (znear + zfar) / (znear - zfar); - r[11] = -1.0f; - r[14] = (2.0f * znear * zfar) / (znear - zfar); - r[15] = 0.0f; -} - -/* - * Multiplies lhs by rhs and writes out to r. All matrices are 4x4 and column - * major. In-place multiplication is supported. - */ -static void -multiply_matrix(float *lhs, float *rhs, float *r) -{ - int i, j, k; - float tmp[16]; - - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - tmp[j * 4 + i] = 0.0; - - for (k = 0; k < 4; k++) { - tmp[j * 4 + i] += lhs[k * 4 + i] * rhs[j * 4 + k]; - } - } - } - - for (i = 0; i < 16; i++) { - r[i] = tmp[i]; - } -} - -/* - * Create shader, load in source, compile, dump debug as necessary. - * - * shader: Pointer to return created shader ID. - * source: Passed-in shader source code. - * shader_type: Passed to GL, e.g. GL_VERTEX_SHADER. - */ -void -process_shader(GLuint *shader, const char * source, GLint shader_type) -{ - GLint status = GL_FALSE; - const char *shaders[1] = { NULL }; - char buffer[1024]; - GLsizei length; - - /* Create shader and load into GL. */ - *shader = GL_CHECK(ctx.glCreateShader(shader_type)); - - shaders[0] = source; - - GL_CHECK(ctx.glShaderSource(*shader, 1, shaders, NULL)); - - /* Clean up shader source. */ - shaders[0] = NULL; - - /* Try compiling the shader. */ - GL_CHECK(ctx.glCompileShader(*shader)); - GL_CHECK(ctx.glGetShaderiv(*shader, GL_COMPILE_STATUS, &status)); - - /* Dump debug info (source and log) if compilation failed. */ - if(status != GL_TRUE) { - ctx.glGetProgramInfoLog(*shader, sizeof(buffer), &length, &buffer[0]); - buffer[length] = '\0'; - SDL_Log("Shader compilation failed: %s", buffer);fflush(stderr); - quit(-1); - } -} - -/* 3D data. Vertex range -0.5..0.5 in all axes. -* Z -0.5 is near, 0.5 is far. */ -const float _vertices[] = -{ - /* Front face. */ - /* Bottom left */ - -0.5, 0.5, -0.5, - 0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, - /* Top right */ - -0.5, 0.5, -0.5, - 0.5, 0.5, -0.5, - 0.5, -0.5, -0.5, - /* Left face */ - /* Bottom left */ - -0.5, 0.5, 0.5, - -0.5, -0.5, -0.5, - -0.5, -0.5, 0.5, - /* Top right */ - -0.5, 0.5, 0.5, - -0.5, 0.5, -0.5, - -0.5, -0.5, -0.5, - /* Top face */ - /* Bottom left */ - -0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, - /* Top right */ - -0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, - /* Right face */ - /* Bottom left */ - 0.5, 0.5, -0.5, - 0.5, -0.5, 0.5, - 0.5, -0.5, -0.5, - /* Top right */ - 0.5, 0.5, -0.5, - 0.5, 0.5, 0.5, - 0.5, -0.5, 0.5, - /* Back face */ - /* Bottom left */ - 0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, - 0.5, -0.5, 0.5, - /* Top right */ - 0.5, 0.5, 0.5, - -0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, - /* Bottom face */ - /* Bottom left */ - -0.5, -0.5, -0.5, - 0.5, -0.5, 0.5, - -0.5, -0.5, 0.5, - /* Top right */ - -0.5, -0.5, -0.5, - 0.5, -0.5, -0.5, - 0.5, -0.5, 0.5, -}; - -const float _colors[] = -{ - /* Front face */ - /* Bottom left */ - 1.0, 0.0, 0.0, /* red */ - 0.0, 0.0, 1.0, /* blue */ - 0.0, 1.0, 0.0, /* green */ - /* Top right */ - 1.0, 0.0, 0.0, /* red */ - 1.0, 1.0, 0.0, /* yellow */ - 0.0, 0.0, 1.0, /* blue */ - /* Left face */ - /* Bottom left */ - 1.0, 1.0, 1.0, /* white */ - 0.0, 1.0, 0.0, /* green */ - 0.0, 1.0, 1.0, /* cyan */ - /* Top right */ - 1.0, 1.0, 1.0, /* white */ - 1.0, 0.0, 0.0, /* red */ - 0.0, 1.0, 0.0, /* green */ - /* Top face */ - /* Bottom left */ - 1.0, 1.0, 1.0, /* white */ - 1.0, 1.0, 0.0, /* yellow */ - 1.0, 0.0, 0.0, /* red */ - /* Top right */ - 1.0, 1.0, 1.0, /* white */ - 0.0, 0.0, 0.0, /* black */ - 1.0, 1.0, 0.0, /* yellow */ - /* Right face */ - /* Bottom left */ - 1.0, 1.0, 0.0, /* yellow */ - 1.0, 0.0, 1.0, /* magenta */ - 0.0, 0.0, 1.0, /* blue */ - /* Top right */ - 1.0, 1.0, 0.0, /* yellow */ - 0.0, 0.0, 0.0, /* black */ - 1.0, 0.0, 1.0, /* magenta */ - /* Back face */ - /* Bottom left */ - 0.0, 0.0, 0.0, /* black */ - 0.0, 1.0, 1.0, /* cyan */ - 1.0, 0.0, 1.0, /* magenta */ - /* Top right */ - 0.0, 0.0, 0.0, /* black */ - 1.0, 1.0, 1.0, /* white */ - 0.0, 1.0, 1.0, /* cyan */ - /* Bottom face */ - /* Bottom left */ - 0.0, 1.0, 0.0, /* green */ - 1.0, 0.0, 1.0, /* magenta */ - 0.0, 1.0, 1.0, /* cyan */ - /* Top right */ - 0.0, 1.0, 0.0, /* green */ - 0.0, 0.0, 1.0, /* blue */ - 1.0, 0.0, 1.0, /* magenta */ -}; - -const char* _shader_vert_src = -" attribute vec4 av4position; " -" attribute vec3 av3color; " -" uniform mat4 mvp; " -" varying vec3 vv3color; " -" void main() { " -" vv3color = av3color; " -" gl_Position = mvp * av4position; " -" } "; - -const char* _shader_frag_src = -" precision lowp float; " -" varying vec3 vv3color; " -" void main() { " -" gl_FragColor = vec4(vv3color, 1.0); " -" } "; - -typedef struct shader_data -{ - GLuint shader_program, shader_frag, shader_vert; - - GLint attr_position; - GLint attr_color, attr_mvp; - - int angle_x, angle_y, angle_z; - -} shader_data; - -static void -Render(unsigned int width, unsigned int height, shader_data* data) -{ - float matrix_rotate[16], matrix_modelview[16], matrix_perspective[16], matrix_mvp[16]; - - /* - * Do some rotation with Euler angles. It is not a fixed axis as - * quaterions would be, but the effect is cool. - */ - rotate_matrix((float)data->angle_x, 1.0f, 0.0f, 0.0f, matrix_modelview); - rotate_matrix((float)data->angle_y, 0.0f, 1.0f, 0.0f, matrix_rotate); - - multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview); - - rotate_matrix((float)data->angle_z, 0.0f, 1.0f, 0.0f, matrix_rotate); - - multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview); - - /* Pull the camera back from the cube */ - matrix_modelview[14] -= 2.5; - - perspective_matrix(45.0f, (float)width/height, 0.01f, 100.0f, matrix_perspective); - multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp); - - GL_CHECK(ctx.glUniformMatrix4fv(data->attr_mvp, 1, GL_FALSE, matrix_mvp)); - - data->angle_x += 3; - data->angle_y += 2; - data->angle_z += 1; - - if(data->angle_x >= 360) data->angle_x -= 360; - if(data->angle_x < 0) data->angle_x += 360; - if(data->angle_y >= 360) data->angle_y -= 360; - if(data->angle_y < 0) data->angle_y += 360; - if(data->angle_z >= 360) data->angle_z -= 360; - if(data->angle_z < 0) data->angle_z += 360; - - GL_CHECK(ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)); - GL_CHECK(ctx.glDrawArrays(GL_TRIANGLES, 0, 36)); -} - -int done; -Uint32 frames; -shader_data *datas; - -void loop() -{ - SDL_Event event; - int i; - int status; - - /* Check for events */ - ++frames; - while (SDL_PollEvent(&event) && !done) { - switch (event.type) { - case SDL_WINDOWEVENT: - switch (event.window.event) { - case SDL_WINDOWEVENT_RESIZED: - for (i = 0; i < state->num_windows; ++i) { - if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { - int w, h; - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - break; - } - /* Change view port to the new window dimensions */ - SDL_GL_GetDrawableSize(state->windows[i], &w, &h); - ctx.glViewport(0, 0, w, h); - state->window_w = event.window.data1; - state->window_h = event.window.data2; - /* Update window content */ - Render(event.window.data1, event.window.data2, &datas[i]); - SDL_GL_SwapWindow(state->windows[i]); - break; - } - } - break; - } - } - SDLTest_CommonEvent(state, &event, &done); - } - if (!done) { - for (i = 0; i < state->num_windows; ++i) { - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - - /* Continue for next window */ - continue; - } - Render(state->window_w, state->window_h, &datas[i]); - SDL_GL_SwapWindow(state->windows[i]); - } - } -#ifdef __EMSCRIPTEN__ - else { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int fsaa, accel; - int value; - int i; - SDL_DisplayMode mode; - Uint32 then, now; - int status; - shader_data *data; - - /* Initialize parameters */ - fsaa = 0; - accel = 0; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { - ++fsaa; - consumed = 1; - } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { - ++accel; - consumed = 1; - } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) { - i++; - if (!argv[i]) { - consumed = -1; - } else { - depth = SDL_atoi(argv[i]); - consumed = 1; - } - } else { - consumed = -1; - } - } - if (consumed < 0) { - SDL_Log ("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], - SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - - /* Set OpenGL parameters */ - state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; - state->gl_red_size = 5; - state->gl_green_size = 5; - state->gl_blue_size = 5; - state->gl_depth_size = depth; - state->gl_major_version = 2; - state->gl_minor_version = 0; - state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; - - if (fsaa) { - state->gl_multisamplebuffers=1; - state->gl_multisamplesamples=fsaa; - } - if (accel) { - state->gl_accelerated=1; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - return 0; - } - - context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context)); - if (context == NULL) { - SDL_Log("Out of memory!\n"); - quit(2); - } - - /* Create OpenGL ES contexts */ - for (i = 0; i < state->num_windows; i++) { - context[i] = SDL_GL_CreateContext(state->windows[i]); - if (!context[i]) { - SDL_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError()); - quit(2); - } - } - - /* Important: call this *after* creating the context */ - if (LoadContext(&ctx) < 0) { - SDL_Log("Could not load GLES2 functions\n"); - quit(2); - return 0; - } - - - - if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { - SDL_GL_SetSwapInterval(1); - } else { - SDL_GL_SetSwapInterval(0); - } - - SDL_GetCurrentDisplayMode(0, &mode); - SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); - SDL_Log("\n"); - SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR)); - SDL_Log("Renderer : %s\n", ctx.glGetString(GL_RENDERER)); - SDL_Log("Version : %s\n", ctx.glGetString(GL_VERSION)); - SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS)); - SDL_Log("\n"); - - status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_Log( "Failed to get SDL_GL_RED_SIZE: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); - } else { - SDL_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); - if (!status) { - SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); - } else { - SDL_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n", - SDL_GetError()); - } - if (fsaa) { - status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); - if (!status) { - SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); - } else { - SDL_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", - SDL_GetError()); - } - status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); - if (!status) { - SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); - } else { - SDL_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", - SDL_GetError()); - } - } - if (accel) { - status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); - if (!status) { - SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); - } else { - SDL_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", - SDL_GetError()); - } - } - - datas = (shader_data *)SDL_calloc(state->num_windows, sizeof(shader_data)); - - /* Set rendering settings for each context */ - for (i = 0; i < state->num_windows; ++i) { - - int w, h; - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - - /* Continue for next window */ - continue; - } - SDL_GL_GetDrawableSize(state->windows[i], &w, &h); - ctx.glViewport(0, 0, w, h); - - data = &datas[i]; - data->angle_x = 0; data->angle_y = 0; data->angle_z = 0; - - /* Shader Initialization */ - process_shader(&data->shader_vert, _shader_vert_src, GL_VERTEX_SHADER); - process_shader(&data->shader_frag, _shader_frag_src, GL_FRAGMENT_SHADER); - - /* Create shader_program (ready to attach shaders) */ - data->shader_program = GL_CHECK(ctx.glCreateProgram()); - - /* Attach shaders and link shader_program */ - GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_vert)); - GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_frag)); - GL_CHECK(ctx.glLinkProgram(data->shader_program)); - - /* Get attribute locations of non-fixed attributes like color and texture coordinates. */ - data->attr_position = GL_CHECK(ctx.glGetAttribLocation(data->shader_program, "av4position")); - data->attr_color = GL_CHECK(ctx.glGetAttribLocation(data->shader_program, "av3color")); - - /* Get uniform locations */ - data->attr_mvp = GL_CHECK(ctx.glGetUniformLocation(data->shader_program, "mvp")); - - GL_CHECK(ctx.glUseProgram(data->shader_program)); - - /* Enable attributes for position, color and texture coordinates etc. */ - GL_CHECK(ctx.glEnableVertexAttribArray(data->attr_position)); - GL_CHECK(ctx.glEnableVertexAttribArray(data->attr_color)); - - /* Populate attributes for position, color and texture coordinates etc. */ - GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, _vertices)); - GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, _colors)); - - GL_CHECK(ctx.glEnable(GL_CULL_FACE)); - GL_CHECK(ctx.glEnable(GL_DEPTH_TEST)); - } - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - SDL_Log("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); - } -#if !defined(__ANDROID__) && !defined(__NACL__) - quit(0); -#endif - return 0; -} - -#else /* HAVE_OPENGLES2 */ - -int -main(int argc, char *argv[]) -{ - SDL_Log("No OpenGL ES support on this system\n"); - return 1; -} - -#endif /* HAVE_OPENGLES2 */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testhaptic.c b/3rdparty/SDL2/test/testhaptic.c deleted file mode 100644 index bffe4467de4..00000000000 --- a/3rdparty/SDL2/test/testhaptic.c +++ /dev/null @@ -1,369 +0,0 @@ -/* -Copyright (c) 2008, Edgar Simo Serra -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Simple Directmedia Layer (SDL) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * includes - */ -#include <stdlib.h> -#include <string.h> /* strstr */ -#include <ctype.h> /* isdigit */ - -#include "SDL.h" - -#ifndef SDL_HAPTIC_DISABLED - -static SDL_Haptic *haptic; - - -/* - * prototypes - */ -static void abort_execution(void); -static void HapticPrintSupported(SDL_Haptic * haptic); - - -/** - * @brief The entry point of this force feedback demo. - * @param[in] argc Number of arguments. - * @param[in] argv Array of argc arguments. - */ -int -main(int argc, char **argv) -{ - int i; - char *name; - int index; - SDL_HapticEffect efx[9]; - int id[9]; - int nefx; - unsigned int supported; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - name = NULL; - index = -1; - if (argc > 1) { - name = argv[1]; - if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { - SDL_Log("USAGE: %s [device]\n" - "If device is a two-digit number it'll use it as an index, otherwise\n" - "it'll use it as if it were part of the device's name.\n", - argv[0]); - return 0; - } - - i = strlen(name); - if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) { - index = atoi(name); - name = NULL; - } - } - - /* Initialize the force feedbackness */ - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | - SDL_INIT_HAPTIC); - SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); - if (SDL_NumHaptics() > 0) { - /* We'll just use index or the first force feedback device found */ - if (name == NULL) { - i = (index != -1) ? index : 0; - } - /* Try to find matching device */ - else { - for (i = 0; i < SDL_NumHaptics(); i++) { - if (strstr(SDL_HapticName(i), name) != NULL) - break; - } - - if (i >= SDL_NumHaptics()) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", - name); - return 1; - } - } - - haptic = SDL_HapticOpen(i); - if (haptic == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", - SDL_GetError()); - return 1; - } - SDL_Log("Device: %s\n", SDL_HapticName(i)); - HapticPrintSupported(haptic); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n"); - return 1; - } - - /* We only want force feedback errors. */ - SDL_ClearError(); - - /* Create effects. */ - memset(&efx, 0, sizeof(efx)); - nefx = 0; - supported = SDL_HapticQuery(haptic); - - SDL_Log("\nUploading effects\n"); - /* First we'll try a SINE effect. */ - if (supported & SDL_HAPTIC_SINE) { - SDL_Log(" effect %d: Sine Wave\n", nefx); - efx[nefx].type = SDL_HAPTIC_SINE; - efx[nefx].periodic.period = 1000; - efx[nefx].periodic.magnitude = -0x2000; /* Negative magnitude and ... */ - efx[nefx].periodic.phase = 18000; /* ... 180 degrees phase shift => cancel eachother */ - efx[nefx].periodic.length = 5000; - efx[nefx].periodic.attack_length = 1000; - efx[nefx].periodic.fade_length = 1000; - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - /* Now we'll try a SAWTOOTHUP */ - if (supported & SDL_HAPTIC_SAWTOOTHUP) { - SDL_Log(" effect %d: Sawtooth Up\n", nefx); - efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP; - efx[nefx].periodic.period = 500; - efx[nefx].periodic.magnitude = 0x5000; - efx[nefx].periodic.length = 5000; - efx[nefx].periodic.attack_length = 1000; - efx[nefx].periodic.fade_length = 1000; - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - - /* Now the classical constant effect. */ - if (supported & SDL_HAPTIC_CONSTANT) { - SDL_Log(" effect %d: Constant Force\n", nefx); - efx[nefx].type = SDL_HAPTIC_CONSTANT; - efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR; - efx[nefx].constant.direction.dir[0] = 20000; /* Force comes from the south-west. */ - efx[nefx].constant.length = 5000; - efx[nefx].constant.level = 0x6000; - efx[nefx].constant.attack_length = 1000; - efx[nefx].constant.fade_length = 1000; - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - - /* The cute spring effect. */ - if (supported & SDL_HAPTIC_SPRING) { - SDL_Log(" effect %d: Condition Spring\n", nefx); - efx[nefx].type = SDL_HAPTIC_SPRING; - efx[nefx].condition.length = 5000; - for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { - efx[nefx].condition.right_sat[i] = 0xFFFF; - efx[nefx].condition.left_sat[i] = 0xFFFF; - efx[nefx].condition.right_coeff[i] = 0x2000; - efx[nefx].condition.left_coeff[i] = 0x2000; - efx[nefx].condition.center[i] = 0x1000; /* Displace the center for it to move. */ - } - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - /* The interesting damper effect. */ - if (supported & SDL_HAPTIC_DAMPER) { - SDL_Log(" effect %d: Condition Damper\n", nefx); - efx[nefx].type = SDL_HAPTIC_DAMPER; - efx[nefx].condition.length = 5000; - for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { - efx[nefx].condition.right_sat[i] = 0xFFFF; - efx[nefx].condition.left_sat[i] = 0xFFFF; - efx[nefx].condition.right_coeff[i] = 0x2000; - efx[nefx].condition.left_coeff[i] = 0x2000; - } - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - /* The pretty awesome inertia effect. */ - if (supported & SDL_HAPTIC_INERTIA) { - SDL_Log(" effect %d: Condition Inertia\n", nefx); - efx[nefx].type = SDL_HAPTIC_INERTIA; - efx[nefx].condition.length = 5000; - for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { - efx[nefx].condition.right_sat[i] = 0xFFFF; - efx[nefx].condition.left_sat[i] = 0xFFFF; - efx[nefx].condition.right_coeff[i] = 0x2000; - efx[nefx].condition.left_coeff[i] = 0x2000; - efx[nefx].condition.deadband[i] = 0x1000; /* 1/16th of axis-range around the center is 'dead'. */ - } - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - /* The hot friction effect. */ - if (supported & SDL_HAPTIC_FRICTION) { - SDL_Log(" effect %d: Condition Friction\n", nefx); - efx[nefx].type = SDL_HAPTIC_FRICTION; - efx[nefx].condition.length = 5000; - for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { - efx[nefx].condition.right_sat[i] = 0xFFFF; - efx[nefx].condition.left_sat[i] = 0xFFFF; - efx[nefx].condition.right_coeff[i] = 0x2000; - efx[nefx].condition.left_coeff[i] = 0x2000; - } - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - - /* Now we'll try a ramp effect */ - if (supported & SDL_HAPTIC_RAMP) { - SDL_Log(" effect %d: Ramp\n", nefx); - efx[nefx].type = SDL_HAPTIC_RAMP; - efx[nefx].ramp.direction.type = SDL_HAPTIC_CARTESIAN; - efx[nefx].ramp.direction.dir[0] = 1; /* Force comes from */ - efx[nefx].ramp.direction.dir[1] = -1; /* the north-east. */ - efx[nefx].ramp.length = 5000; - efx[nefx].ramp.start = 0x4000; - efx[nefx].ramp.end = -0x4000; - efx[nefx].ramp.attack_length = 1000; - efx[nefx].ramp.fade_length = 1000; - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - - /* Finally we'll try a left/right effect. */ - if (supported & SDL_HAPTIC_LEFTRIGHT) { - SDL_Log(" effect %d: Left/Right\n", nefx); - efx[nefx].type = SDL_HAPTIC_LEFTRIGHT; - efx[nefx].leftright.length = 5000; - efx[nefx].leftright.large_magnitude = 0x3000; - efx[nefx].leftright.small_magnitude = 0xFFFF; - id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); - if (id[nefx] < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); - abort_execution(); - } - nefx++; - } - - - SDL_Log - ("\nNow playing effects for 5 seconds each with 1 second delay between\n"); - for (i = 0; i < nefx; i++) { - SDL_Log(" Playing effect %d\n", i); - SDL_HapticRunEffect(haptic, id[i], 1); - SDL_Delay(6000); /* Effects only have length 5000 */ - } - - /* Quit */ - if (haptic != NULL) - SDL_HapticClose(haptic); - SDL_Quit(); - - return 0; -} - - -/* - * Cleans up a bit. - */ -static void -abort_execution(void) -{ - SDL_Log("\nAborting program execution.\n"); - - SDL_HapticClose(haptic); - SDL_Quit(); - - exit(1); -} - - -/* - * Displays information about the haptic device. - */ -static void -HapticPrintSupported(SDL_Haptic * haptic) -{ - unsigned int supported; - - supported = SDL_HapticQuery(haptic); - SDL_Log(" Supported effects [%d effects, %d playing]:\n", - SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic)); - if (supported & SDL_HAPTIC_CONSTANT) - SDL_Log(" constant\n"); - if (supported & SDL_HAPTIC_SINE) - SDL_Log(" sine\n"); - /* !!! FIXME: put this back when we have more bits in 2.1 */ - /* if (supported & SDL_HAPTIC_SQUARE) - SDL_Log(" square\n"); */ - if (supported & SDL_HAPTIC_TRIANGLE) - SDL_Log(" triangle\n"); - if (supported & SDL_HAPTIC_SAWTOOTHUP) - SDL_Log(" sawtoothup\n"); - if (supported & SDL_HAPTIC_SAWTOOTHDOWN) - SDL_Log(" sawtoothdown\n"); - if (supported & SDL_HAPTIC_RAMP) - SDL_Log(" ramp\n"); - if (supported & SDL_HAPTIC_FRICTION) - SDL_Log(" friction\n"); - if (supported & SDL_HAPTIC_SPRING) - SDL_Log(" spring\n"); - if (supported & SDL_HAPTIC_DAMPER) - SDL_Log(" damper\n"); - if (supported & SDL_HAPTIC_INERTIA) - SDL_Log(" inertia\n"); - if (supported & SDL_HAPTIC_CUSTOM) - SDL_Log(" custom\n"); - if (supported & SDL_HAPTIC_LEFTRIGHT) - SDL_Log(" left/right\n"); - SDL_Log(" Supported capabilities:\n"); - if (supported & SDL_HAPTIC_GAIN) - SDL_Log(" gain\n"); - if (supported & SDL_HAPTIC_AUTOCENTER) - SDL_Log(" autocenter\n"); - if (supported & SDL_HAPTIC_STATUS) - SDL_Log(" status\n"); -} - -#else - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n"); - exit(1); -} - -#endif diff --git a/3rdparty/SDL2/test/testhittesting.c b/3rdparty/SDL2/test/testhittesting.c deleted file mode 100644 index 5e32be42d09..00000000000 --- a/3rdparty/SDL2/test/testhittesting.c +++ /dev/null @@ -1,134 +0,0 @@ -#include <stdio.h> -#include "SDL.h" - -/* !!! FIXME: rewrite this to be wired in to test framework. */ - -#define RESIZE_BORDER 20 - -const SDL_Rect drag_areas[] = { - { 20, 20, 100, 100 }, - { 200, 70, 100, 100 }, - { 400, 90, 100, 100 } -}; - -static const SDL_Rect *areas = drag_areas; -static int numareas = SDL_arraysize(drag_areas); - -static SDL_HitTestResult -hitTest(SDL_Window *window, const SDL_Point *pt, void *data) -{ - int i; - int w, h; - - for (i = 0; i < numareas; i++) { - if (SDL_PointInRect(pt, &areas[i])) { - SDL_Log("HIT-TEST: DRAGGABLE\n"); - return SDL_HITTEST_DRAGGABLE; - } - } - - SDL_GetWindowSize(window, &w, &h); - - #define REPORT_RESIZE_HIT(name) { \ - SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \ - return SDL_HITTEST_RESIZE_##name; \ - } - - if (pt->x < RESIZE_BORDER && pt->y < RESIZE_BORDER) { - REPORT_RESIZE_HIT(TOPLEFT); - } else if (pt->x > RESIZE_BORDER && pt->x < w - RESIZE_BORDER && pt->y < RESIZE_BORDER) { - REPORT_RESIZE_HIT(TOP); - } else if (pt->x > w - RESIZE_BORDER && pt->y < RESIZE_BORDER) { - REPORT_RESIZE_HIT(TOPRIGHT); - } else if (pt->x > w - RESIZE_BORDER && pt->y > RESIZE_BORDER && pt->y < h - RESIZE_BORDER) { - REPORT_RESIZE_HIT(RIGHT); - } else if (pt->x > w - RESIZE_BORDER && pt->y > h - RESIZE_BORDER) { - REPORT_RESIZE_HIT(BOTTOMRIGHT); - } else if (pt->x < w - RESIZE_BORDER && pt->x > RESIZE_BORDER && pt->y > h - RESIZE_BORDER) { - REPORT_RESIZE_HIT(BOTTOM); - } else if (pt->x < RESIZE_BORDER && pt->y > h - RESIZE_BORDER) { - REPORT_RESIZE_HIT(BOTTOMLEFT); - } else if (pt->x < RESIZE_BORDER && pt->y < h - RESIZE_BORDER && pt->y > RESIZE_BORDER) { - REPORT_RESIZE_HIT(LEFT); - } - - SDL_Log("HIT-TEST: NORMAL\n"); - return SDL_HITTEST_NORMAL; -} - - -int main(int argc, char **argv) -{ - int done = 0; - SDL_Window *window; - SDL_Renderer *renderer; - - /* !!! FIXME: check for errors. */ - SDL_Init(SDL_INIT_VIDEO); - window = SDL_CreateWindow("Drag the red boxes", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE); - renderer = SDL_CreateRenderer(window, -1, 0); - - if (SDL_SetWindowHitTest(window, hitTest, NULL) == -1) { - SDL_Log("Enabling hit-testing failed!\n"); - SDL_Quit(); - return 1; - } - - while (!done) - { - SDL_Event e; - int nothing_to_do = 1; - - SDL_SetRenderDrawColor(renderer, 0, 0, 127, 255); - SDL_RenderClear(renderer); - SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); - SDL_RenderFillRects(renderer, areas, SDL_arraysize(drag_areas)); - SDL_RenderPresent(renderer); - - while (SDL_PollEvent(&e)) { - nothing_to_do = 0; - - switch (e.type) - { - case SDL_MOUSEBUTTONDOWN: - SDL_Log("button down!\n"); - break; - - case SDL_MOUSEBUTTONUP: - SDL_Log("button up!\n"); - break; - - case SDL_WINDOWEVENT: - if (e.window.event == SDL_WINDOWEVENT_MOVED) { - SDL_Log("Window event moved to (%d, %d)!\n", (int) e.window.data1, (int) e.window.data2); - } - break; - - case SDL_KEYDOWN: - if (e.key.keysym.sym == SDLK_ESCAPE) { - done = 1; - } else if (e.key.keysym.sym == SDLK_x) { - if (!areas) { - areas = drag_areas; - numareas = SDL_arraysize(drag_areas); - } else { - areas = NULL; - numareas = 0; - } - } - break; - - case SDL_QUIT: - done = 1; - break; - } - } - - if (nothing_to_do) { - SDL_Delay(50); - } - } - - SDL_Quit(); - return 0; -} diff --git a/3rdparty/SDL2/test/testhotplug.c b/3rdparty/SDL2/test/testhotplug.c deleted file mode 100644 index 1fa9637548e..00000000000 --- a/3rdparty/SDL2/test/testhotplug.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple program to test the SDL joystick hotplugging */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "SDL.h" - -#if !defined SDL_JOYSTICK_DISABLED && !defined SDL_HAPTIC_DISABLED - -int -main(int argc, char *argv[]) -{ - SDL_Joystick *joystick = NULL; - SDL_Haptic *haptic = NULL; - SDL_JoystickID instance = -1; - SDL_bool keepGoing = SDL_TRUE; - int i; - SDL_bool enable_haptic = SDL_TRUE; - Uint32 init_subsystems = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK; - - for (i = 1; i < argc; ++i) { - if (SDL_strcasecmp(argv[i], "--nohaptic") == 0) { - enable_haptic = SDL_FALSE; - } - } - - if(enable_haptic) { - init_subsystems |= SDL_INIT_HAPTIC; - } - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); - - /* Initialize SDL (Note: video is required to start event loop) */ - if (SDL_Init(init_subsystems) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - - /* - //SDL_CreateWindow("Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, 0); - */ - - SDL_Log("There are %d joysticks at startup\n", SDL_NumJoysticks()); - if (enable_haptic) - SDL_Log("There are %d haptic devices at startup\n", SDL_NumHaptics()); - - while(keepGoing) - { - SDL_Event event; - while(SDL_PollEvent(&event)) - { - switch(event.type) - { - case SDL_QUIT: - keepGoing = SDL_FALSE; - break; - case SDL_JOYDEVICEADDED: - if (joystick != NULL) - { - SDL_Log("Only one joystick supported by this test\n"); - } - else - { - joystick = SDL_JoystickOpen(event.jdevice.which); - instance = SDL_JoystickInstanceID(joystick); - SDL_Log("Joy Added : %d : %s\n", event.jdevice.which, SDL_JoystickName(joystick)); - if (enable_haptic) - { - if (SDL_JoystickIsHaptic(joystick)) - { - haptic = SDL_HapticOpenFromJoystick(joystick); - if (haptic) - { - SDL_Log("Joy Haptic Opened\n"); - if (SDL_HapticRumbleInit( haptic ) != 0) - { - SDL_Log("Could not init Rumble!: %s\n", SDL_GetError()); - SDL_HapticClose(haptic); - haptic = NULL; - } - } else { - SDL_Log("Joy haptic open FAILED!: %s\n", SDL_GetError()); - } - } - else - { - SDL_Log("No haptic found\n"); - } - } - } - break; - case SDL_JOYDEVICEREMOVED: - if (instance == event.jdevice.which) - { - SDL_Log("Joy Removed: %d\n", event.jdevice.which); - instance = -1; - if(enable_haptic && haptic) - { - SDL_HapticClose(haptic); - haptic = NULL; - } - SDL_JoystickClose(joystick); - joystick = NULL; - } else { - SDL_Log("Unknown joystick diconnected\n"); - } - break; - case SDL_JOYAXISMOTION: -/* -// SDL_Log("Axis Move: %d\n", event.jaxis.axis); -*/ - if (enable_haptic) - SDL_HapticRumblePlay(haptic, 0.25, 250); - break; - case SDL_JOYBUTTONDOWN: - SDL_Log("Button Press: %d\n", event.jbutton.button); - if(enable_haptic && haptic) - { - SDL_HapticRumblePlay(haptic, 0.25, 250); - } - if (event.jbutton.button == 0) { - SDL_Log("Exiting due to button press of button 0\n"); - keepGoing = SDL_FALSE; - } - break; - case SDL_JOYBUTTONUP: - SDL_Log("Button Release: %d\n", event.jbutton.button); - break; - } - } - } - - SDL_Quit(); - - return 0; -} -#else - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick and haptic support.\n"); - return 1; -} - -#endif diff --git a/3rdparty/SDL2/test/testiconv.c b/3rdparty/SDL2/test/testiconv.c deleted file mode 100644 index 79efec8aaab..00000000000 --- a/3rdparty/SDL2/test/testiconv.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#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; - FILE *file; - int errors = 0; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (!argv[1]) { - argv[1] = "utf8.txt"; - } - file = fopen(argv[1], "rb"); - if (!file) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]); - ++errors; - } - SDL_free(test[0]); - 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]); - } - fclose(file); - return (errors ? errors + 1 : 0); -} diff --git a/3rdparty/SDL2/test/testime.c b/3rdparty/SDL2/test/testime.c deleted file mode 100644 index 39a40f82f37..00000000000 --- a/3rdparty/SDL2/test/testime.c +++ /dev/null @@ -1,793 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* A simple program to test the Input Method support in the SDL library (2.0+) - If you build without SDL_ttf, you can use the GNU Unifont hex file instead. - Download at http://unifoundry.com/unifont.html */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "SDL.h" -#ifdef HAVE_SDL_TTF -#include "SDL_ttf.h" -#endif - -#include "SDL_test_common.h" - -#define DEFAULT_PTSIZE 30 -#ifdef HAVE_SDL_TTF -#ifdef __MACOSX__ -#define DEFAULT_FONT "/System/Library/Fonts/华文细黑.ttf" -#elif __WIN32__ -/* Some japanese font present on at least Windows 8.1. */ -#define DEFAULT_FONT "C:\\Windows\\Fonts\\yugothic.ttf" -#else -#define DEFAULT_FONT "NoDefaultFont.ttf" -#endif -#else -#define DEFAULT_FONT "unifont-9.0.02.hex" -#endif -#define MAX_TEXT_LENGTH 256 - -static SDLTest_CommonState *state; -static SDL_Rect textRect, markedRect; -static SDL_Color lineColor = {0,0,0,255}; -static SDL_Color backColor = {255,255,255,255}; -static SDL_Color textColor = {0,0,0,255}; -static char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; -static int cursor = 0; -#ifdef HAVE_SDL_TTF -static TTF_Font *font; -#else -#define UNIFONT_MAX_CODEPOINT 0x1ffff -#define UNIFONT_NUM_GLYPHS 0x20000 -/* Using 512x512 textures that are supported everywhere. */ -#define UNIFONT_TEXTURE_WIDTH 512 -#define UNIFONT_GLYPHS_IN_ROW (UNIFONT_TEXTURE_WIDTH / 16) -#define UNIFONT_GLYPHS_IN_TEXTURE (UNIFONT_GLYPHS_IN_ROW * UNIFONT_GLYPHS_IN_ROW) -#define UNIFONT_NUM_TEXTURES ((UNIFONT_NUM_GLYPHS + UNIFONT_GLYPHS_IN_TEXTURE - 1) / UNIFONT_GLYPHS_IN_TEXTURE) -#define UNIFONT_TEXTURE_SIZE (UNIFONT_TEXTURE_WIDTH * UNIFONT_TEXTURE_WIDTH * 4) -#define UNIFONT_TEXTURE_PITCH (UNIFONT_TEXTURE_WIDTH * 4) -#define UNIFONT_DRAW_SCALE 2 -struct UnifontGlyph { - Uint8 width; - Uint8 data[32]; -} *unifontGlyph; -static SDL_Texture **unifontTexture; -static Uint8 unifontTextureLoaded[UNIFONT_NUM_TEXTURES] = {0}; - -/* Unifont loading code start */ - -static Uint8 dehex(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - else if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - return 255; -} - -static Uint8 dehex2(char c1, char c2) -{ - return (dehex(c1) << 4) | dehex(c2); -} - -static Uint8 validate_hex(const char *cp, size_t len, Uint32 *np) -{ - Uint32 n = 0; - for (; len > 0; cp++, len--) - { - Uint8 c = dehex(*cp); - if (c == 255) - return 0; - n = (n << 4) | c; - } - if (np != NULL) - *np = n; - return 1; -} - -static void unifont_init(const char *fontname) -{ - Uint8 hexBuffer[65]; - Uint32 numGlyphs = 0; - int lineNumber = 1; - size_t bytesRead; - SDL_RWops *hexFile; - const size_t unifontGlyphSize = UNIFONT_NUM_GLYPHS * sizeof(struct UnifontGlyph); - const size_t unifontTextureSize = UNIFONT_NUM_TEXTURES * state->num_windows * sizeof(void *); - - /* Allocate memory for the glyph data so the file can be closed after initialization. */ - unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize); - if (unifontGlyph == NULL) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.\n", (int)(unifontGlyphSize + 1023) / 1024); - exit(-1); - } - SDL_memset(unifontGlyph, 0, unifontGlyphSize); - - /* Allocate memory for texture pointers for all renderers. */ - unifontTexture = (SDL_Texture **)SDL_malloc(unifontTextureSize); - if (unifontTexture == NULL) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.\n", (int)(unifontTextureSize + 1023) / 1024); - exit(-1); - } - SDL_memset(unifontTexture, 0, unifontTextureSize); - - hexFile = SDL_RWFromFile(fontname, "rb"); - if (hexFile == NULL) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname); - exit(-1); - } - - /* Read all the glyph data into memory to make it accessible later when textures are created. */ - do { - int i, codepointHexSize; - size_t bytesOverread; - Uint8 glyphWidth; - Uint32 codepoint; - - bytesRead = SDL_RWread(hexFile, hexBuffer, 1, 9); - if (numGlyphs > 0 && bytesRead == 0) - break; /* EOF */ - if ((numGlyphs == 0 && bytesRead == 0) || (numGlyphs > 0 && bytesRead < 9)) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unfiont: Unexpected end of hex file.\n"); - exit(-1); - } - - /* Looking for the colon that separates the codepoint and glyph data at position 2, 4, 6 and 8. */ - if (hexBuffer[2] == ':') - codepointHexSize = 2; - else if (hexBuffer[4] == ':') - codepointHexSize = 4; - else if (hexBuffer[6] == ':') - codepointHexSize = 6; - else if (hexBuffer[8] == ':') - codepointHexSize = 8; - else - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Could not find codepoint and glyph data separator symbol in hex file on line %d.\n", lineNumber); - exit(-1); - } - - if (!validate_hex((const char *)hexBuffer, codepointHexSize, &codepoint)) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Malformed hexadecimal number in hex file on line %d.\n", lineNumber); - exit(-1); - } - if (codepoint > UNIFONT_MAX_CODEPOINT) - SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "unifont: Codepoint on line %d exceeded limit of 0x%x.\n", lineNumber, UNIFONT_MAX_CODEPOINT); - - /* If there was glyph data read in the last file read, move it to the front of the buffer. */ - bytesOverread = 8 - codepointHexSize; - if (codepointHexSize < 8) - SDL_memmove(hexBuffer, hexBuffer + codepointHexSize + 1, bytesOverread); - bytesRead = SDL_RWread(hexFile, hexBuffer + bytesOverread, 1, 33 - bytesOverread); - if (bytesRead < (33 - bytesOverread)) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n"); - exit(-1); - } - if (hexBuffer[32] == '\n') - glyphWidth = 8; - else - { - glyphWidth = 16; - bytesRead = SDL_RWread(hexFile, hexBuffer + 33, 1, 32); - if (bytesRead < 32) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n"); - exit(-1); - } - } - - if (!validate_hex((const char *)hexBuffer, glyphWidth * 4, NULL)) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Malformed hexadecimal glyph data in hex file on line %d.\n", lineNumber); - exit(-1); - } - - if (codepoint <= UNIFONT_MAX_CODEPOINT) - { - if (unifontGlyph[codepoint].width > 0) - SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "unifont: Ignoring duplicate codepoint 0x%08x in hex file on line %d.\n", codepoint, lineNumber); - else - { - unifontGlyph[codepoint].width = glyphWidth; - /* Pack the hex data into a more compact form. */ - for (i = 0; i < glyphWidth * 2; i++) - unifontGlyph[codepoint].data[i] = dehex2(hexBuffer[i * 2], hexBuffer[i * 2 + 1]); - numGlyphs++; - } - } - - lineNumber++; - } while (bytesRead > 0); - - SDL_RWclose(hexFile); - SDL_Log("unifont: Loaded %u glyphs.\n", numGlyphs); -} - -static void unifont_make_rgba(Uint8 *src, Uint8 *dst, Uint8 width) -{ - int i, j; - Uint8 *row = dst; - - for (i = 0; i < width * 2; i++) - { - Uint8 data = src[i]; - for (j = 0; j < 8; j++) - { - if (data & 0x80) - { - row[0] = textColor.r; - row[1] = textColor.g; - row[2] = textColor.b; - row[3] = textColor.a; - } - else - { - row[0] = 0; - row[1] = 0; - row[2] = 0; - row[3] = 0; - } - data <<= 1; - row += 4; - } - - if (width == 8 || (width == 16 && i % 2 == 1)) - { - dst += UNIFONT_TEXTURE_PITCH; - row = dst; - } - } -} - -static void unifont_load_texture(Uint32 textureID) -{ - int i; - Uint8 * textureRGBA; - - if (textureID >= UNIFONT_NUM_TEXTURES) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Tried to load out of range texture %u.\n", textureID); - exit(-1); - } - - textureRGBA = (Uint8 *)SDL_malloc(UNIFONT_TEXTURE_SIZE); - if (textureRGBA == NULL) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.\n", UNIFONT_TEXTURE_SIZE / 1024 / 1024); - exit(-1); - } - SDL_memset(textureRGBA, 0, UNIFONT_TEXTURE_SIZE); - - /* Copy the glyphs into memory in RGBA format. */ - for (i = 0; i < UNIFONT_GLYPHS_IN_TEXTURE; i++) - { - Uint32 codepoint = UNIFONT_GLYPHS_IN_TEXTURE * textureID + i; - if (unifontGlyph[codepoint].width > 0) - { - const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE; - const size_t offset = (cInTex / UNIFONT_GLYPHS_IN_ROW) * UNIFONT_TEXTURE_PITCH * 16 + (cInTex % UNIFONT_GLYPHS_IN_ROW) * 16 * 4; - unifont_make_rgba(unifontGlyph[codepoint].data, textureRGBA + offset, unifontGlyph[codepoint].width); - } - } - - /* Create textures and upload the RGBA data from above. */ - for (i = 0; i < state->num_windows; ++i) - { - SDL_Renderer *renderer = state->renderers[i]; - SDL_Texture *tex = unifontTexture[UNIFONT_NUM_TEXTURES * i + textureID]; - if (state->windows[i] == NULL || renderer == NULL || tex != NULL) - continue; - tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, UNIFONT_TEXTURE_WIDTH, UNIFONT_TEXTURE_WIDTH); - if (tex == NULL) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to create texture %u for renderer %d.\n", textureID, i); - exit(-1); - } - unifontTexture[UNIFONT_NUM_TEXTURES * i + textureID] = tex; - SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND); - if (SDL_UpdateTexture(tex, NULL, textureRGBA, UNIFONT_TEXTURE_PITCH) != 0) - { - SDL_Log("unifont error: Failed to update texture %u data for renderer %d.\n", textureID, i); - } - } - - SDL_free(textureRGBA); - unifontTextureLoaded[textureID] = 1; -} - -static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dstrect) -{ - SDL_Texture *texture; - const Uint32 textureID = codepoint / UNIFONT_GLYPHS_IN_TEXTURE; - SDL_Rect srcrect; - srcrect.w = srcrect.h = 16; - if (codepoint > UNIFONT_MAX_CODEPOINT) - return 0; - if (!unifontTextureLoaded[textureID]) - unifont_load_texture(textureID); - texture = unifontTexture[UNIFONT_NUM_TEXTURES * rendererID + textureID]; - if (texture != NULL) - { - const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE; - srcrect.x = cInTex % UNIFONT_GLYPHS_IN_ROW * 16; - srcrect.y = cInTex / UNIFONT_GLYPHS_IN_ROW * 16; - SDL_RenderCopy(state->renderers[rendererID], texture, &srcrect, dstrect); - } - return unifontGlyph[codepoint].width; -} - -static void unifont_cleanup() -{ - int i, j; - for (i = 0; i < state->num_windows; ++i) - { - SDL_Renderer *renderer = state->renderers[i]; - if (state->windows[i] == NULL || renderer == NULL) - continue; - for (j = 0; j < UNIFONT_NUM_TEXTURES; j++) - { - SDL_Texture *tex = unifontTexture[UNIFONT_NUM_TEXTURES * i + j]; - if (tex != NULL) - SDL_DestroyTexture(tex); - } - } - - for (j = 0; j < UNIFONT_NUM_TEXTURES; j++) - unifontTextureLoaded[j] = 0; - - SDL_free(unifontTexture); - SDL_free(unifontGlyph); -} - -/* Unifont code end */ -#endif - -size_t utf8_length(unsigned char c) -{ - c = (unsigned char)(0xff & c); - if (c < 0x80) - return 1; - else if ((c >> 5) ==0x6) - return 2; - else if ((c >> 4) == 0xe) - return 3; - else if ((c >> 3) == 0x1e) - return 4; - else - return 0; -} - -char *utf8_next(char *p) -{ - size_t len = utf8_length(*p); - size_t i = 0; - if (!len) - return 0; - - for (; i < len; ++i) - { - ++p; - if (!*p) - return 0; - } - return p; -} - -char *utf8_advance(char *p, size_t distance) -{ - size_t i = 0; - for (; i < distance && p; ++i) - { - p = utf8_next(p); - } - return p; -} - -Uint32 utf8_decode(char *p, size_t len) -{ - Uint32 codepoint = 0; - size_t i = 0; - if (!len) - return 0; - - for (; i < len; ++i) - { - if (i == 0) - codepoint = (0xff >> len) & *p; - else - { - codepoint <<= 6; - codepoint |= 0x3f & *p; - } - if (!*p) - return 0; - p++; - } - - return codepoint; -} - -void usage() -{ - SDL_Log("usage: testime [--font fontfile]\n"); - exit(0); -} - -void InitInput() -{ - - /* Prepare a rect for text input */ - textRect.x = textRect.y = 100; - textRect.w = DEFAULT_WINDOW_WIDTH - 2 * textRect.x; - textRect.h = 50; - - text[0] = 0; - markedRect = textRect; - markedText[0] = 0; - - SDL_StartTextInput(); -} - -void CleanupVideo() -{ - SDL_StopTextInput(); -#ifdef HAVE_SDL_TTF - TTF_CloseFont(font); - TTF_Quit(); -#else - unifont_cleanup(); -#endif -} - -void _Redraw(int rendererID) { - SDL_Renderer * renderer = state->renderers[rendererID]; - SDL_Rect drawnTextRect, cursorRect, underlineRect; - drawnTextRect = textRect; - drawnTextRect.w = 0; - - SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a); - SDL_RenderFillRect(renderer,&textRect); - - if (*text) - { -#ifdef HAVE_SDL_TTF - SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, textColor); - SDL_Texture *texture; - - /* Vertically center text */ - drawnTextRect.y = textRect.y + (textRect.h - textSur->h) / 2; - drawnTextRect.w = textSur->w; - drawnTextRect.h = textSur->h; - - texture = SDL_CreateTextureFromSurface(renderer,textSur); - SDL_FreeSurface(textSur); - - SDL_RenderCopy(renderer,texture,NULL,&drawnTextRect); - SDL_DestroyTexture(texture); -#else - char *utext = text; - Uint32 codepoint; - size_t len; - SDL_Rect dstrect; - - dstrect.x = textRect.x; - dstrect.y = textRect.y + (textRect.h - 16 * UNIFONT_DRAW_SCALE) / 2; - dstrect.w = 16 * UNIFONT_DRAW_SCALE; - dstrect.h = 16 * UNIFONT_DRAW_SCALE; - drawnTextRect.y = dstrect.y; - drawnTextRect.h = dstrect.h; - - while ((codepoint = utf8_decode(utext, len = utf8_length(*utext)))) - { - Sint32 advance = unifont_draw_glyph(codepoint, rendererID, &dstrect) * UNIFONT_DRAW_SCALE; - dstrect.x += advance; - drawnTextRect.w += advance; - utext += len; - } -#endif - } - - markedRect.x = textRect.x + drawnTextRect.w; - markedRect.w = textRect.w - drawnTextRect.w; - if (markedRect.w < 0) - { - /* Stop text input because we cannot hold any more characters */ - SDL_StopTextInput(); - return; - } - else - { - SDL_StartTextInput(); - } - - cursorRect = drawnTextRect; - cursorRect.x += cursorRect.w; - cursorRect.w = 2; - cursorRect.h = drawnTextRect.h; - - drawnTextRect.x += drawnTextRect.w; - drawnTextRect.w = 0; - - SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a); - SDL_RenderFillRect(renderer,&markedRect); - - if (markedText[0]) - { -#ifdef HAVE_SDL_TTF - SDL_Surface *textSur; - SDL_Texture *texture; - if (cursor) - { - char *p = utf8_advance(markedText, cursor); - char c = 0; - if (!p) - p = &markedText[SDL_strlen(markedText)]; - - c = *p; - *p = 0; - TTF_SizeUTF8(font, markedText, &drawnTextRect.w, NULL); - cursorRect.x += drawnTextRect.w; - *p = c; - } - textSur = TTF_RenderUTF8_Blended(font, markedText, textColor); - /* Vertically center text */ - drawnTextRect.y = textRect.y + (textRect.h - textSur->h) / 2; - drawnTextRect.w = textSur->w; - drawnTextRect.h = textSur->h; - - texture = SDL_CreateTextureFromSurface(renderer,textSur); - SDL_FreeSurface(textSur); - - SDL_RenderCopy(renderer,texture,NULL,&drawnTextRect); - SDL_DestroyTexture(texture); -#else - int i = 0; - char *utext = markedText; - Uint32 codepoint; - size_t len; - SDL_Rect dstrect; - - dstrect.x = drawnTextRect.x; - dstrect.y = textRect.y + (textRect.h - 16 * UNIFONT_DRAW_SCALE) / 2; - dstrect.w = 16 * UNIFONT_DRAW_SCALE; - dstrect.h = 16 * UNIFONT_DRAW_SCALE; - drawnTextRect.y = dstrect.y; - drawnTextRect.h = dstrect.h; - - while ((codepoint = utf8_decode(utext, len = utf8_length(*utext)))) - { - Sint32 advance = unifont_draw_glyph(codepoint, rendererID, &dstrect) * UNIFONT_DRAW_SCALE; - dstrect.x += advance; - drawnTextRect.w += advance; - if (i < cursor) - cursorRect.x += advance; - i++; - utext += len; - } -#endif - - if (cursor > 0) - { - cursorRect.y = drawnTextRect.y; - cursorRect.h = drawnTextRect.h; - } - - underlineRect = markedRect; - underlineRect.y = drawnTextRect.y + drawnTextRect.h - 2; - underlineRect.h = 2; - underlineRect.w = drawnTextRect.w; - - SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a); - SDL_RenderFillRect(renderer, &underlineRect); - } - - SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a); - SDL_RenderFillRect(renderer,&cursorRect); - - SDL_SetTextInputRect(&markedRect); -} - -void Redraw() { - int i; - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - if (state->windows[i] == NULL) - continue; - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); - SDL_RenderClear(renderer); - - /* Sending in the window id to let the font renderers know which one we're working with. */ - _Redraw(i); - - SDL_RenderPresent(renderer); - } -} - -int main(int argc, char *argv[]) { - int i, done; - SDL_Event event; - const char *fontname = DEFAULT_FONT; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;i++) { - SDLTest_CommonArg(state, i); - } - for (argc--, argv++; argc > 0; argc--, argv++) - { - if (strcmp(argv[0], "--help") == 0) { - usage(); - return 0; - } - - else if (strcmp(argv[0], "--font") == 0) - { - argc--; - argv++; - - if (argc > 0) - fontname = argv[0]; - else { - usage(); - return 0; - } - } - } - - if (!SDLTest_CommonInit(state)) { - return 2; - } - - -#ifdef HAVE_SDL_TTF - /* Initialize fonts */ - TTF_Init(); - - font = TTF_OpenFont(fontname, DEFAULT_PTSIZE); - if (! font) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError()); - exit(-1); - } -#else - unifont_init(fontname); -#endif - - SDL_Log("Using font: %s\n", fontname); - atexit(SDL_Quit); - - InitInput(); - /* Create the windows and initialize the renderers */ - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE); - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - Redraw(); - /* Main render loop */ - done = 0; - while (!done) { - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - switch(event.type) { - case SDL_KEYDOWN: { - switch (event.key.keysym.sym) - { - case SDLK_RETURN: - text[0]=0x00; - Redraw(); - break; - case SDLK_BACKSPACE: - /* Only delete text if not in editing mode. */ - if (!markedText[0]) - { - size_t textlen = SDL_strlen(text); - - do { - if (textlen==0) - { - break; - } - if ((text[textlen-1] & 0x80) == 0x00) - { - /* One byte */ - text[textlen-1]=0x00; - break; - } - if ((text[textlen-1] & 0xC0) == 0x80) - { - /* Byte from the multibyte sequence */ - text[textlen-1]=0x00; - textlen--; - } - if ((text[textlen-1] & 0xC0) == 0xC0) - { - /* First byte of multibyte sequence */ - text[textlen-1]=0x00; - break; - } - } while(1); - - Redraw(); - } - break; - } - - if (done) - { - break; - } - - SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n", - event.key.keysym.scancode, - SDL_GetScancodeName(event.key.keysym.scancode), - event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym)); - break; - - case SDL_TEXTINPUT: - if (event.text.text[0] == '\0' || event.text.text[0] == '\n' || - markedRect.w < 0) - break; - - SDL_Log("Keyboard: text input \"%s\"\n", event.text.text); - - if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) - SDL_strlcat(text, event.text.text, sizeof(text)); - - SDL_Log("text inputed: %s\n", text); - - /* After text inputed, we can clear up markedText because it */ - /* is committed */ - markedText[0] = 0; - Redraw(); - break; - - case SDL_TEXTEDITING: - SDL_Log("text editing \"%s\", selected range (%d, %d)\n", - event.edit.text, event.edit.start, event.edit.length); - - SDL_strlcpy(markedText, event.edit.text, SDL_TEXTEDITINGEVENT_TEXT_SIZE); - cursor = event.edit.start; - Redraw(); - break; - } - break; - - } - } - } - CleanupVideo(); - SDLTest_CommonQuit(state); - return 0; -} - - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testintersections.c b/3rdparty/SDL2/test/testintersections.c deleted file mode 100644 index 82aae633886..00000000000 --- a/3rdparty/SDL2/test/testintersections.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple program: draw as many random objects on the screen as possible */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - -#define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0) -#define NUM_OBJECTS 100 - -static SDLTest_CommonState *state; -static int num_objects; -static SDL_bool cycle_color; -static SDL_bool cycle_alpha; -static int cycle_direction = 1; -static int current_alpha = 255; -static int current_color = 255; -static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE; - -int mouse_begin_x = -1, mouse_begin_y = -1; -int done; - -void -DrawPoints(SDL_Renderer * renderer) -{ - int i; - int x, y; - SDL_Rect viewport; - - /* Query the sizes */ - SDL_RenderGetViewport(renderer, &viewport); - - for (i = 0; i < num_objects * 4; ++i) { - /* Cycle the color and alpha, if desired */ - if (cycle_color) { - current_color += cycle_direction; - if (current_color < 0) { - current_color = 0; - cycle_direction = -cycle_direction; - } - if (current_color > 255) { - current_color = 255; - cycle_direction = -cycle_direction; - } - } - if (cycle_alpha) { - current_alpha += cycle_direction; - if (current_alpha < 0) { - current_alpha = 0; - cycle_direction = -cycle_direction; - } - if (current_alpha > 255) { - current_alpha = 255; - cycle_direction = -cycle_direction; - } - } - SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color, - (Uint8) current_color, (Uint8) current_alpha); - - x = rand() % viewport.w; - y = rand() % viewport.h; - SDL_RenderDrawPoint(renderer, x, y); - } -} - -#define MAX_LINES 16 -int num_lines = 0; -SDL_Rect lines[MAX_LINES]; -static int -add_line(int x1, int y1, int x2, int y2) -{ - if (num_lines >= MAX_LINES) - return 0; - if ((x1 == x2) && (y1 == y2)) - return 0; - - SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2); - lines[num_lines].x = x1; - lines[num_lines].y = y1; - lines[num_lines].w = x2; - lines[num_lines].h = y2; - - return ++num_lines; -} - - -void -DrawLines(SDL_Renderer * renderer) -{ - int i; - SDL_Rect viewport; - - /* Query the sizes */ - SDL_RenderGetViewport(renderer, &viewport); - - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); - - for (i = 0; i < num_lines; ++i) { - if (i == -1) { - SDL_RenderDrawLine(renderer, 0, 0, viewport.w - 1, viewport.h - 1); - SDL_RenderDrawLine(renderer, 0, viewport.h - 1, viewport.w - 1, 0); - SDL_RenderDrawLine(renderer, 0, viewport.h / 2, viewport.w - 1, viewport.h / 2); - SDL_RenderDrawLine(renderer, viewport.w / 2, 0, viewport.w / 2, viewport.h - 1); - } else { - SDL_RenderDrawLine(renderer, lines[i].x, lines[i].y, lines[i].w, lines[i].h); - } - } -} - -#define MAX_RECTS 16 -int num_rects = 0; -SDL_Rect rects[MAX_RECTS]; -static int -add_rect(int x1, int y1, int x2, int y2) -{ - if (num_rects >= MAX_RECTS) - return 0; - if ((x1 == x2) || (y1 == y2)) - return 0; - - if (x1 > x2) - SWAP(int, x1, x2); - if (y1 > y2) - SWAP(int, y1, y2); - - SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2, - x2 - x1, y2 - y1); - - rects[num_rects].x = x1; - rects[num_rects].y = y1; - rects[num_rects].w = x2 - x1; - rects[num_rects].h = y2 - y1; - - return ++num_rects; -} - -static void -DrawRects(SDL_Renderer * renderer) -{ - SDL_SetRenderDrawColor(renderer, 255, 127, 0, 255); - SDL_RenderFillRects(renderer, rects, num_rects); -} - -static void -DrawRectLineIntersections(SDL_Renderer * renderer) -{ - int i, j; - - SDL_SetRenderDrawColor(renderer, 0, 255, 55, 255); - - for (i = 0; i < num_rects; i++) - for (j = 0; j < num_lines; j++) { - int x1, y1, x2, y2; - SDL_Rect r; - - r = rects[i]; - x1 = lines[j].x; - y1 = lines[j].y; - x2 = lines[j].w; - y2 = lines[j].h; - - if (SDL_IntersectRectAndLine(&r, &x1, &y1, &x2, &y2)) { - SDL_RenderDrawLine(renderer, x1, y1, x2, y2); - } - } -} - -static void -DrawRectRectIntersections(SDL_Renderer * renderer) -{ - int i, j; - - SDL_SetRenderDrawColor(renderer, 255, 200, 0, 255); - - for (i = 0; i < num_rects; i++) - for (j = i + 1; j < num_rects; j++) { - SDL_Rect r; - if (SDL_IntersectRect(&rects[i], &rects[j], &r)) { - SDL_RenderFillRect(renderer, &r); - } - } -} - -void -loop() -{ - int i; - SDL_Event event; - - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - switch (event.type) { - case SDL_MOUSEBUTTONDOWN: - mouse_begin_x = event.button.x; - mouse_begin_y = event.button.y; - break; - case SDL_MOUSEBUTTONUP: - if (event.button.button == 3) - add_line(mouse_begin_x, mouse_begin_y, event.button.x, - event.button.y); - if (event.button.button == 1) - add_rect(mouse_begin_x, mouse_begin_y, event.button.x, - event.button.y); - break; - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case 'l': - if (event.key.keysym.mod & KMOD_SHIFT) - num_lines = 0; - else - add_line(rand() % 640, rand() % 480, rand() % 640, - rand() % 480); - break; - case 'r': - if (event.key.keysym.mod & KMOD_SHIFT) - num_rects = 0; - else - add_rect(rand() % 640, rand() % 480, rand() % 640, - rand() % 480); - break; - } - break; - default: - break; - } - } - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - if (state->windows[i] == NULL) - continue; - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - - DrawRects(renderer); - DrawPoints(renderer); - DrawRectRectIntersections(renderer); - DrawLines(renderer); - DrawRectLineIntersections(renderer); - - SDL_RenderPresent(renderer); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - Uint32 then, now, frames; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize parameters */ - num_objects = NUM_OBJECTS; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - if (SDL_strcasecmp(argv[i], "--blend") == 0) { - if (argv[i + 1]) { - if (SDL_strcasecmp(argv[i + 1], "none") == 0) { - blendMode = SDL_BLENDMODE_NONE; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { - blendMode = SDL_BLENDMODE_BLEND; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { - blendMode = SDL_BLENDMODE_ADD; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { - blendMode = SDL_BLENDMODE_MOD; - consumed = 2; - } - } - } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { - cycle_color = SDL_TRUE; - consumed = 1; - } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) { - cycle_alpha = SDL_TRUE; - consumed = 1; - } else if (SDL_isdigit(*argv[i])) { - num_objects = SDL_atoi(argv[i]); - consumed = 1; - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", - argv[0], SDLTest_CommonUsage(state)); - return 1; - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - return 2; - } - - /* Create the windows and initialize the renderers */ - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawBlendMode(renderer, blendMode); - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - - srand(time(NULL)); - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - ++frames; - loop(); - } -#endif - - SDLTest_CommonQuit(state); - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testjoystick.c b/3rdparty/SDL2/test/testjoystick.c deleted file mode 100644 index bed27212e11..00000000000 --- a/3rdparty/SDL2/test/testjoystick.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple program to test the SDL joystick routines */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "SDL.h" - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#ifndef SDL_JOYSTICK_DISABLED - -#ifdef __IPHONEOS__ -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 480 -#else -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 -#endif - -SDL_Renderer *screen = NULL; -SDL_bool retval = SDL_FALSE; -SDL_bool done = SDL_FALSE; - -static void -DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h) -{ - const SDL_Rect area = { x, y, w, h }; - SDL_RenderFillRect(r, &area); -} - -void -loop(void *arg) -{ - SDL_Event event; - int i; - SDL_Joystick *joystick = (SDL_Joystick *)arg; - - /* blank screen, set up for drawing this frame. */ - SDL_SetRenderDrawColor(screen, 0x0, 0x0, 0x0, SDL_ALPHA_OPAQUE); - SDL_RenderClear(screen); - - while (SDL_PollEvent(&event)) { - switch (event.type) { - - case SDL_JOYDEVICEREMOVED: - SDL_Log("Joystick device %d removed.\n", (int) event.jdevice.which); - SDL_Log("Our instance ID is %d\n", (int) SDL_JoystickInstanceID(joystick)); - break; - - case SDL_JOYAXISMOTION: - SDL_Log("Joystick %d axis %d value: %d\n", - event.jaxis.which, - event.jaxis.axis, event.jaxis.value); - break; - case SDL_JOYHATMOTION: - SDL_Log("Joystick %d hat %d value:", - event.jhat.which, event.jhat.hat); - if (event.jhat.value == SDL_HAT_CENTERED) - SDL_Log(" centered"); - if (event.jhat.value & SDL_HAT_UP) - SDL_Log(" up"); - if (event.jhat.value & SDL_HAT_RIGHT) - SDL_Log(" right"); - if (event.jhat.value & SDL_HAT_DOWN) - SDL_Log(" down"); - if (event.jhat.value & SDL_HAT_LEFT) - SDL_Log(" left"); - SDL_Log("\n"); - break; - case SDL_JOYBALLMOTION: - SDL_Log("Joystick %d ball %d delta: (%d,%d)\n", - event.jball.which, - event.jball.ball, event.jball.xrel, event.jball.yrel); - break; - case SDL_JOYBUTTONDOWN: - SDL_Log("Joystick %d button %d down\n", - event.jbutton.which, event.jbutton.button); - break; - case SDL_JOYBUTTONUP: - SDL_Log("Joystick %d button %d up\n", - event.jbutton.which, event.jbutton.button); - break; - case SDL_KEYDOWN: - if ((event.key.keysym.sym != SDLK_ESCAPE) && - (event.key.keysym.sym != SDLK_AC_BACK)) { - break; - } - /* Fall through to signal quit */ - case SDL_FINGERDOWN: - case SDL_MOUSEBUTTONDOWN: - case SDL_QUIT: - done = SDL_TRUE; - break; - default: - break; - } - } - /* Update visual joystick state */ - SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE); - for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) { - if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) { - DrawRect(screen, (i%20) * 34, SCREEN_HEIGHT - 68 + (i/20) * 34, 32, 32); - } - } - - SDL_SetRenderDrawColor(screen, 0xFF, 0x00, 0x00, SDL_ALPHA_OPAQUE); - for (i = 0; i < SDL_JoystickNumAxes(joystick); ++i) { - /* Draw the X/Y axis */ - int x, y; - x = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768); - x *= SCREEN_WIDTH; - x /= 65535; - if (x < 0) { - x = 0; - } else if (x > (SCREEN_WIDTH - 16)) { - x = SCREEN_WIDTH - 16; - } - ++i; - if (i < SDL_JoystickNumAxes(joystick)) { - y = (((int) SDL_JoystickGetAxis(joystick, i)) + 32768); - } else { - y = 32768; - } - y *= SCREEN_HEIGHT; - y /= 65535; - if (y < 0) { - y = 0; - } else if (y > (SCREEN_HEIGHT - 16)) { - y = SCREEN_HEIGHT - 16; - } - - DrawRect(screen, x, y, 16, 16); - } - - SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE); - for (i = 0; i < SDL_JoystickNumHats(joystick); ++i) { - /* Derive the new position */ - int x = SCREEN_WIDTH/2; - int y = SCREEN_HEIGHT/2; - const Uint8 hat_pos = SDL_JoystickGetHat(joystick, i); - - if (hat_pos & SDL_HAT_UP) { - y = 0; - } else if (hat_pos & SDL_HAT_DOWN) { - y = SCREEN_HEIGHT-8; - } - - if (hat_pos & SDL_HAT_LEFT) { - x = 0; - } else if (hat_pos & SDL_HAT_RIGHT) { - x = SCREEN_WIDTH-8; - } - - DrawRect(screen, x, y, 8, 8); - } - - SDL_RenderPresent(screen); - - if (SDL_JoystickGetAttached( joystick ) == 0) { - done = SDL_TRUE; - retval = SDL_TRUE; /* keep going, wait for reattach. */ - } - -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -static SDL_bool -WatchJoystick(SDL_Joystick * joystick) -{ - SDL_Window *window = NULL; - const char *name = NULL; - - retval = SDL_FALSE; - done = SDL_FALSE; - - /* Create a window to display joystick axis position */ - window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); - if (window == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); - return SDL_FALSE; - } - - screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); - SDL_DestroyWindow(window); - return SDL_FALSE; - } - - SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE); - SDL_RenderClear(screen); - SDL_RenderPresent(screen); - SDL_RaiseWindow(window); - - /* Print info about the joystick we are watching */ - name = SDL_JoystickName(joystick); - SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick), - name ? name : "Unknown Joystick"); - SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", - SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), - SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); - - /* Loop, getting joystick events! */ -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop_arg(loop, joystick, 0, 1); -#else - while (!done) { - loop(joystick); - } -#endif - - SDL_DestroyRenderer(screen); - screen = NULL; - SDL_DestroyWindow(window); - return retval; -} - -int -main(int argc, char *argv[]) -{ - const char *name; - int i; - SDL_Joystick *joystick; - - SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize SDL (Note: video is required to start event loop) */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - - /* Print information about the joysticks */ - SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks()); - for (i = 0; i < SDL_NumJoysticks(); ++i) { - name = SDL_JoystickNameForIndex(i); - SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); - joystick = SDL_JoystickOpen(i); - if (joystick == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i, - SDL_GetError()); - } else { - char guid[64]; - SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick); - SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), - guid, sizeof (guid)); - SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick)); - SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick)); - SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick)); - SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joystick)); - SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick)); - SDL_Log(" guid: %s\n", guid); - SDL_JoystickClose(joystick); - } - } - -#if defined(__ANDROID__) || defined(__IPHONEOS__) - if (SDL_NumJoysticks() > 0) { -#else - if (argv[1]) { -#endif - SDL_bool reportederror = SDL_FALSE; - SDL_bool keepGoing = SDL_TRUE; - SDL_Event event; - int device; -#if defined(__ANDROID__) || defined(__IPHONEOS__) - device = 0; -#else - device = atoi(argv[1]); -#endif - joystick = SDL_JoystickOpen(device); - if (joystick != NULL) { - SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick); - } - - while ( keepGoing ) { - if (joystick == NULL) { - if ( !reportederror ) { - SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError()); - keepGoing = SDL_FALSE; - reportederror = SDL_TRUE; - } - } else { - reportederror = SDL_FALSE; - keepGoing = WatchJoystick(joystick); - SDL_JoystickClose(joystick); - } - - joystick = NULL; - if (keepGoing) { - SDL_Log("Waiting for attach\n"); - } - while (keepGoing) { - SDL_WaitEvent(&event); - if ((event.type == SDL_QUIT) || (event.type == SDL_FINGERDOWN) - || (event.type == SDL_MOUSEBUTTONDOWN)) { - keepGoing = SDL_FALSE; - } else if (event.type == SDL_JOYDEVICEADDED) { - joystick = SDL_JoystickOpen(device); - if (joystick != NULL) { - SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick); - } - break; - } - } - } - } - SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); - - return 0; -} - -#else - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n"); - exit(1); -} - -#endif diff --git a/3rdparty/SDL2/test/testkeys.c b/3rdparty/SDL2/test/testkeys.c deleted file mode 100644 index aea496caaf0..00000000000 --- a/3rdparty/SDL2/test/testkeys.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Print out all the scancodes 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[]) -{ - SDL_Scancode scancode; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { - SDL_Log("Scancode #%d, \"%s\"\n", scancode, - SDL_GetScancodeName(scancode)); - } - SDL_Quit(); - return (0); -} diff --git a/3rdparty/SDL2/test/testloadso.c b/3rdparty/SDL2/test/testloadso.c deleted file mode 100644 index fb87fbed7ae..00000000000 --- a/3rdparty/SDL2/test/testloadso.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Test program to test dynamic loading with the loadso subsystem. -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.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]; - SDL_Log("USAGE: %s <library> <functionname>\n", app); - SDL_Log(" %s --hello <lib with puts()>\n", app); - return 1; - } - - /* Initialize SDL */ - if (SDL_Init(0) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n", - libname, SDL_GetError()); - retval = 3; - } else { - fn = (fntype) SDL_LoadFunction(lib, symname); - if (fn == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n", - symname, SDL_GetError()); - retval = 4; - } else { - SDL_Log("Found %s in %s at %p\n", symname, libname, fn); - if (hello) { - SDL_Log("Calling function...\n"); - fflush(stdout); - fn(" HELLO, WORLD!\n"); - SDL_Log("...apparently, we survived. :)\n"); - SDL_Log("Unloading library...\n"); - fflush(stdout); - } - } - SDL_UnloadObject(lib); - } - SDL_Quit(); - return retval; -} diff --git a/3rdparty/SDL2/test/testlock.c b/3rdparty/SDL2/test/testlock.c deleted file mode 100644 index 113ba0d4c4a..00000000000 --- a/3rdparty/SDL2/test/testlock.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Test the thread and mutex locking functions - Also exercises the system's signal/thread interaction -*/ - -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> /* for atexit() */ - -#include "SDL.h" - -static SDL_mutex *mutex = NULL; -static SDL_threadID mainthread; -static SDL_Thread *threads[6]; -static SDL_atomic_t doterminate; - -/* - * 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) -{ - SDL_Log("Process %lu: exiting\n", SDL_ThreadID()); -} - -void -terminate(int sig) -{ - signal(SIGINT, terminate); - SDL_AtomicSet(&doterminate, 1); -} - -void -closemutex(int sig) -{ - SDL_threadID id = SDL_ThreadID(); - int i; - SDL_Log("Process %lu: Cleaning up...\n", id == mainthread ? 0 : id); - SDL_AtomicSet(&doterminate, 1); - for (i = 0; i < 6; ++i) - SDL_WaitThread(threads[i], NULL); - SDL_DestroyMutex(mutex); - exit(sig); -} - -int SDLCALL -Run(void *data) -{ - if (SDL_ThreadID() == mainthread) - signal(SIGTERM, closemutex); - while (!SDL_AtomicGet(&doterminate)) { - SDL_Log("Process %lu ready to work\n", SDL_ThreadID()); - if (SDL_LockMutex(mutex) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError()); - exit(1); - } - SDL_Log("Process %lu, working!\n", SDL_ThreadID()); - SDL_Delay(1 * 1000); - SDL_Log("Process %lu, done!\n", SDL_ThreadID()); - if (SDL_UnlockMutex(mutex) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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 && SDL_AtomicGet(&doterminate)) { - SDL_Log("Process %lu: raising SIGTERM\n", SDL_ThreadID()); - raise(SIGTERM); - } - return (0); -} - -int -main(int argc, char *argv[]) -{ - int i; - int maxproc = 6; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(0) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); - exit(1); - } - atexit(SDL_Quit_Wrapper); - - SDL_AtomicSet(&doterminate, 0); - - if ((mutex = SDL_CreateMutex()) == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError()); - exit(1); - } - - mainthread = SDL_ThreadID(); - SDL_Log("Main thread: %lu\n", mainthread); - atexit(printid); - for (i = 0; i < maxproc; ++i) { - char name[64]; - SDL_snprintf(name, sizeof (name), "Worker%d", i); - if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL) - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n"); - } - signal(SIGINT, terminate); - Run(NULL); - - return (0); /* Never reached */ -} diff --git a/3rdparty/SDL2/test/testmessage.c b/3rdparty/SDL2/test/testmessage.c deleted file mode 100644 index 91968c322c8..00000000000 --- a/3rdparty/SDL2/test/testmessage.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple test of the SDL MessageBox API */ - -#include <stdio.h> -#include <stdlib.h> -#include <signal.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 int -button_messagebox(void *eventNumber) -{ - const SDL_MessageBoxButtonData buttons[] = { - { - SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, - 0, - "OK" - },{ - SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, - 1, - "Cancel" - }, - }; - - SDL_MessageBoxData data = { - SDL_MESSAGEBOX_INFORMATION, - NULL, /* no parent window */ - "Custom MessageBox", - "This is a custom messagebox", - 2, - buttons, - NULL /* Default color scheme */ - }; - - int button = -1; - int success = 0; - if (eventNumber) { - data.message = "This is a custom messagebox from a background thread."; - } - - success = SDL_ShowMessageBox(&data, &button); - if (success == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); - if (eventNumber) { - SDL_UserEvent event; - event.type = (intptr_t)eventNumber; - SDL_PushEvent((SDL_Event*)&event); - return 1; - } else { - quit(2); - } - } - SDL_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel" : "OK"); - - if (eventNumber) { - SDL_UserEvent event; - event.type = (intptr_t)eventNumber; - SDL_PushEvent((SDL_Event*)&event); - } - - return 0; -} - -int -main(int argc, char *argv[]) -{ - int success; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Simple MessageBox", - "This is a simple error MessageBox", - NULL); - if (success == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); - quit(1); - } - - success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Simple MessageBox", - "This is a simple MessageBox with a newline:\r\nHello world!", - NULL); - if (success == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); - quit(1); - } - - /* Google says this is Traditional Chinese for "beef with broccoli" */ - success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "UTF-8 Simple MessageBox", - "Unicode text: '牛肉西蘭花' ...", - NULL); - if (success == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); - quit(1); - } - - /* Google says this is Traditional Chinese for "beef with broccoli" */ - success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "UTF-8 Simple MessageBox", - "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'", - NULL); - if (success == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); - quit(1); - } - - /* Google says this is Traditional Chinese for "beef with broccoli" */ - success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "牛肉西蘭花", - "Unicode text in the title.", - NULL); - if (success == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); - quit(1); - } - - button_messagebox(NULL); - - /* Test showing a message box from a background thread. - - On Mac OS X, the video subsystem needs to be initialized for this - to work, since the message box events are dispatched by the Cocoa - subsystem on the main thread. - */ - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError()); - return (1); - } - { - int status = 0; - SDL_Event event; - intptr_t eventNumber = SDL_RegisterEvents(1); - SDL_Thread* thread = SDL_CreateThread(&button_messagebox, "MessageBox", (void*)eventNumber); - - while (SDL_WaitEvent(&event)) - { - if (event.type == eventNumber) { - break; - } - } - - SDL_WaitThread(thread, &status); - - SDL_Log("Message box thread return %i\n", status); - } - - /* Test showing a message box with a parent window */ - { - SDL_Event event; - SDL_Window *window = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); - - success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Simple MessageBox", - "This is a simple error MessageBox with a parent window", - window); - if (success == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); - quit(1); - } - - while (SDL_WaitEvent(&event)) - { - if (event.type == SDL_QUIT || event.type == SDL_KEYUP) { - break; - } - } - } - - SDL_Quit(); - return (0); -} diff --git a/3rdparty/SDL2/test/testmultiaudio.c b/3rdparty/SDL2/test/testmultiaudio.c deleted file mode 100644 index 1b07ba9fc73..00000000000 --- a/3rdparty/SDL2/test/testmultiaudio.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include "SDL.h" - -#include <stdio.h> /* for fflush() and stdout */ - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -static SDL_AudioSpec spec; -static Uint8 *sound = NULL; /* Pointer to wave data */ -static Uint32 soundlen = 0; /* Length of wave data */ - -typedef struct -{ - SDL_AudioDeviceID dev; - int soundpos; - SDL_atomic_t done; -} callback_data; - -callback_data cbd[64]; - -void SDLCALL -play_through_once(void *arg, Uint8 * stream, int len) -{ - callback_data *cbd = (callback_data *) arg; - Uint8 *waveptr = sound + cbd->soundpos; - int waveleft = soundlen - cbd->soundpos; - int cpy = len; - if (cpy > waveleft) - cpy = waveleft; - - SDL_memcpy(stream, waveptr, cpy); - len -= cpy; - cbd->soundpos += cpy; - if (len > 0) { - stream += cpy; - SDL_memset(stream, spec.silence, len); - SDL_AtomicSet(&cbd->done, 1); - } -} - -void -loop() -{ - if (SDL_AtomicGet(&cbd[0].done)) { -#ifdef __EMSCRIPTEN__ - emscripten_cancel_main_loop(); -#endif - SDL_PauseAudioDevice(cbd[0].dev, 1); - SDL_CloseAudioDevice(cbd[0].dev); - SDL_FreeWAV(sound); - SDL_Quit(); - } -} - -static void -test_multi_audio(int devcount) -{ - int keep_going = 1; - int i; - -#ifdef __ANDROID__ - SDL_Event event; - - /* Create a Window to get fully initialized event processing for testing pause on Android. */ - SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0); -#endif - - if (devcount > 64) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n", - devcount); - devcount = 64; - } - - spec.callback = play_through_once; - - for (i = 0; i < devcount; i++) { - const char *devname = SDL_GetAudioDeviceName(i, 0); - SDL_Log("playing on device #%d: ('%s')...", i, devname); - fflush(stdout); - - SDL_memset(&cbd[0], '\0', sizeof(callback_data)); - spec.userdata = &cbd[0]; - cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0); - if (cbd[0].dev == 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError()); - } else { - SDL_PauseAudioDevice(cbd[0].dev, 0); -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!SDL_AtomicGet(&cbd[0].done)) { - #ifdef __ANDROID__ - /* Empty queue, some application events would prevent pause. */ - while (SDL_PollEvent(&event)){} - #endif - SDL_Delay(100); - } - SDL_PauseAudioDevice(cbd[0].dev, 1); -#endif - SDL_Log("done.\n"); - SDL_CloseAudioDevice(cbd[0].dev); - } - } - - SDL_memset(cbd, '\0', sizeof(cbd)); - - SDL_Log("playing on all devices...\n"); - for (i = 0; i < devcount; i++) { - const char *devname = SDL_GetAudioDeviceName(i, 0); - spec.userdata = &cbd[i]; - cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0); - if (cbd[i].dev == 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError()); - } - } - - for (i = 0; i < devcount; i++) { - if (cbd[i].dev) { - SDL_PauseAudioDevice(cbd[i].dev, 0); - } - } - - while (keep_going) { - keep_going = 0; - for (i = 0; i < devcount; i++) { - if ((cbd[i].dev) && (!SDL_AtomicGet(&cbd[i].done))) { - keep_going = 1; - } - } - #ifdef __ANDROID__ - /* Empty queue, some application events would prevent pause. */ - while (SDL_PollEvent(&event)){} - #endif - - SDL_Delay(100); - } - -#ifndef __EMSCRIPTEN__ - for (i = 0; i < devcount; i++) { - if (cbd[i].dev) { - SDL_PauseAudioDevice(cbd[i].dev, 1); - SDL_CloseAudioDevice(cbd[i].dev); - } - } - - SDL_Log("All done!\n"); -#endif -} - - -int -main(int argc, char **argv) -{ - int devcount = 0; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_AUDIO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); - - devcount = SDL_GetNumAudioDevices(0); - if (devcount < 1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n"); - } else { - if (argv[1] == NULL) { - argv[1] = "sample.wav"; - } - - /* Load the wave file into memory */ - if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], - SDL_GetError()); - } else { - test_multi_audio(devcount); - SDL_FreeWAV(sound); - } - } - - SDL_Quit(); - return 0; -} diff --git a/3rdparty/SDL2/test/testnative.c b/3rdparty/SDL2/test/testnative.c deleted file mode 100644 index 049c4c83e91..00000000000 --- a/3rdparty/SDL2/test/testnative.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple program: Create a native window and attach an SDL renderer */ - -#include <stdio.h> -#include <stdlib.h> /* for srand() */ -#include <time.h> /* for time() */ - -#include "testnative.h" - -#define WINDOW_W 640 -#define WINDOW_H 480 -#define NUM_SPRITES 100 -#define MAX_SPEED 1 - -static NativeWindowFactory *factories[] = { -#ifdef TEST_NATIVE_WINDOWS - &WindowsWindowFactory, -#endif -#ifdef TEST_NATIVE_X11 - &X11WindowFactory, -#endif -#ifdef TEST_NATIVE_COCOA - &CocoaWindowFactory, -#endif - NULL -}; -static NativeWindowFactory *factory = NULL; -static void *native_window; -static SDL_Rect *positions, *velocities; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDL_VideoQuit(); - if (native_window) { - factory->DestroyNativeWindow(native_window); - } - exit(rc); -} - -SDL_Texture * -LoadSprite(SDL_Renderer *renderer, char *file) -{ - SDL_Surface *temp; - SDL_Texture *sprite; - - /* Load the sprite image */ - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); - return 0; - } - - /* Set transparent pixel as the pixel at (0,0) */ - if (temp->format->palette) { - SDL_SetColorKey(temp, 1, *(Uint8 *) temp->pixels); - } - - /* Create textures from the image */ - sprite = SDL_CreateTextureFromSurface(renderer, temp); - if (!sprite) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - SDL_FreeSurface(temp); - return 0; - } - SDL_FreeSurface(temp); - - /* We're ready to roll. :) */ - return sprite; -} - -void -MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) -{ - int sprite_w, sprite_h; - int i; - SDL_Rect viewport; - SDL_Rect *position, *velocity; - - /* Query the sizes */ - SDL_RenderGetViewport(renderer, &viewport); - SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h); - - /* Draw a gray background */ - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - - /* Move the sprite, bounce at the wall, and draw */ - for (i = 0; i < NUM_SPRITES; ++i) { - position = &positions[i]; - velocity = &velocities[i]; - position->x += velocity->x; - if ((position->x < 0) || (position->x >= (viewport.w - sprite_w))) { - velocity->x = -velocity->x; - position->x += velocity->x; - } - position->y += velocity->y; - if ((position->y < 0) || (position->y >= (viewport.h - sprite_h))) { - velocity->y = -velocity->y; - position->y += velocity->y; - } - - /* Blit the sprite onto the screen */ - SDL_RenderCopy(renderer, sprite, NULL, position); - } - - /* Update the screen! */ - SDL_RenderPresent(renderer); -} - -int -main(int argc, char *argv[]) -{ - int i, done; - const char *driver; - SDL_Window *window; - SDL_Renderer *renderer; - SDL_Texture *sprite; - int window_w, window_h; - int sprite_w, sprite_h; - SDL_Event event; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_VideoInit(NULL) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n", - SDL_GetError()); - exit(1); - } - driver = SDL_GetCurrentVideoDriver(); - - /* Find a native window driver and create a native window */ - for (i = 0; factories[i]; ++i) { - if (SDL_strcmp(driver, factories[i]->tag) == 0) { - factory = factories[i]; - break; - } - } - if (!factory) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n", - driver); - quit(2); - } - SDL_Log("Creating native window for %s driver\n", driver); - native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H); - if (!native_window) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n"); - quit(3); - } - window = SDL_CreateWindowFrom(native_window); - if (!window) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError()); - quit(4); - } - SDL_SetWindowTitle(window, "SDL Native Window Test"); - - /* Create the renderer */ - renderer = SDL_CreateRenderer(window, -1, 0); - if (!renderer) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); - quit(5); - } - - /* Clear the window, load the sprite and go! */ - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - - sprite = LoadSprite(renderer, "icon.bmp"); - if (!sprite) { - quit(6); - } - - /* Allocate memory for the sprite info */ - SDL_GetWindowSize(window, &window_w, &window_h); - SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h); - positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); - velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); - if (!positions || !velocities) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); - quit(2); - } - srand(time(NULL)); - for (i = 0; i < NUM_SPRITES; ++i) { - positions[i].x = rand() % (window_w - sprite_w); - positions[i].y = rand() % (window_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; - } - } - - /* Main render loop */ - done = 0; - while (!done) { - /* Check for events */ - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_WINDOWEVENT: - switch (event.window.event) { - case SDL_WINDOWEVENT_EXPOSED: - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - break; - } - break; - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - MoveSprites(renderer, sprite); - } - - quit(0); - - return 0; /* to prevent compiler warning */ -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testnative.h b/3rdparty/SDL2/test/testnative.h deleted file mode 100644 index ed2bf7e52c0..00000000000 --- a/3rdparty/SDL2/test/testnative.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Definitions for platform dependent windowing functions to test SDL - integration with native windows -*/ - -#include "SDL.h" - -/* This header includes all the necessary system headers for native windows */ -#include "SDL_syswm.h" - -typedef struct -{ - const char *tag; - void *(*CreateNativeWindow) (int w, int h); - void (*DestroyNativeWindow) (void *window); -} NativeWindowFactory; - -#ifdef SDL_VIDEO_DRIVER_WINDOWS -#define TEST_NATIVE_WINDOWS -extern NativeWindowFactory WindowsWindowFactory; -#endif - -#ifdef SDL_VIDEO_DRIVER_X11 -#define TEST_NATIVE_X11 -extern NativeWindowFactory X11WindowFactory; -#endif - -#ifdef SDL_VIDEO_DRIVER_COCOA -/* Actually, we don't really do this, since it involves adding Objective C - support to the build system, which is a little tricky. You can uncomment - it manually though and link testnativecocoa.m into the test application. -*/ -#define TEST_NATIVE_COCOA -extern NativeWindowFactory CocoaWindowFactory; -#endif diff --git a/3rdparty/SDL2/test/testnativecocoa.m b/3rdparty/SDL2/test/testnativecocoa.m deleted file mode 100644 index 030607d6654..00000000000 --- a/3rdparty/SDL2/test/testnativecocoa.m +++ /dev/null @@ -1,51 +0,0 @@ - -#include "testnative.h" - -#ifdef TEST_NATIVE_COCOA - -#include <Cocoa/Cocoa.h> - -static void *CreateWindowCocoa(int w, int h); -static void DestroyWindowCocoa(void *window); - -NativeWindowFactory CocoaWindowFactory = { - "cocoa", - CreateWindowCocoa, - DestroyWindowCocoa -}; - -static void *CreateWindowCocoa(int w, int h) -{ - NSAutoreleasePool *pool; - NSWindow *nswindow; - NSRect rect; - unsigned int style; - - pool = [[NSAutoreleasePool alloc] init]; - - rect.origin.x = 0; - rect.origin.y = 0; - rect.size.width = w; - rect.size.height = h; - rect.origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - rect.origin.y - rect.size.height; - - style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask); - - nswindow = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE]; - [nswindow makeKeyAndOrderFront:nil]; - - [pool release]; - - return nswindow; -} - -static void DestroyWindowCocoa(void *window) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSWindow *nswindow = (NSWindow *)window; - - [nswindow close]; - [pool release]; -} - -#endif diff --git a/3rdparty/SDL2/test/testnativew32.c b/3rdparty/SDL2/test/testnativew32.c deleted file mode 100644 index aaea267d260..00000000000 --- a/3rdparty/SDL2/test/testnativew32.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include "testnative.h" - -#ifdef TEST_NATIVE_WINDOWS - -static void *CreateWindowNative(int w, int h); -static void DestroyWindowNative(void *window); - -NativeWindowFactory WindowsWindowFactory = { - "windows", - CreateWindowNative, - DestroyWindowNative -}; - -LRESULT CALLBACK -WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_CLOSE: - DestroyWindow(hwnd); - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return 0; -} - -static void * -CreateWindowNative(int w, int h) -{ - HWND hwnd; - WNDCLASS wc; - - wc.style = 0; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = GetModuleHandle(NULL); - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); - wc.lpszMenuName = NULL; - wc.lpszClassName = "SDL Test"; - - if (!RegisterClass(&wc)) { - MessageBox(NULL, "Window Registration Failed!", "Error!", - MB_ICONEXCLAMATION | MB_OK); - return 0; - } - - hwnd = - CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, - CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), - NULL); - if (hwnd == NULL) { - MessageBox(NULL, "Window Creation Failed!", "Error!", - MB_ICONEXCLAMATION | MB_OK); - return 0; - } - - ShowWindow(hwnd, SW_SHOW); - - return hwnd; -} - -static void -DestroyWindowNative(void *window) -{ - DestroyWindow((HWND) window); -} - -#endif diff --git a/3rdparty/SDL2/test/testnativex11.c b/3rdparty/SDL2/test/testnativex11.c deleted file mode 100644 index 69fa37bbf19..00000000000 --- a/3rdparty/SDL2/test/testnativex11.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include "testnative.h" - -#ifdef TEST_NATIVE_X11 - -static void *CreateWindowX11(int w, int h); -static void DestroyWindowX11(void *window); - -NativeWindowFactory X11WindowFactory = { - "x11", - CreateWindowX11, - DestroyWindowX11 -}; - -static Display *dpy; - -static void * -CreateWindowX11(int w, int h) -{ - Window window = 0; - - dpy = XOpenDisplay(NULL); - if (dpy) { - window = - XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0, - 0); - XMapRaised(dpy, window); - XSync(dpy, False); - } - return (void *) window; -} - -static void -DestroyWindowX11(void *window) -{ - if (dpy) { - XDestroyWindow(dpy, (Window) window); - XCloseDisplay(dpy); - } -} - -#endif diff --git a/3rdparty/SDL2/test/testoverlay2.c b/3rdparty/SDL2/test/testoverlay2.c deleted file mode 100644 index 453f0f443a3..00000000000 --- a/3rdparty/SDL2/test/testoverlay2.c +++ /dev/null @@ -1,511 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/******************************************************************************** - * * - * 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> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#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} -}; - -Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE*2]; -SDL_Texture *MooseTexture; -SDL_Rect displayrect; -int window_w; -int window_h; -SDL_Window *window; -SDL_Renderer *renderer; -int paused = 0; -int i; -SDL_bool done = SDL_FALSE; -Uint32 pixel_format = SDL_PIXELFORMAT_YV12; -int fpsdelay; - -/* 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] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]); - yuv[1] = 128; - yuv[2] = 128; -#else - yuv[0] = (int)(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] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]); - yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128); - yuv[2] = (int)((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(Uint8 *rgb, Uint8 *out, int w, int h, - int monochrome, int luminance) -{ - int x, y; - int yuv[3]; - Uint8 *op[3]; - - op[0] = out; - op[1] = op[0] + w*h; - op[2] = op[1] + w*h/4; - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - RGBtoYUV(rgb, yuv, monochrome, luminance); - *(op[0]++) = yuv[0]; - if (x % 2 == 0 && y % 2 == 0) { - *(op[1]++) = yuv[2]; - *(op[2]++) = yuv[1]; - } - rgb += 3; - } - } -} - -void -ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h, - int monochrome, int luminance) -{ - int x, y; - int yuv[3]; - Uint8 *op[2]; - - op[0] = out; - op[1] = op[0] + w*h; - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - RGBtoYUV(rgb, yuv, monochrome, luminance); - *(op[0]++) = yuv[0]; - if (x % 2 == 0 && y % 2 == 0) { - *(op[1]++) = yuv[1]; - *(op[1]++) = yuv[2]; - } - rgb += 3; - } - } -} - -static void -PrintUsage(char *argv0) -{ - SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0); - SDL_Log("\n"); - SDL_Log("Where 'arg' is any of the following options:\n"); - SDL_Log("\n"); - SDL_Log(" -fps <frames per second>\n"); - SDL_Log(" -nodelay\n"); - SDL_Log(" -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); - SDL_Log(" -scale <scale factor> (initial scale of the overlay)\n"); - SDL_Log(" -help (shows this help)\n"); - SDL_Log("\n"); - SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n"); - SDL_Log("\n"); -} - -void -loop() -{ - SDL_Event event; - - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_WINDOWEVENT: - if (event.window.event == SDL_WINDOWEVENT_RESIZED) { - SDL_RenderSetViewport(renderer, NULL); - displayrect.w = window_w = event.window.data1; - displayrect.h = window_h = event.window.data2; - } - break; - case SDL_MOUSEBUTTONDOWN: - displayrect.x = event.button.x - window_w / 2; - displayrect.y = event.button.y - window_h / 2; - break; - case SDL_MOUSEMOTION: - if (event.motion.state) { - displayrect.x = event.motion.x - window_w / 2; - displayrect.y = event.motion.y - window_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: - done = SDL_TRUE; - break; - } - } - -#ifndef __EMSCRIPTEN__ - SDL_Delay(fpsdelay); -#endif - - if (!paused) { - i = (i + 1) % MOOSEFRAMES_COUNT; - - SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*SDL_BYTESPERPIXEL(pixel_format)); - } - SDL_RenderClear(renderer); - SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect); - SDL_RenderPresent(renderer); - -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char **argv) -{ - Uint8 *RawMooseData; - SDL_RWops *handle; - SDL_Window *window; - int j; - int fps = 12; - int fpsdelay; - int nodelay = 0; -#ifdef TEST_NV12 - Uint32 pixel_format = SDL_PIXELFORMAT_NV12; -#else - Uint32 pixel_format = SDL_PIXELFORMAT_YV12; -#endif - int scale = 5; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); - quit(10); - } - if ((fps < 0) || (fps > 1000)) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -fps option must be in range from 1 to 1000, default is 12.\n"); - quit(10); - } - argv += 2; - argc -= 2; - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); - quit(10); - } - } else if (strcmp(argv[1], "-nodelay") == 0) { - nodelay = 1; - argv += 1; - argc -= 1; - } else if (strcmp(argv[1], "-scale") == 0) { - if (argv[2]) { - scale = atoi(argv[2]); - if (scale == 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -scale option requires an argument [from 1 to 50], default is 5.\n"); - quit(10); - } - if ((scale < 0) || (scale > 50)) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "The -scale option must be in range from 1 to 50, default is 5.\n"); - quit(10); - } - argv += 2; - argc -= 2; - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "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 { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]); - quit(10); - } - break; - } - - RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); - if (RawMooseData == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); - free(RawMooseData); - quit(2); - } - - SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT); - - SDL_RWclose(handle); - - /* Create the window and renderer */ - window_w = MOOSEPIC_W * scale; - window_h = MOOSEPIC_H * scale; - window = SDL_CreateWindow("Happy Moose", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - window_w, window_h, - SDL_WINDOW_RESIZABLE); - if (!window) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); - free(RawMooseData); - quit(4); - } - - renderer = SDL_CreateRenderer(window, -1, 0); - if (!renderer) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); - free(RawMooseData); - quit(4); - } - - MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); - if (!MooseTexture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); - free(RawMooseData); - quit(5); - } - /* Uncomment this to check vertex color with a YUV texture */ - /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */ - - for (i = 0; i < MOOSEFRAMES_COUNT; i++) { - Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3]; - Uint8 *rgb; - Uint8 *frame; - - rgb = MooseFrameRGB; - frame = RawMooseData + i * MOOSEFRAME_SIZE; - for (j = 0; j < MOOSEFRAME_SIZE; ++j) { - rgb[0] = MooseColors[frame[j]].r; - rgb[1] = MooseColors[frame[j]].g; - rgb[2] = MooseColors[frame[j]].b; - rgb += 3; - } - switch (pixel_format) { - case SDL_PIXELFORMAT_YV12: - ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100); - break; - case SDL_PIXELFORMAT_NV12: - ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100); - break; - default: - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n"); - break; - } - } - - free(RawMooseData); - - /* set the start frame */ - i = 0; - if (nodelay) { - fpsdelay = 0; - } else { - fpsdelay = 1000 / fps; - } - - displayrect.x = 0; - displayrect.y = 0; - displayrect.w = window_w; - displayrect.h = window_h; - - /* Ignore key up events, they don't even get filtered */ - SDL_EventState(SDL_KEYUP, SDL_IGNORE); - - /* Loop, waiting for QUIT or RESIZE */ -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, nodelay ? 0 : fps, 1); -#else - while (!done) { - loop(); - } -#endif - - SDL_DestroyRenderer(renderer); - quit(0); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testplatform.c b/3rdparty/SDL2/test/testplatform.c deleted file mode 100644 index 14acac4b110..00000000000 --- a/3rdparty/SDL2/test/testplatform.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include <stdio.h> - -#include "SDL.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) - SDL_Log("sizeof(Uint8) != 1, instead = %u\n", - (unsigned int)sizeof(Uint8)); - ++error; - } - if (badsize(sizeof(Uint16), 2)) { - if (verbose) - SDL_Log("sizeof(Uint16) != 2, instead = %u\n", - (unsigned int)sizeof(Uint16)); - ++error; - } - if (badsize(sizeof(Uint32), 4)) { - if (verbose) - SDL_Log("sizeof(Uint32) != 4, instead = %u\n", - (unsigned int)sizeof(Uint32)); - ++error; - } - if (badsize(sizeof(Uint64), 8)) { - if (verbose) - SDL_Log("sizeof(Uint64) != 8, instead = %u\n", - (unsigned int)sizeof(Uint64)); - ++error; - } - if (verbose && !error) - SDL_Log("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; - Uint64 value64, swapped64; - - value64 = 0xEFBEADDE; - value64 <<= 32; - value64 |= 0xCDAB3412; - swapped64 = 0x1234ABCD; - swapped64 <<= 32; - swapped64 |= 0xDEADBEEF; - - if (verbose) { - SDL_Log("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) { - SDL_Log("Actually a %s endian machine!\n", - (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); - } - ++error; - } - if (verbose) { - SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16, - SDL_Swap16(value16)); - } - if (SDL_Swap16(value16) != swapped16) { - if (verbose) { - SDL_Log("16 bit value swapped incorrectly!\n"); - } - ++error; - } - if (verbose) { - SDL_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32, - SDL_Swap32(value32)); - } - if (SDL_Swap32(value32) != swapped32) { - if (verbose) { - SDL_Log("32 bit value swapped incorrectly!\n"); - } - ++error; - } - if (verbose) { - SDL_Log("Value 64 = 0x%"SDL_PRIX64", swapped = 0x%"SDL_PRIX64"\n", value64, - SDL_Swap64(value64)); - } - if (SDL_Swap64(value64) != swapped64) { - if (verbose) { - SDL_Log("64 bit value swapped incorrectly!\n"); - } - ++error; - } - return (error ? 1 : 0); -} - - -int -TestCPUInfo(SDL_bool verbose) -{ - if (verbose) { - SDL_Log("CPU count: %d\n", SDL_GetCPUCount()); - SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize()); - SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); - SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); - SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); - SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected"); - SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); - SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); - SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); - SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); - SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); - SDL_Log("AVX %s\n", SDL_HasAVX()? "detected" : "not detected"); - SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM()); - } - return (0); -} - -int -TestAssertions(SDL_bool verbose) -{ - SDL_assert(1); - SDL_assert_release(1); - SDL_assert_paranoid(1); - SDL_assert(0 || 1); - SDL_assert_release(0 || 1); - SDL_assert_paranoid(0 || 1); - -#if 0 /* enable this to test assertion failures. */ - SDL_assert_release(1 == 2); - SDL_assert_release(5 < 4); - SDL_assert_release(0 && "This is a test"); -#endif - - { - const SDL_AssertData *item = SDL_GetAssertionReport(); - while (item) { - SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", - item->condition, item->function, item->filename, - item->linenum, item->trigger_count, - item->always_ignore ? "yes" : "no"); - item = item->next; - } - } - return (0); -} - -int -main(int argc, char *argv[]) -{ - SDL_bool verbose = SDL_TRUE; - int status = 0; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) { - verbose = SDL_FALSE; - } - if (verbose) { - SDL_Log("This system is running %s\n", SDL_GetPlatform()); - } - - status += TestTypes(verbose); - status += TestEndian(verbose); - status += TestCPUInfo(verbose); - status += TestAssertions(verbose); - - return status; -} diff --git a/3rdparty/SDL2/test/testpower.c b/3rdparty/SDL2/test/testpower.c deleted file mode 100644 index 300d21a24d0..00000000000 --- a/3rdparty/SDL2/test/testpower.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple test of power subsystem. */ - -#include <stdio.h> -#include "SDL.h" - -static void -report_power(void) -{ - int seconds, percent; - const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent); - char *statestr = NULL; - - SDL_Log("SDL-reported power info...\n"); - switch (state) { - case SDL_POWERSTATE_UNKNOWN: - statestr = "Unknown"; - break; - case SDL_POWERSTATE_ON_BATTERY: - statestr = "On battery"; - break; - case SDL_POWERSTATE_NO_BATTERY: - statestr = "No battery"; - break; - case SDL_POWERSTATE_CHARGING: - statestr = "Charging"; - break; - case SDL_POWERSTATE_CHARGED: - statestr = "Charged"; - break; - default: - statestr = "!!API ERROR!!"; - break; - } - - SDL_Log("State: %s\n", statestr); - - if (percent == -1) { - SDL_Log("Percent left: unknown\n"); - } else { - SDL_Log("Percent left: %d%%\n", percent); - } - - if (seconds == -1) { - SDL_Log("Time left: unknown\n"); - } else { - SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60), - (int) (seconds % 60)); - } -} - - -int -main(int argc, char *argv[]) -{ - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_Init(0) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); - return 1; - } - - report_power(); - - SDL_Quit(); - return 0; -} - -/* end of testpower.c ... */ diff --git a/3rdparty/SDL2/test/testqsort.c b/3rdparty/SDL2/test/testqsort.c deleted file mode 100644 index 48659f307fc..00000000000 --- a/3rdparty/SDL2/test/testqsort.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include "SDL_test.h" - -static int -num_compare(const void *_a, const void *_b) -{ - const int a = *((const int *) _a); - const int b = *((const int *) _b); - return (a < b) ? -1 : ((a > b) ? 1 : 0); -} - -static void -test_sort(const char *desc, int *nums, const int arraylen) -{ - int i; - int prev; - - SDL_Log("test: %s arraylen=%d", desc, arraylen); - - SDL_qsort(nums, arraylen, sizeof (nums[0]), num_compare); - - prev = nums[0]; - for (i = 1; i < arraylen; i++) { - const int val = nums[i]; - if (val < prev) { - SDL_Log("sort is broken!"); - return; - } - prev = val; - } -} - -int -main(int argc, char *argv[]) -{ - static int nums[1024 * 100]; - static const int itervals[] = { SDL_arraysize(nums), 12 }; - int iteration; - SDLTest_RandomContext rndctx; - - if (argc > 1) - { - int success; - Uint64 seed = 0; - if (argv[1][0] == '0' && argv[1][1] == 'x') - success = SDL_sscanf(argv[1] + 2, "%llx", &seed); - else - success = SDL_sscanf(argv[1], "%llu", &seed); - if (!success) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n"); - return 1; - } - if (seed <= 0xffffffff) - { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Seed must be equal or greater than 0x100000000.\n"); - return 1; - } - SDLTest_RandomInit(&rndctx, (unsigned int)(seed >> 32), (unsigned int)(seed & 0xffffffff)); - } - else - { - SDLTest_RandomInitTime(&rndctx); - } - SDL_Log("Using random seed 0x%08x%08x\n", rndctx.x, rndctx.c); - - for (iteration = 0; iteration < SDL_arraysize(itervals); iteration++) { - const int arraylen = itervals[iteration]; - int i; - - for (i = 0; i < arraylen; i++) { - nums[i] = i; - } - test_sort("already sorted", nums, arraylen); - - for (i = 0; i < arraylen; i++) { - nums[i] = i; - } - nums[arraylen-1] = -1; - test_sort("already sorted except last element", nums, arraylen); - - for (i = 0; i < arraylen; i++) { - nums[i] = (arraylen-1) - i; - } - test_sort("reverse sorted", nums, arraylen); - - for (i = 0; i < arraylen; i++) { - nums[i] = SDLTest_RandomInt(&rndctx); - } - test_sort("random sorted", nums, arraylen); - } - - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ - diff --git a/3rdparty/SDL2/test/testrelative.c b/3rdparty/SDL2/test/testrelative.c deleted file mode 100644 index 59d23f63880..00000000000 --- a/3rdparty/SDL2/test/testrelative.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple program: Test relative mouse motion */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#include "SDL_test_common.h" - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -static SDLTest_CommonState *state; -int i, done; -SDL_Rect rect; -SDL_Event event; - -static void -DrawRects(SDL_Renderer * renderer, SDL_Rect * rect) -{ - SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); - SDL_RenderFillRect(renderer, rect); -} - -static void -loop(){ - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - switch(event.type) { - case SDL_MOUSEMOTION: - { - rect.x += event.motion.xrel; - rect.y += event.motion.yrel; - } - break; - } - } - for (i = 0; i < state->num_windows; ++i) { - SDL_Rect viewport; - SDL_Renderer *renderer = state->renderers[i]; - if (state->windows[i] == NULL) - continue; - SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); - SDL_RenderClear(renderer); - - /* Wrap the cursor rectangle at the screen edges to keep it visible */ - SDL_RenderGetViewport(renderer, &viewport); - if (rect.x < viewport.x) rect.x += viewport.w; - if (rect.y < viewport.y) rect.y += viewport.h; - if (rect.x > viewport.x + viewport.w) rect.x -= viewport.w; - if (rect.y > viewport.y + viewport.h) rect.y -= viewport.h; - - DrawRects(renderer, &rect); - - SDL_RenderPresent(renderer); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc; ++i) { - SDLTest_CommonArg(state, i); - } - if (!SDLTest_CommonInit(state)) { - return 2; - } - - /* Create the windows and initialize the renderers */ - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE); - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - - srand((unsigned int)time(NULL)); - if(SDL_SetRelativeMouseMode(SDL_TRUE) < 0) { - return 3; - }; - - rect.x = DEFAULT_WINDOW_WIDTH / 2; - rect.y = DEFAULT_WINDOW_HEIGHT / 2; - rect.w = 10; - rect.h = 10; - /* Main render loop */ - done = 0; -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - SDLTest_CommonQuit(state); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testrendercopyex.c b/3rdparty/SDL2/test/testrendercopyex.c deleted file mode 100644 index e34890245bd..00000000000 --- a/3rdparty/SDL2/test/testrendercopyex.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple program: Move N sprites around on the screen as fast as possible */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - - -static SDLTest_CommonState *state; - -typedef struct { - SDL_Window *window; - SDL_Renderer *renderer; - SDL_Texture *background; - SDL_Texture *sprite; - SDL_Rect sprite_rect; - int scale_direction; -} DrawState; - -DrawState *drawstates; -int done; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -SDL_Texture * -LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent) -{ - SDL_Surface *temp; - SDL_Texture *texture; - - /* Load the sprite image */ - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); - return NULL; - } - - /* Set transparent pixel as the pixel at (0,0) */ - if (transparent) { - if (temp->format->palette) { - SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels); - } else { - switch (temp->format->BitsPerPixel) { - case 15: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint16 *) temp->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels); - break; - case 24: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint32 *) temp->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels); - break; - } - } - } - - /* Create textures from the image */ - texture = SDL_CreateTextureFromSurface(renderer, temp); - if (!texture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - SDL_FreeSurface(temp); - return NULL; - } - SDL_FreeSurface(temp); - - /* We're ready to roll. :) */ - return texture; -} - -void -Draw(DrawState *s) -{ - SDL_Rect viewport; - SDL_Texture *target; - SDL_Point *center=NULL; - SDL_Point origin = {0,0}; - - SDL_RenderGetViewport(s->renderer, &viewport); - - target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h); - SDL_SetRenderTarget(s->renderer, target); - - /* Draw the background */ - SDL_RenderCopy(s->renderer, s->background, NULL, NULL); - - /* Scale and draw the sprite */ - s->sprite_rect.w += s->scale_direction; - s->sprite_rect.h += s->scale_direction; - if (s->scale_direction > 0) { - center = &origin; - if (s->sprite_rect.w >= viewport.w || s->sprite_rect.h >= viewport.h) { - s->scale_direction = -1; - } - } else { - if (s->sprite_rect.w <= 1 || s->sprite_rect.h <= 1) { - s->scale_direction = 1; - } - } - s->sprite_rect.x = (viewport.w - s->sprite_rect.w) / 2; - s->sprite_rect.y = (viewport.h - s->sprite_rect.h) / 2; - - SDL_RenderCopyEx(s->renderer, s->sprite, NULL, &s->sprite_rect, (double)s->sprite_rect.w, center, (SDL_RendererFlip)s->scale_direction); - - SDL_SetRenderTarget(s->renderer, NULL); - SDL_RenderCopy(s->renderer, target, NULL, NULL); - SDL_DestroyTexture(target); - - /* Update the screen! */ - SDL_RenderPresent(s->renderer); - /* SDL_Delay(10); */ -} - -void loop() -{ - int i; - SDL_Event event; - - /* Check for events */ - - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - for (i = 0; i < state->num_windows; ++i) { - if (state->windows[i] == NULL) - continue; - Draw(&drawstates[i]); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - int frames; - Uint32 then, now; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - return 1; - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - drawstates = SDL_stack_alloc(DrawState, state->num_windows); - for (i = 0; i < state->num_windows; ++i) { - DrawState *drawstate = &drawstates[i]; - - drawstate->window = state->windows[i]; - drawstate->renderer = state->renderers[i]; - drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE); - drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE); - if (!drawstate->sprite || !drawstate->background) { - quit(2); - } - SDL_QueryTexture(drawstate->sprite, NULL, NULL, - &drawstate->sprite_rect.w, &drawstate->sprite_rect.h); - drawstate->scale_direction = 1; - } - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - ++frames; - loop(); - } -#endif - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } - - SDL_stack_free(drawstates); - - quit(0); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testrendertarget.c b/3rdparty/SDL2/test/testrendertarget.c deleted file mode 100644 index c5e1dce05b7..00000000000 --- a/3rdparty/SDL2/test/testrendertarget.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple program: Move N sprites around on the screen as fast as possible */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - - -static SDLTest_CommonState *state; - -typedef struct { - SDL_Window *window; - SDL_Renderer *renderer; - SDL_Texture *background; - SDL_Texture *sprite; - SDL_Rect sprite_rect; - int scale_direction; -} DrawState; - -DrawState *drawstates; -int done; -SDL_bool test_composite = SDL_FALSE; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -SDL_Texture * -LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) -{ - SDL_Surface *temp; - SDL_Texture *texture; - - /* Load the sprite image */ - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); - return NULL; - } - - /* Set transparent pixel as the pixel at (0,0) */ - if (transparent) { - if (temp->format->palette) { - SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels); - } else { - switch (temp->format->BitsPerPixel) { - case 15: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint16 *) temp->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels); - break; - case 24: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint32 *) temp->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels); - break; - } - } - } - - /* Create textures from the image */ - texture = SDL_CreateTextureFromSurface(renderer, temp); - if (!texture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - SDL_FreeSurface(temp); - return NULL; - } - SDL_FreeSurface(temp); - - /* We're ready to roll. :) */ - return texture; -} - -SDL_bool -DrawComposite(DrawState *s) -{ - SDL_Rect viewport, R; - SDL_Texture *target; - - static SDL_bool blend_tested = SDL_FALSE; - if (!blend_tested) { - SDL_Texture *A, *B; - Uint32 P; - - A = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, 1, 1); - SDL_SetTextureBlendMode(A, SDL_BLENDMODE_BLEND); - - B = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, 1, 1); - SDL_SetTextureBlendMode(B, SDL_BLENDMODE_BLEND); - - SDL_SetRenderTarget(s->renderer, A); - SDL_SetRenderDrawColor(s->renderer, 0x00, 0x00, 0x00, 0x80); - SDL_RenderFillRect(s->renderer, NULL); - - SDL_SetRenderTarget(s->renderer, B); - SDL_SetRenderDrawColor(s->renderer, 0x00, 0x00, 0x00, 0x00); - SDL_RenderFillRect(s->renderer, NULL); - SDL_RenderCopy(s->renderer, A, NULL, NULL); - SDL_RenderReadPixels(s->renderer, NULL, SDL_PIXELFORMAT_ARGB8888, &P, sizeof(P)); - - SDL_Log("Blended pixel: 0x%8.8X\n", P); - - SDL_DestroyTexture(A); - SDL_DestroyTexture(B); - blend_tested = SDL_TRUE; - } - - SDL_RenderGetViewport(s->renderer, &viewport); - - target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h); - SDL_SetTextureBlendMode(target, SDL_BLENDMODE_BLEND); - SDL_SetRenderTarget(s->renderer, target); - - /* Draw the background. - This is solid black so when the sprite is copied to it, any per-pixel alpha will be blended through. - */ - SDL_SetRenderDrawColor(s->renderer, 0x00, 0x00, 0x00, 0x00); - SDL_RenderFillRect(s->renderer, NULL); - - /* Scale and draw the sprite */ - s->sprite_rect.w += s->scale_direction; - s->sprite_rect.h += s->scale_direction; - if (s->scale_direction > 0) { - if (s->sprite_rect.w >= viewport.w || s->sprite_rect.h >= viewport.h) { - s->scale_direction = -1; - } - } else { - if (s->sprite_rect.w <= 1 || s->sprite_rect.h <= 1) { - s->scale_direction = 1; - } - } - s->sprite_rect.x = (viewport.w - s->sprite_rect.w) / 2; - s->sprite_rect.y = (viewport.h - s->sprite_rect.h) / 2; - - SDL_RenderCopy(s->renderer, s->sprite, NULL, &s->sprite_rect); - - SDL_SetRenderTarget(s->renderer, NULL); - SDL_RenderCopy(s->renderer, s->background, NULL, NULL); - - SDL_SetRenderDrawBlendMode(s->renderer, SDL_BLENDMODE_BLEND); - SDL_SetRenderDrawColor(s->renderer, 0xff, 0x00, 0x00, 0x80); - R.x = 0; - R.y = 0; - R.w = 100; - R.h = 100; - SDL_RenderFillRect(s->renderer, &R); - SDL_SetRenderDrawBlendMode(s->renderer, SDL_BLENDMODE_NONE); - - SDL_RenderCopy(s->renderer, target, NULL, NULL); - SDL_DestroyTexture(target); - - /* Update the screen! */ - SDL_RenderPresent(s->renderer); - return SDL_TRUE; -} - -SDL_bool -Draw(DrawState *s) -{ - SDL_Rect viewport; - SDL_Texture *target; - - SDL_RenderGetViewport(s->renderer, &viewport); - - target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h); - if (!target) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError()); - return SDL_FALSE; - } - SDL_SetRenderTarget(s->renderer, target); - - /* Draw the background */ - SDL_RenderCopy(s->renderer, s->background, NULL, NULL); - - /* Scale and draw the sprite */ - s->sprite_rect.w += s->scale_direction; - s->sprite_rect.h += s->scale_direction; - if (s->scale_direction > 0) { - if (s->sprite_rect.w >= viewport.w || s->sprite_rect.h >= viewport.h) { - s->scale_direction = -1; - } - } else { - if (s->sprite_rect.w <= 1 || s->sprite_rect.h <= 1) { - s->scale_direction = 1; - } - } - s->sprite_rect.x = (viewport.w - s->sprite_rect.w) / 2; - s->sprite_rect.y = (viewport.h - s->sprite_rect.h) / 2; - - SDL_RenderCopy(s->renderer, s->sprite, NULL, &s->sprite_rect); - - SDL_SetRenderTarget(s->renderer, NULL); - SDL_RenderCopy(s->renderer, target, NULL, NULL); - SDL_DestroyTexture(target); - - /* Update the screen! */ - SDL_RenderPresent(s->renderer); - return SDL_TRUE; -} - -void -loop() -{ - int i; - SDL_Event event; - - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - for (i = 0; i < state->num_windows; ++i) { - if (state->windows[i] == NULL) - continue; - if (test_composite) { - if (!DrawComposite(&drawstates[i])) done = 1; - } else { - if (!Draw(&drawstates[i])) done = 1; - } - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - int frames; - Uint32 then, now; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - if (SDL_strcasecmp(argv[i], "--composite") == 0) { - test_composite = SDL_TRUE; - consumed = 1; - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--composite]\n", - argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - drawstates = SDL_stack_alloc(DrawState, state->num_windows); - for (i = 0; i < state->num_windows; ++i) { - DrawState *drawstate = &drawstates[i]; - - drawstate->window = state->windows[i]; - drawstate->renderer = state->renderers[i]; - if (test_composite) { - drawstate->sprite = LoadTexture(drawstate->renderer, "icon-alpha.bmp", SDL_TRUE); - } else { - drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE); - } - drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE); - if (!drawstate->sprite || !drawstate->background) { - quit(2); - } - SDL_QueryTexture(drawstate->sprite, NULL, NULL, - &drawstate->sprite_rect.w, &drawstate->sprite_rect.h); - drawstate->scale_direction = 1; - } - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - ++frames; - loop(); - } -#endif - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } - - SDL_stack_free(drawstates); - - quit(0); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testresample.c b/3rdparty/SDL2/test/testresample.c deleted file mode 100644 index 0e92bbe11a6..00000000000 --- a/3rdparty/SDL2/test/testresample.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include "SDL.h" - -int -main(int argc, char **argv) -{ - SDL_AudioSpec spec; - SDL_AudioCVT cvt; - Uint32 len = 0; - Uint8 *data = NULL; - int cvtfreq = 0; - int bitsize = 0; - int blockalign = 0; - int avgbytes = 0; - SDL_RWops *io = NULL; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (argc != 4) { - SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]); - return 1; - } - - cvtfreq = SDL_atoi(argv[3]); - - if (SDL_Init(SDL_INIT_AUDIO) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); - return 2; - } - - if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError()); - SDL_Quit(); - return 3; - } - - if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq, - spec.format, spec.channels, cvtfreq) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError()); - SDL_FreeWAV(data); - SDL_Quit(); - return 4; - } - - cvt.len = len; - cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult); - if (cvt.buf == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n"); - SDL_FreeWAV(data); - SDL_Quit(); - return 5; - } - SDL_memcpy(cvt.buf, data, len); - - if (SDL_ConvertAudio(&cvt) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError()); - SDL_free(cvt.buf); - SDL_FreeWAV(data); - SDL_Quit(); - return 6; - } - - /* write out a WAV header... */ - io = SDL_RWFromFile(argv[2], "wb"); - if (io == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError()); - SDL_free(cvt.buf); - SDL_FreeWAV(data); - SDL_Quit(); - return 7; - } - - bitsize = SDL_AUDIO_BITSIZE(spec.format); - blockalign = (bitsize / 8) * spec.channels; - avgbytes = cvtfreq * blockalign; - - SDL_WriteLE32(io, 0x46464952); /* RIFF */ - SDL_WriteLE32(io, len * cvt.len_mult + 36); - SDL_WriteLE32(io, 0x45564157); /* WAVE */ - SDL_WriteLE32(io, 0x20746D66); /* fmt */ - SDL_WriteLE32(io, 16); /* chunk size */ - SDL_WriteLE16(io, 1); /* uncompressed */ - SDL_WriteLE16(io, spec.channels); /* channels */ - SDL_WriteLE32(io, cvtfreq); /* sample rate */ - SDL_WriteLE32(io, avgbytes); /* average bytes per second */ - SDL_WriteLE16(io, blockalign); /* block align */ - SDL_WriteLE16(io, bitsize); /* significant bits per sample */ - SDL_WriteLE32(io, 0x61746164); /* data */ - SDL_WriteLE32(io, cvt.len_cvt); /* size */ - SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1); - - if (SDL_RWclose(io) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError()); - SDL_free(cvt.buf); - SDL_FreeWAV(data); - SDL_Quit(); - return 8; - } /* if */ - - SDL_free(cvt.buf); - SDL_FreeWAV(data); - SDL_Quit(); - return 0; -} /* main */ - -/* end of testresample.c ... */ diff --git a/3rdparty/SDL2/test/testrumble.c b/3rdparty/SDL2/test/testrumble.c deleted file mode 100644 index ea7466d2daa..00000000000 --- a/3rdparty/SDL2/test/testrumble.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* -Copyright (c) 2011, Edgar Simo Serra -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Simple Directmedia Layer (SDL) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * includes - */ -#include <stdlib.h> -#include <string.h> /* strstr */ -#include <ctype.h> /* isdigit */ - -#include "SDL.h" - -#ifndef SDL_HAPTIC_DISABLED - -static SDL_Haptic *haptic; - - -/** - * @brief The entry point of this force feedback demo. - * @param[in] argc Number of arguments. - * @param[in] argv Array of argc arguments. - */ -int -main(int argc, char **argv) -{ - int i; - char *name; - int index; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - name = NULL; - index = -1; - if (argc > 1) { - name = argv[1]; - if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { - SDL_Log("USAGE: %s [device]\n" - "If device is a two-digit number it'll use it as an index, otherwise\n" - "it'll use it as if it were part of the device's name.\n", - argv[0]); - return 0; - } - - i = strlen(name); - if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) { - index = atoi(name); - name = NULL; - } - } - - /* Initialize the force feedbackness */ - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | - SDL_INIT_HAPTIC); - SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); - if (SDL_NumHaptics() > 0) { - /* We'll just use index or the first force feedback device found */ - if (name == NULL) { - i = (index != -1) ? index : 0; - } - /* Try to find matching device */ - else { - for (i = 0; i < SDL_NumHaptics(); i++) { - if (strstr(SDL_HapticName(i), name) != NULL) - break; - } - - if (i >= SDL_NumHaptics()) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", - name); - return 1; - } - } - - haptic = SDL_HapticOpen(i); - if (haptic == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", - SDL_GetError()); - return 1; - } - SDL_Log("Device: %s\n", SDL_HapticName(i)); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n"); - return 1; - } - - /* We only want force feedback errors. */ - SDL_ClearError(); - - if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n"); - return 1; - } - if (SDL_HapticRumbleInit(haptic) != 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError()); - return 1; - } - SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n"); - if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); - return 1; - } - SDL_Delay(2000); - SDL_Log("Stopping rumble.\n"); - SDL_HapticRumbleStop(haptic); - SDL_Delay(2000); - SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n"); - if (SDL_HapticRumblePlay(haptic, 0.3f, 5000) != 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); - return 1; - } - SDL_Delay(2000); - - /* Quit */ - if (haptic != NULL) - SDL_HapticClose(haptic); - SDL_Quit(); - - return 0; -} - -#else - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n"); - exit(1); -} - -#endif diff --git a/3rdparty/SDL2/test/testscale.c b/3rdparty/SDL2/test/testscale.c deleted file mode 100644 index 9f5fdbff100..00000000000 --- a/3rdparty/SDL2/test/testscale.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple program: Move N sprites around on the screen as fast as possible */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - -#define WINDOW_WIDTH 640 -#define WINDOW_HEIGHT 480 - -static SDLTest_CommonState *state; - -typedef struct { - SDL_Window *window; - SDL_Renderer *renderer; - SDL_Texture *background; - SDL_Texture *sprite; - SDL_Rect sprite_rect; - int scale_direction; -} DrawState; - -DrawState *drawstates; -int done; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -SDL_Texture * -LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) -{ - SDL_Surface *temp; - SDL_Texture *texture; - - /* Load the sprite image */ - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); - return NULL; - } - - /* Set transparent pixel as the pixel at (0,0) */ - if (transparent) { - if (temp->format->palette) { - SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels); - } else { - switch (temp->format->BitsPerPixel) { - case 15: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint16 *) temp->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels); - break; - case 24: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint32 *) temp->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels); - break; - } - } - } - - /* Create textures from the image */ - texture = SDL_CreateTextureFromSurface(renderer, temp); - if (!texture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - SDL_FreeSurface(temp); - return NULL; - } - SDL_FreeSurface(temp); - - /* We're ready to roll. :) */ - return texture; -} - -void -Draw(DrawState *s) -{ - SDL_Rect viewport; - - SDL_RenderGetViewport(s->renderer, &viewport); - - /* Draw the background */ - SDL_RenderCopy(s->renderer, s->background, NULL, NULL); - - /* Scale and draw the sprite */ - s->sprite_rect.w += s->scale_direction; - s->sprite_rect.h += s->scale_direction; - if (s->scale_direction > 0) { - if (s->sprite_rect.w >= viewport.w || s->sprite_rect.h >= viewport.h) { - s->scale_direction = -1; - } - } else { - if (s->sprite_rect.w <= 1 || s->sprite_rect.h <= 1) { - s->scale_direction = 1; - } - } - s->sprite_rect.x = (viewport.w - s->sprite_rect.w) / 2; - s->sprite_rect.y = (viewport.h - s->sprite_rect.h) / 2; - - SDL_RenderCopy(s->renderer, s->sprite, NULL, &s->sprite_rect); - - /* Update the screen! */ - SDL_RenderPresent(s->renderer); -} - -void -loop() -{ - int i; - SDL_Event event; - - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - for (i = 0; i < state->num_windows; ++i) { - if (state->windows[i] == NULL) - continue; - Draw(&drawstates[i]); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - int frames; - Uint32 then, now; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - return 1; - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - drawstates = SDL_stack_alloc(DrawState, state->num_windows); - for (i = 0; i < state->num_windows; ++i) { - DrawState *drawstate = &drawstates[i]; - - drawstate->window = state->windows[i]; - drawstate->renderer = state->renderers[i]; - drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE); - drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE); - if (!drawstate->sprite || !drawstate->background) { - quit(2); - } - SDL_QueryTexture(drawstate->sprite, NULL, NULL, - &drawstate->sprite_rect.w, &drawstate->sprite_rect.h); - drawstate->scale_direction = 1; - } - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - ++frames; - loop(); - } -#endif - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } - - SDL_stack_free(drawstates); - - quit(0); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testsem.c b/3rdparty/SDL2/test/testsem.c deleted file mode 100644 index b8d3b274918..00000000000 --- a/3rdparty/SDL2/test/testsem.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple test of the SDL semaphore code */ - -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> - -#include "SDL.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); - SDL_Log("Thread number %d has got the semaphore (value = %d)!\n", - threadnum, SDL_SemValue(sem)); - SDL_Delay(200); - SDL_SemPost(sem); - SDL_Log("Thread number %d has released the semaphore (value = %d)!\n", - threadnum, SDL_SemValue(sem)); - SDL_Delay(1); /* For the scheduler */ - } - SDL_Log("Thread number %d exiting.\n", threadnum); - return 0; -} - -static void -killed(int sig) -{ - alive = 0; -} - -static void -TestWaitTimeout(void) -{ - Uint32 start_ticks; - Uint32 end_ticks; - Uint32 duration; - int retval; - - sem = SDL_CreateSemaphore(0); - SDL_Log("Waiting 2 seconds on semaphore\n"); - - start_ticks = SDL_GetTicks(); - retval = SDL_SemWaitTimeout(sem, 2000); - end_ticks = SDL_GetTicks(); - - duration = end_ticks - start_ticks; - - /* Accept a little offset in the effective wait */ - if (duration > 1900 && duration < 2050) - SDL_Log("Wait done.\n"); - else - SDL_Log("Wait took %d milliseconds\n", duration); - - /* Check to make sure the return value indicates timed out */ - if (retval != SDL_MUTEX_TIMEDOUT) - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT); -} - -int -main(int argc, char **argv) -{ - SDL_Thread *threads[NUM_THREADS]; - uintptr_t i; - int init_sem; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (argc < 2) { - SDL_Log("Usage: %s init_value\n", argv[0]); - return (1); - } - - /* Load the SDL library */ - if (SDL_Init(0) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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); - - SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS, - init_sem); - /* Create all the threads */ - for (i = 0; i < NUM_THREADS; ++i) { - char name[64]; - SDL_snprintf(name, sizeof (name), "Thread%u", (unsigned int) i); - threads[i] = SDL_CreateThread(ThreadFunc, name, (void *) i); - } - - /* Wait 10 seconds */ - SDL_Delay(10 * 1000); - - /* Wait for all threads to finish */ - SDL_Log("Waiting for threads to finish\n"); - alive = 0; - for (i = 0; i < NUM_THREADS; ++i) { - SDL_WaitThread(threads[i], NULL); - } - SDL_Log("Finished waiting for threads\n"); - - SDL_DestroySemaphore(sem); - - TestWaitTimeout(); - - SDL_Quit(); - return (0); -} diff --git a/3rdparty/SDL2/test/testshader.c b/3rdparty/SDL2/test/testshader.c deleted file mode 100644 index fc6da29875b..00000000000 --- a/3rdparty/SDL2/test/testshader.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* This is a simple example of using GLSL shaders with SDL */ - -#include "SDL.h" - -#ifdef HAVE_OPENGL - -#include "SDL_opengl.h" - - -static SDL_bool shaders_supported; -static int current_shader = 0; - -enum { - SHADER_COLOR, - SHADER_TEXTURE, - SHADER_TEXCOORDS, - NUM_SHADERS -}; - -typedef struct { - GLhandleARB program; - GLhandleARB vert_shader; - GLhandleARB frag_shader; - const char *vert_source; - const char *frag_source; -} ShaderData; - -static ShaderData shaders[NUM_SHADERS] = { - - /* SHADER_COLOR */ - { 0, 0, 0, - /* vertex shader */ -"varying vec4 v_color;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" -" v_color = gl_Color;\n" -"}", - /* fragment shader */ -"varying vec4 v_color;\n" -"\n" -"void main()\n" -"{\n" -" gl_FragColor = v_color;\n" -"}" - }, - - /* SHADER_TEXTURE */ - { 0, 0, 0, - /* vertex shader */ -"varying vec4 v_color;\n" -"varying vec2 v_texCoord;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" -" v_color = gl_Color;\n" -" v_texCoord = vec2(gl_MultiTexCoord0);\n" -"}", - /* fragment shader */ -"varying vec4 v_color;\n" -"varying vec2 v_texCoord;\n" -"uniform sampler2D tex0;\n" -"\n" -"void main()\n" -"{\n" -" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n" -"}" - }, - - /* SHADER_TEXCOORDS */ - { 0, 0, 0, - /* vertex shader */ -"varying vec2 v_texCoord;\n" -"\n" -"void main()\n" -"{\n" -" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" -" v_texCoord = vec2(gl_MultiTexCoord0);\n" -"}", - /* fragment shader */ -"varying vec2 v_texCoord;\n" -"\n" -"void main()\n" -"{\n" -" vec4 color;\n" -" vec2 delta;\n" -" float dist;\n" -"\n" -" delta = vec2(0.5, 0.5) - v_texCoord;\n" -" dist = dot(delta, delta);\n" -"\n" -" color.r = v_texCoord.x;\n" -" color.g = v_texCoord.x * v_texCoord.y;\n" -" color.b = v_texCoord.y;\n" -" color.a = 1.0 - (dist * 4.0);\n" -" gl_FragColor = color;\n" -"}" - }, -}; - -static PFNGLATTACHOBJECTARBPROC glAttachObjectARB; -static PFNGLCOMPILESHADERARBPROC glCompileShaderARB; -static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; -static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; -static PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; -static PFNGLGETINFOLOGARBPROC glGetInfoLogARB; -static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; -static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB; -static PFNGLLINKPROGRAMARBPROC glLinkProgramARB; -static PFNGLSHADERSOURCEARBPROC glShaderSourceARB; -static PFNGLUNIFORM1IARBPROC glUniform1iARB; -static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; - -static SDL_bool CompileShader(GLhandleARB shader, const char *source) -{ - GLint status; - - glShaderSourceARB(shader, 1, &source, NULL); - glCompileShaderARB(shader); - glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); - if (status == 0) { - GLint length; - char *info; - - glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - info = SDL_stack_alloc(char, length+1); - glGetInfoLogARB(shader, length, NULL, info); - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info); - SDL_stack_free(info); - - return SDL_FALSE; - } else { - return SDL_TRUE; - } -} - -static SDL_bool CompileShaderProgram(ShaderData *data) -{ - const int num_tmus_bound = 4; - int i; - GLint location; - - glGetError(); - - /* Create one program object to rule them all */ - data->program = glCreateProgramObjectARB(); - - /* Create the vertex shader */ - data->vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); - if (!CompileShader(data->vert_shader, data->vert_source)) { - return SDL_FALSE; - } - - /* Create the fragment shader */ - data->frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); - if (!CompileShader(data->frag_shader, data->frag_source)) { - return SDL_FALSE; - } - - /* ... and in the darkness bind them */ - glAttachObjectARB(data->program, data->vert_shader); - glAttachObjectARB(data->program, data->frag_shader); - glLinkProgramARB(data->program); - - /* Set up some uniform variables */ - glUseProgramObjectARB(data->program); - for (i = 0; i < num_tmus_bound; ++i) { - char tex_name[5]; - SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i); - location = glGetUniformLocationARB(data->program, tex_name); - if (location >= 0) { - glUniform1iARB(location, i); - } - } - glUseProgramObjectARB(0); - - return (glGetError() == GL_NO_ERROR) ? SDL_TRUE : SDL_FALSE; -} - -static void DestroyShaderProgram(ShaderData *data) -{ - if (shaders_supported) { - glDeleteObjectARB(data->vert_shader); - glDeleteObjectARB(data->frag_shader); - glDeleteObjectARB(data->program); - } -} - -static SDL_bool InitShaders() -{ - int i; - - /* Check for shader support */ - shaders_supported = SDL_FALSE; - if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") && - SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && - SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") && - SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) { - glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); - glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); - glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); - glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); - glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); - glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); - glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); - glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); - glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); - glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); - glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); - glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); - if (glAttachObjectARB && - glCompileShaderARB && - glCreateProgramObjectARB && - glCreateShaderObjectARB && - glDeleteObjectARB && - glGetInfoLogARB && - glGetObjectParameterivARB && - glGetUniformLocationARB && - glLinkProgramARB && - glShaderSourceARB && - glUniform1iARB && - glUseProgramObjectARB) { - shaders_supported = SDL_TRUE; - } - } - - if (!shaders_supported) { - return SDL_FALSE; - } - - /* Compile all the shaders */ - for (i = 0; i < NUM_SHADERS; ++i) { - if (!CompileShaderProgram(&shaders[i])) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n"); - return SDL_FALSE; - } - } - - /* We're done! */ - return SDL_TRUE; -} - -static void QuitShaders() -{ - int i; - - for (i = 0; i < NUM_SHADERS; ++i) { - DestroyShaderProgram(&shaders[i]); - } -} - -/* 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; - SDL_BlendMode saved_mode; - - /* 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 */ - SDL_GetSurfaceBlendMode(surface, &saved_mode); - SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); - - /* 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 */ - SDL_SetSurfaceBlendMode(surface, saved_mode); - - /* 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; -} - -/* A general OpenGL initialization function. Sets all of the initial parameters. */ -void InitGL(int Width, int Height) /* We call this right after our OpenGL window is created. */ -{ - GLdouble aspect; - - glViewport(0, 0, Width, Height); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); /* This Will Clear The Background Color To Black */ - glClearDepth(1.0); /* Enables Clearing Of The Depth Buffer */ - glDepthFunc(GL_LESS); /* The Type Of Depth Test To Do */ - glEnable(GL_DEPTH_TEST); /* Enables Depth Testing */ - glShadeModel(GL_SMOOTH); /* Enables Smooth Color Shading */ - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); /* Reset The Projection Matrix */ - - aspect = (GLdouble)Width / Height; - glOrtho(-3.0, 3.0, -3.0 / aspect, 3.0 / aspect, 0.0, 1.0); - - glMatrixMode(GL_MODELVIEW); -} - -/* The main drawing function. */ -void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord) -{ - /* Texture coordinate lookup, to make it simple */ - enum { - MINX, - MINY, - MAXX, - MAXY - }; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Clear The Screen And The Depth Buffer */ - glLoadIdentity(); /* Reset The View */ - - glTranslatef(-1.5f,0.0f,0.0f); /* Move Left 1.5 Units */ - - /* draw a triangle (in smooth coloring mode) */ - glBegin(GL_POLYGON); /* start drawing a polygon */ - glColor3f(1.0f,0.0f,0.0f); /* Set The Color To Red */ - glVertex3f( 0.0f, 1.0f, 0.0f); /* Top */ - glColor3f(0.0f,1.0f,0.0f); /* Set The Color To Green */ - glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ - glColor3f(0.0f,0.0f,1.0f); /* Set The Color To Blue */ - glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ - glEnd(); /* we're done with the polygon (smooth color interpolation) */ - - glTranslatef(3.0f,0.0f,0.0f); /* Move Right 3 Units */ - - /* Enable blending */ - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - /* draw a textured square (quadrilateral) */ - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture); - glColor3f(1.0f,1.0f,1.0f); - if (shaders_supported) { - glUseProgramObjectARB(shaders[current_shader].program); - } - - glBegin(GL_QUADS); /* start drawing a polygon (4 sided) */ - glTexCoord2f(texcoord[MINX], texcoord[MINY]); - glVertex3f(-1.0f, 1.0f, 0.0f); /* Top Left */ - glTexCoord2f(texcoord[MAXX], texcoord[MINY]); - glVertex3f( 1.0f, 1.0f, 0.0f); /* Top Right */ - glTexCoord2f(texcoord[MAXX], texcoord[MAXY]); - glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ - glTexCoord2f(texcoord[MINX], texcoord[MAXY]); - glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ - glEnd(); /* done with the polygon */ - - if (shaders_supported) { - glUseProgramObjectARB(0); - } - glDisable(GL_TEXTURE_2D); - - /* swap buffers to display, since we're double buffered. */ - SDL_GL_SwapWindow(window); -} - -int main(int argc, char **argv) -{ - int done; - SDL_Window *window; - SDL_Surface *surface; - GLuint texture; - GLfloat texcoords[4]; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Initialize SDL for video output */ - if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - - /* Create a 640x480 OpenGL screen */ - window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL ); - if ( !window ) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); - SDL_Quit(); - exit(2); - } - - if ( !SDL_GL_CreateContext(window)) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError()); - SDL_Quit(); - exit(2); - } - - surface = SDL_LoadBMP("icon.bmp"); - if ( ! surface ) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError()); - SDL_Quit(); - exit(3); - } - texture = SDL_GL_LoadTexture(surface, texcoords); - SDL_FreeSurface(surface); - - /* Loop, drawing and checking events */ - InitGL(640, 480); - if (InitShaders()) { - SDL_Log("Shaders supported, press SPACE to cycle them.\n"); - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n"); - } - done = 0; - while ( ! done ) { - DrawGLScene(window, texture, texcoords); - - /* This could go in a separate function */ - { SDL_Event event; - while ( SDL_PollEvent(&event) ) { - if ( event.type == SDL_QUIT ) { - done = 1; - } - if ( event.type == SDL_KEYDOWN ) { - if ( event.key.keysym.sym == SDLK_SPACE ) { - current_shader = (current_shader + 1) % NUM_SHADERS; - } - if ( event.key.keysym.sym == SDLK_ESCAPE ) { - done = 1; - } - } - } - } - } - QuitShaders(); - SDL_Quit(); - return 1; -} - -#else /* HAVE_OPENGL */ - -int -main(int argc, char *argv[]) -{ - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); - return 1; -} - -#endif /* HAVE_OPENGL */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testshape.c b/3rdparty/SDL2/test/testshape.c deleted file mode 100644 index 476fac21ec3..00000000000 --- a/3rdparty/SDL2/test/testshape.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -#include <stdlib.h> -#include <math.h> -#include <stdio.h> -#include "SDL.h" -#include "SDL_shape.h" - -#define SHAPED_WINDOW_X 150 -#define SHAPED_WINDOW_Y 150 -#define SHAPED_WINDOW_DIMENSION 640 - -typedef struct LoadedPicture { - SDL_Surface *surface; - SDL_Texture *texture; - SDL_WindowShapeMode mode; - const char* name; -} LoadedPicture; - -void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensions) -{ - /* Clear render-target to blue. */ - SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff); - SDL_RenderClear(renderer); - - /* Render the texture. */ - SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions); - - SDL_RenderPresent(renderer); -} - -int main(int argc,char** argv) -{ - Uint8 num_pictures; - LoadedPicture* pictures; - int i, j; - SDL_PixelFormat* format = NULL; - SDL_Window *window; - SDL_Renderer *renderer; - SDL_Color black = {0,0,0,0xff}; - SDL_Event event; - int event_pending = 0; - int should_exit = 0; - unsigned int current_picture; - int button_down; - Uint32 pixelFormat = 0; - int access = 0; - SDL_Rect texture_dimensions; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if(argc < 2) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument."); - exit(-1); - } - - if(SDL_VideoInit(NULL) == -1) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video."); - exit(-2); - } - - num_pictures = argc - 1; - pictures = (LoadedPicture *)SDL_malloc(sizeof(LoadedPicture)*num_pictures); - if (!pictures) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate memory."); - exit(1); - } - for(i=0;i<num_pictures;i++) - pictures[i].surface = NULL; - for(i=0;i<num_pictures;i++) { - pictures[i].surface = SDL_LoadBMP(argv[i+1]); - pictures[i].name = argv[i+1]; - if(pictures[i].surface == NULL) { - j = 0; - for(j=0;j<num_pictures;j++) - SDL_FreeSurface(pictures[j].surface); - SDL_free(pictures); - SDL_VideoQuit(); - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file: %s", argv[i+1]); - exit(-3); - } - - format = pictures[i].surface->format; - if(SDL_ISPIXELFORMAT_ALPHA(format->format)) { - pictures[i].mode.mode = ShapeModeBinarizeAlpha; - pictures[i].mode.parameters.binarizationCutoff = 255; - } - else { - pictures[i].mode.mode = ShapeModeColorKey; - pictures[i].mode.parameters.colorKey = black; - } - } - - window = SDL_CreateShapedWindow("SDL_Shape test", - SHAPED_WINDOW_X, SHAPED_WINDOW_Y, - SHAPED_WINDOW_DIMENSION,SHAPED_WINDOW_DIMENSION, - 0); - SDL_SetWindowPosition(window, SHAPED_WINDOW_X, SHAPED_WINDOW_Y); - if(window == NULL) { - for(i=0;i<num_pictures;i++) - SDL_FreeSurface(pictures[i].surface); - SDL_free(pictures); - SDL_VideoQuit(); - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape."); - exit(-4); - } - renderer = SDL_CreateRenderer(window,-1,0); - if (!renderer) { - SDL_DestroyWindow(window); - for(i=0;i<num_pictures;i++) - SDL_FreeSurface(pictures[i].surface); - SDL_free(pictures); - SDL_VideoQuit(); - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window."); - exit(-5); - } - - for(i=0;i<num_pictures;i++) - pictures[i].texture = NULL; - for(i=0;i<num_pictures;i++) { - pictures[i].texture = SDL_CreateTextureFromSurface(renderer,pictures[i].surface); - if(pictures[i].texture == NULL) { - j = 0; - for(j=0;j<num_pictures;i++) - if(pictures[i].texture != NULL) - SDL_DestroyTexture(pictures[i].texture); - for(i=0;i<num_pictures;i++) - SDL_FreeSurface(pictures[i].surface); - SDL_free(pictures); - SDL_DestroyRenderer(renderer); - SDL_DestroyWindow(window); - SDL_VideoQuit(); - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape."); - exit(-6); - } - } - - event_pending = 0; - should_exit = 0; - event_pending = SDL_PollEvent(&event); - current_picture = 0; - button_down = 0; - texture_dimensions.h = 0; - texture_dimensions.w = 0; - texture_dimensions.x = 0; - texture_dimensions.y = 0; - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Changing to shaped bmp: %s", pictures[current_picture].name); - SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h); - SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h); - SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode); - while(should_exit == 0) { - event_pending = SDL_PollEvent(&event); - if(event_pending == 1) { - if(event.type == SDL_KEYDOWN) { - button_down = 1; - if(event.key.keysym.sym == SDLK_ESCAPE) { - should_exit = 1; - break; - } - } - if(button_down && event.type == SDL_KEYUP) { - button_down = 0; - current_picture += 1; - if(current_picture >= num_pictures) - current_picture = 0; - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Changing to shaped bmp: %s", pictures[current_picture].name); - SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h); - SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h); - SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode); - } - if(event.type == SDL_QUIT) - should_exit = 1; - event_pending = 0; - } - render(renderer,pictures[current_picture].texture,texture_dimensions); - SDL_Delay(10); - } - - /* Free the textures. */ - for(i=0;i<num_pictures;i++) - SDL_DestroyTexture(pictures[i].texture); - SDL_DestroyRenderer(renderer); - /* Destroy the window. */ - SDL_DestroyWindow(window); - /* Free the original surfaces backing the textures. */ - for(i=0;i<num_pictures;i++) - SDL_FreeSurface(pictures[i].surface); - SDL_free(pictures); - /* Call SDL_VideoQuit() before quitting. */ - SDL_VideoQuit(); - - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testsprite2.c b/3rdparty/SDL2/test/testsprite2.c deleted file mode 100644 index 7a33af30844..00000000000 --- a/3rdparty/SDL2/test/testsprite2.c +++ /dev/null @@ -1,401 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple program: Move N sprites around on the screen as fast as possible */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test.h" -#include "SDL_test_common.h" - -#define NUM_SPRITES 100 -#define MAX_SPEED 1 - -static SDLTest_CommonState *state; -static int num_sprites; -static SDL_Texture **sprites; -static SDL_bool cycle_color; -static SDL_bool cycle_alpha; -static int cycle_direction = 1; -static int current_alpha = 0; -static int current_color = 0; -static SDL_Rect *positions; -static SDL_Rect *velocities; -static int sprite_w, sprite_h; -static SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND; - -/* Number of iterations to move sprites - used for visual tests. */ -/* -1: infinite random moves (default); >=0: enables N deterministic moves */ -static int iterations = -1; - -int done; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDL_free(sprites); - SDL_free(positions); - SDL_free(velocities); - SDLTest_CommonQuit(state); - exit(rc); -} - -int -LoadSprite(const char *file) -{ - int i; - SDL_Surface *temp; - - /* Load the sprite image */ - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); - return (-1); - } - sprite_w = temp->w; - sprite_h = temp->h; - - /* Set transparent pixel as the pixel at (0,0) */ - if (temp->format->palette) { - SDL_SetColorKey(temp, 1, *(Uint8 *) temp->pixels); - } else { - switch (temp->format->BitsPerPixel) { - case 15: - SDL_SetColorKey(temp, 1, (*(Uint16 *) temp->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetColorKey(temp, 1, *(Uint16 *) temp->pixels); - break; - case 24: - SDL_SetColorKey(temp, 1, (*(Uint32 *) temp->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetColorKey(temp, 1, *(Uint32 *) temp->pixels); - break; - } - } - - /* Create textures from the image */ - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - sprites[i] = SDL_CreateTextureFromSurface(renderer, temp); - if (!sprites[i]) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - SDL_FreeSurface(temp); - return (-1); - } - SDL_SetTextureBlendMode(sprites[i], blendMode); - } - SDL_FreeSurface(temp); - - /* We're ready to roll. :) */ - return (0); -} - -void -MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) -{ - int i; - SDL_Rect viewport, temp; - SDL_Rect *position, *velocity; - - /* Query the sizes */ - SDL_RenderGetViewport(renderer, &viewport); - - /* Cycle the color and alpha, if desired */ - if (cycle_color) { - current_color += cycle_direction; - if (current_color < 0) { - current_color = 0; - cycle_direction = -cycle_direction; - } - if (current_color > 255) { - current_color = 255; - cycle_direction = -cycle_direction; - } - SDL_SetTextureColorMod(sprite, 255, (Uint8) current_color, - (Uint8) current_color); - } - if (cycle_alpha) { - current_alpha += cycle_direction; - if (current_alpha < 0) { - current_alpha = 0; - cycle_direction = -cycle_direction; - } - if (current_alpha > 255) { - current_alpha = 255; - cycle_direction = -cycle_direction; - } - SDL_SetTextureAlphaMod(sprite, (Uint8) current_alpha); - } - - /* Draw a gray background */ - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - - /* Test points */ - SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0x00, 0xFF); - SDL_RenderDrawPoint(renderer, 0, 0); - SDL_RenderDrawPoint(renderer, viewport.w-1, 0); - SDL_RenderDrawPoint(renderer, 0, viewport.h-1); - SDL_RenderDrawPoint(renderer, viewport.w-1, viewport.h-1); - - /* Test horizontal and vertical lines */ - SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF); - SDL_RenderDrawLine(renderer, 1, 0, viewport.w-2, 0); - SDL_RenderDrawLine(renderer, 1, viewport.h-1, viewport.w-2, viewport.h-1); - SDL_RenderDrawLine(renderer, 0, 1, 0, viewport.h-2); - SDL_RenderDrawLine(renderer, viewport.w-1, 1, viewport.w-1, viewport.h-2); - - /* Test fill and copy */ - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); - temp.x = 1; - temp.y = 1; - temp.w = sprite_w; - temp.h = sprite_h; - SDL_RenderFillRect(renderer, &temp); - SDL_RenderCopy(renderer, sprite, NULL, &temp); - temp.x = viewport.w-sprite_w-1; - temp.y = 1; - temp.w = sprite_w; - temp.h = sprite_h; - SDL_RenderFillRect(renderer, &temp); - SDL_RenderCopy(renderer, sprite, NULL, &temp); - temp.x = 1; - temp.y = viewport.h-sprite_h-1; - temp.w = sprite_w; - temp.h = sprite_h; - SDL_RenderFillRect(renderer, &temp); - SDL_RenderCopy(renderer, sprite, NULL, &temp); - temp.x = viewport.w-sprite_w-1; - temp.y = viewport.h-sprite_h-1; - temp.w = sprite_w; - temp.h = sprite_h; - SDL_RenderFillRect(renderer, &temp); - SDL_RenderCopy(renderer, sprite, NULL, &temp); - - /* Test diagonal lines */ - SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF); - SDL_RenderDrawLine(renderer, sprite_w, sprite_h, - viewport.w-sprite_w-2, viewport.h-sprite_h-2); - SDL_RenderDrawLine(renderer, viewport.w-sprite_w-2, sprite_h, - sprite_w, viewport.h-sprite_h-2); - - /* Conditionally move the sprites, bounce at the wall */ - if (iterations == -1 || iterations > 0) { - for (i = 0; i < num_sprites; ++i) { - position = &positions[i]; - velocity = &velocities[i]; - position->x += velocity->x; - if ((position->x < 0) || (position->x >= (viewport.w - sprite_w))) { - velocity->x = -velocity->x; - position->x += velocity->x; - } - position->y += velocity->y; - if ((position->y < 0) || (position->y >= (viewport.h - sprite_h))) { - velocity->y = -velocity->y; - position->y += velocity->y; - } - - } - - /* Countdown sprite-move iterations and disable color changes at iteration end - used for visual tests. */ - if (iterations > 0) { - iterations--; - if (iterations == 0) { - cycle_alpha = SDL_FALSE; - cycle_color = SDL_FALSE; - } - } - } - - /* Draw sprites */ - for (i = 0; i < num_sprites; ++i) { - position = &positions[i]; - - /* Blit the sprite onto the screen */ - SDL_RenderCopy(renderer, sprite, NULL, position); - } - - /* Update the screen! */ - SDL_RenderPresent(renderer); -} - -void -loop() -{ - int i; - SDL_Event event; - - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - for (i = 0; i < state->num_windows; ++i) { - if (state->windows[i] == NULL) - continue; - MoveSprites(state->renderers[i], sprites[i]); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - Uint32 then, now, frames; - Uint64 seed; - const char *icon = "icon.bmp"; - - /* Initialize parameters */ - num_sprites = NUM_SPRITES; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - if (SDL_strcasecmp(argv[i], "--blend") == 0) { - if (argv[i + 1]) { - if (SDL_strcasecmp(argv[i + 1], "none") == 0) { - blendMode = SDL_BLENDMODE_NONE; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { - blendMode = SDL_BLENDMODE_BLEND; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { - blendMode = SDL_BLENDMODE_ADD; - consumed = 2; - } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { - blendMode = SDL_BLENDMODE_MOD; - consumed = 2; - } - } - } else if (SDL_strcasecmp(argv[i], "--iterations") == 0) { - if (argv[i + 1]) { - iterations = SDL_atoi(argv[i + 1]); - if (iterations < -1) iterations = -1; - consumed = 2; - } - } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { - cycle_color = SDL_TRUE; - consumed = 1; - } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) { - cycle_alpha = SDL_TRUE; - consumed = 1; - } else if (SDL_isdigit(*argv[i])) { - num_sprites = SDL_atoi(argv[i]); - consumed = 1; - } else if (argv[i][0] != '-') { - icon = argv[i]; - consumed = 1; - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n", - argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - /* Create the windows, initialize the renderers, and load the textures */ - sprites = - (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); - if (!sprites) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); - quit(2); - } - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - if (LoadSprite(icon) < 0) { - quit(2); - } - - /* Allocate memory for the sprite info */ - positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); - velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); - if (!positions || !velocities) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); - quit(2); - } - - /* Position sprites and set their velocities using the fuzzer */ - if (iterations >= 0) { - /* Deterministic seed - used for visual tests */ - seed = (Uint64)iterations; - } else { - /* Pseudo-random seed generated from the time */ - seed = (Uint64)time(NULL); - } - SDLTest_FuzzerInit(seed); - for (i = 0; i < num_sprites; ++i) { - positions[i].x = SDLTest_RandomIntegerInRange(0, state->window_w - sprite_w); - positions[i].y = SDLTest_RandomIntegerInRange(0, state->window_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 = SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED); - velocities[i].y = SDLTest_RandomIntegerInRange(-MAX_SPEED, MAX_SPEED); - } - } - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - ++frames; - loop(); - } -#endif - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } - quit(0); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testspriteminimal.c b/3rdparty/SDL2/test/testspriteminimal.c deleted file mode 100644 index 05f97309c00..00000000000 --- a/3rdparty/SDL2/test/testspriteminimal.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple program: Move N sprites around on the screen as fast as possible */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL.h" - -#define WINDOW_WIDTH 640 -#define WINDOW_HEIGHT 480 -#define NUM_SPRITES 100 -#define MAX_SPEED 1 - -static SDL_Texture *sprite; -static SDL_Rect positions[NUM_SPRITES]; -static SDL_Rect velocities[NUM_SPRITES]; -static int sprite_w, sprite_h; - -SDL_Renderer *renderer; -int done; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - exit(rc); -} - -int -LoadSprite(char *file, SDL_Renderer *renderer) -{ - SDL_Surface *temp; - - /* Load the sprite image */ - temp = SDL_LoadBMP(file); - if (temp == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError()); - return (-1); - } - sprite_w = temp->w; - sprite_h = temp->h; - - /* Set transparent pixel as the pixel at (0,0) */ - if (temp->format->palette) { - SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels); - } else { - switch (temp->format->BitsPerPixel) { - case 15: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint16 *) temp->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels); - break; - case 24: - SDL_SetColorKey(temp, SDL_TRUE, - (*(Uint32 *) temp->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels); - break; - } - } - - /* Create textures from the image */ - sprite = SDL_CreateTextureFromSurface(renderer, temp); - if (!sprite) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); - SDL_FreeSurface(temp); - return (-1); - } - SDL_FreeSurface(temp); - - /* We're ready to roll. :) */ - return (0); -} - -void -MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) -{ - int i; - int window_w = WINDOW_WIDTH; - int window_h = WINDOW_HEIGHT; - SDL_Rect *position, *velocity; - - /* Draw a gray background */ - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - - /* Move the sprite, bounce at the wall, and draw */ - for (i = 0; i < NUM_SPRITES; ++i) { - position = &positions[i]; - velocity = &velocities[i]; - position->x += velocity->x; - if ((position->x < 0) || (position->x >= (window_w - sprite_w))) { - velocity->x = -velocity->x; - position->x += velocity->x; - } - position->y += velocity->y; - if ((position->y < 0) || (position->y >= (window_h - sprite_h))) { - velocity->y = -velocity->y; - position->y += velocity->y; - } - - /* Blit the sprite onto the screen */ - SDL_RenderCopy(renderer, sprite, NULL, position); - } - - /* Update the screen! */ - SDL_RenderPresent(renderer); -} - -void loop() -{ - SDL_Event event; - - /* Check for events */ - while (SDL_PollEvent(&event)) { - if (event.type == SDL_QUIT || event.type == SDL_KEYDOWN) { - done = 1; - } - } - MoveSprites(renderer, sprite); -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - SDL_Window *window; - int i; - - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_CreateWindowAndRenderer(WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer) < 0) { - quit(2); - } - - if (LoadSprite("icon.bmp", renderer) < 0) { - quit(2); - } - - /* Initialize the sprite positions */ - srand(time(NULL)); - for (i = 0; i < NUM_SPRITES; ++i) { - positions[i].x = rand() % (WINDOW_WIDTH - sprite_w); - positions[i].y = rand() % (WINDOW_HEIGHT - 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; - } - } - - /* Main render loop */ - done = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - quit(0); - - return 0; /* to prevent compiler warning */ -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/teststreaming.c b/3rdparty/SDL2/test/teststreaming.c deleted file mode 100644 index 86cc13917bd..00000000000 --- a/3rdparty/SDL2/test/teststreaming.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/******************************************************************************** - * * - * Running moose :) Coded by Mike Gorchak. * - * * - ********************************************************************************/ - -#include <stdlib.h> -#include <stdio.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#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, 255}, {66, 24, 0, 255}, {66, 33, 0, 255}, {66, 66, 66, 255}, - {66, 115, 49, 255}, {74, 33, 0, 255}, {74, 41, 16, 255}, {82, 33, 8, 255}, - {82, 41, 8, 255}, {82, 49, 16, 255}, {82, 82, 82, 255}, {90, 41, 8, 255}, - {90, 41, 16, 255}, {90, 57, 24, 255}, {99, 49, 16, 255}, {99, 66, 24, 255}, - {99, 66, 33, 255}, {99, 74, 33, 255}, {107, 57, 24, 255}, {107, 82, 41, 255}, - {115, 57, 33, 255}, {115, 66, 33, 255}, {115, 66, 41, 255}, {115, 74, 0, 255}, - {115, 90, 49, 255}, {115, 115, 115, 255}, {123, 82, 0, 255}, {123, 99, 57, 255}, - {132, 66, 41, 255}, {132, 74, 41, 255}, {132, 90, 8, 255}, {132, 99, 33, 255}, - {132, 99, 66, 255}, {132, 107, 66, 255}, {140, 74, 49, 255}, {140, 99, 16, 255}, - {140, 107, 74, 255}, {140, 115, 74, 255}, {148, 107, 24, 255}, {148, 115, 82, 255}, - {148, 123, 74, 255}, {148, 123, 90, 255}, {156, 115, 33, 255}, {156, 115, 90, 255}, - {156, 123, 82, 255}, {156, 132, 82, 255}, {156, 132, 99, 255}, {156, 156, 156, 255}, - {165, 123, 49, 255}, {165, 123, 90, 255}, {165, 132, 82, 255}, {165, 132, 90, 255}, - {165, 132, 99, 255}, {165, 140, 90, 255}, {173, 132, 57, 255}, {173, 132, 99, 255}, - {173, 140, 107, 255}, {173, 140, 115, 255}, {173, 148, 99, 255}, {173, 173, 173, 255}, - {181, 140, 74, 255}, {181, 148, 115, 255}, {181, 148, 123, 255}, {181, 156, 107, 255}, - {189, 148, 123, 255}, {189, 156, 82, 255}, {189, 156, 123, 255}, {189, 156, 132, 255}, - {189, 189, 189, 255}, {198, 156, 123, 255}, {198, 165, 132, 255}, {206, 165, 99, 255}, - {206, 165, 132, 255}, {206, 173, 140, 255}, {206, 206, 206, 255}, {214, 173, 115, 255}, - {214, 173, 140, 255}, {222, 181, 148, 255}, {222, 189, 132, 255}, {222, 189, 156, 255}, - {222, 222, 222, 255}, {231, 198, 165, 255}, {231, 231, 231, 255}, {239, 206, 173, 255} -}; - -Uint8 MooseFrames[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE]; - -SDL_Renderer *renderer; -int frame; -SDL_Texture *MooseTexture; -SDL_bool done = SDL_FALSE; - -void quit(int rc) -{ - SDL_Quit(); - exit(rc); -} - -void UpdateTexture(SDL_Texture *texture, int frame) -{ - SDL_Color *color; - Uint8 *src; - Uint32 *dst; - int row, col; - void *pixels; - int pitch; - - if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError()); - quit(5); - } - src = MooseFrames[frame]; - for (row = 0; row < MOOSEPIC_H; ++row) { - dst = (Uint32*)((Uint8*)pixels + row * pitch); - for (col = 0; col < MOOSEPIC_W; ++col) { - color = &MooseColors[*src++]; - *dst++ = (0xFF000000|(color->r<<16)|(color->g<<8)|color->b); - } - } - SDL_UnlockTexture(texture); -} - -void -loop() -{ - SDL_Event event; - - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_KEYDOWN: - if (event.key.keysym.sym == SDLK_ESCAPE) { - done = SDL_TRUE; - } - break; - case SDL_QUIT: - done = SDL_TRUE; - break; - } - } - - frame = (frame + 1) % MOOSEFRAMES_COUNT; - UpdateTexture(MooseTexture, frame); - - SDL_RenderClear(renderer); - SDL_RenderCopy(renderer, MooseTexture, NULL, NULL); - SDL_RenderPresent(renderer); - -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char **argv) -{ - SDL_Window *window; - SDL_RWops *handle; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return 1; - } - - /* load the moose images */ - handle = SDL_RWFromFile("moose.dat", "rb"); - if (handle == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); - quit(2); - } - SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT); - SDL_RWclose(handle); - - - /* Create the window and renderer */ - window = SDL_CreateWindow("Happy Moose", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - MOOSEPIC_W*4, MOOSEPIC_H*4, - SDL_WINDOW_RESIZABLE); - if (!window) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); - quit(3); - } - - renderer = SDL_CreateRenderer(window, -1, 0); - if (!renderer) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); - quit(4); - } - - MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); - if (!MooseTexture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); - quit(5); - } - - /* Loop, waiting for QUIT or the escape key */ - frame = 0; - -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - - SDL_DestroyRenderer(renderer); - - quit(0); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testthread.c b/3rdparty/SDL2/test/testthread.c deleted file mode 100644 index 90e2c60c588..00000000000 --- a/3rdparty/SDL2/test/testthread.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple test of the SDL threading code */ - -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> - -#include "SDL.h" - -static SDL_TLSID tls; -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) -{ - SDL_TLSSet(tls, "baby thread", NULL); - SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n", - (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls)); - while (alive) { - SDL_Log("Thread '%s' is alive!\n", (char *) data); - SDL_Delay(1 * 1000); - } - SDL_Log("Thread '%s' exiting!\n", (char *) data); - return (0); -} - -static void -killed(int sig) -{ - SDL_Log("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; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(0) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - tls = SDL_TLSCreate(); - SDL_assert(tls); - SDL_TLSSet(tls, "main thread", NULL); - SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls)); - - alive = 1; - thread = SDL_CreateThread(ThreadFunc, "One", "#1"); - if (thread == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); - quit(1); - } - SDL_Delay(5 * 1000); - SDL_Log("Waiting for thread #1\n"); - alive = 0; - SDL_WaitThread(thread, NULL); - - SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls)); - - alive = 1; - signal(SIGTERM, killed); - thread = SDL_CreateThread(ThreadFunc, "Two", "#2"); - if (thread == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); - quit(1); - } - raise(SIGTERM); - - SDL_Quit(); /* Never reached */ - return (0); /* Never reached */ -} diff --git a/3rdparty/SDL2/test/testtimer.c b/3rdparty/SDL2/test/testtimer.c deleted file mode 100644 index 32b74909826..00000000000 --- a/3rdparty/SDL2/test/testtimer.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* 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, void *param) -{ - ++ticks; - return (interval); -} - -static Uint32 SDLCALL -callback(Uint32 interval, void *param) -{ - SDL_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param); - return interval; -} - -int -main(int argc, char *argv[]) -{ - int i, desired; - SDL_TimerID t1, t2, t3; - Uint32 start32, now32; - Uint64 start, now; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - if (SDL_Init(SDL_INIT_TIMER) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "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; - } - t1 = SDL_AddTimer(desired, ticktock, NULL); - - /* Wait 10 seconds */ - SDL_Log("Waiting 10 seconds\n"); - SDL_Delay(10 * 1000); - - /* Stop the timer */ - SDL_RemoveTimer(t1); - - /* Print the results */ - if (ticks) { - SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n", - desired, (double) (10 * 1000) / ticks); - } - - /* Test multiple timers */ - SDL_Log("Testing multiple timers...\n"); - t1 = SDL_AddTimer(100, callback, (void *) 1); - if (!t1) - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError()); - t2 = SDL_AddTimer(50, callback, (void *) 2); - if (!t2) - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError()); - t3 = SDL_AddTimer(233, callback, (void *) 3); - if (!t3) - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError()); - - /* Wait 10 seconds */ - SDL_Log("Waiting 10 seconds\n"); - SDL_Delay(10 * 1000); - - SDL_Log("Removing timer 1 and waiting 5 more seconds\n"); - SDL_RemoveTimer(t1); - - SDL_Delay(5 * 1000); - - SDL_RemoveTimer(t2); - SDL_RemoveTimer(t3); - - start = SDL_GetPerformanceCounter(); - for (i = 0; i < 1000000; ++i) { - ticktock(0, NULL); - } - now = SDL_GetPerformanceCounter(); - SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); - - SDL_Log("Performance counter frequency: %"SDL_PRIu64"\n", (unsigned long long) SDL_GetPerformanceFrequency()); - start32 = SDL_GetTicks(); - start = SDL_GetPerformanceCounter(); - SDL_Delay(1000); - now = SDL_GetPerformanceCounter(); - now32 = SDL_GetTicks(); - SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); - - SDL_Quit(); - return (0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testver.c b/3rdparty/SDL2/test/testver.c deleted file mode 100644 index f0e3bcf3c20..00000000000 --- a/3rdparty/SDL2/test/testver.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* 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" -#include "SDL_revision.h" - -int -main(int argc, char *argv[]) -{ - SDL_version compiled; - SDL_version linked; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - -#if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_Log("Compiled with SDL 2.0 or newer\n"); -#else - SDL_Log("Compiled with SDL older than 2.0\n"); -#endif - SDL_VERSION(&compiled); - SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n", - compiled.major, compiled.minor, compiled.patch, - SDL_REVISION_NUMBER, SDL_REVISION); - SDL_GetVersion(&linked); - SDL_Log("Linked version: %d.%d.%d.%d (%s)\n", - linked.major, linked.minor, linked.patch, - SDL_GetRevisionNumber(), SDL_GetRevision()); - SDL_Quit(); - return (0); -} diff --git a/3rdparty/SDL2/test/testviewport.c b/3rdparty/SDL2/test/testviewport.c deleted file mode 100644 index 7ed4e6ec357..00000000000 --- a/3rdparty/SDL2/test/testviewport.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ -/* Simple program: Check viewports */ - -#include <stdlib.h> -#include <stdio.h> -#include <time.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test.h" -#include "SDL_test_common.h" - - -static SDLTest_CommonState *state; - -SDL_Rect viewport; -int done, j; -SDL_bool use_target = SDL_FALSE; -#ifdef __EMSCRIPTEN__ -Uint32 wait_start; -#endif - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -void -DrawOnViewport(SDL_Renderer * renderer, SDL_Rect viewport) -{ - SDL_Rect rect; - - /* Set the viewport */ - SDL_RenderSetViewport(renderer, &viewport); - - /* Draw a gray background */ - SDL_SetRenderDrawColor(renderer, 0x80, 0x80, 0x80, 0xFF); - SDL_RenderClear(renderer); - - /* Test inside points */ - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xF, 0xFF); - SDL_RenderDrawPoint(renderer, viewport.h/2 + 10, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2 - 10, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - 10); - SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + 10); - - /* Test horizontal and vertical lines */ - SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF); - SDL_RenderDrawLine(renderer, 1, 0, viewport.w-2, 0); - SDL_RenderDrawLine(renderer, 1, viewport.h-1, viewport.w-2, viewport.h-1); - SDL_RenderDrawLine(renderer, 0, 1, 0, viewport.h-2); - SDL_RenderDrawLine(renderer, viewport.w-1, 1, viewport.w-1, viewport.h-2); - - /* Test diagonal lines */ - SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0xFF, 0xFF); - SDL_RenderDrawLine(renderer, 0, 0, - viewport.w-1, viewport.h-1); - SDL_RenderDrawLine(renderer, viewport.w-1, 0, - 0, viewport.h-1); - - /* Test outside points */ - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xF, 0xFF); - SDL_RenderDrawPoint(renderer, viewport.h/2 + viewport.h, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2 - viewport.h, viewport.w/2); - SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - viewport.w); - SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + viewport.w); - - /* Add a box at the top */ - rect.w = 8; - rect.h = 8; - rect.x = (viewport.w - rect.w) / 2; - rect.y = 0; - SDL_RenderFillRect(renderer, &rect); -} - -void -loop() -{ -#ifdef __EMSCRIPTEN__ - /* Avoid using delays */ - if(SDL_GetTicks() - wait_start < 1000) - return; - wait_start = SDL_GetTicks(); -#endif - SDL_Event event; - int i; - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } - - /* Move a viewport box in steps around the screen */ - viewport.x = j * 100; - viewport.y = viewport.x; - viewport.w = 100 + j * 50; - viewport.h = 100 + j * 50; - j = (j + 1) % 4; - SDL_Log("Current Viewport x=%i y=%i w=%i h=%i", viewport.x, viewport.y, viewport.w, viewport.h); - - for (i = 0; i < state->num_windows; ++i) { - if (state->windows[i] == NULL) - continue; - - /* Draw using viewport */ - DrawOnViewport(state->renderers[i], viewport); - - /* Update the screen! */ - if (use_target) { - SDL_SetRenderTarget(state->renderers[i], NULL); - SDL_RenderCopy(state->renderers[i], state->targets[i], NULL, NULL); - SDL_RenderPresent(state->renderers[i]); - SDL_SetRenderTarget(state->renderers[i], state->targets[i]); - } else { - SDL_RenderPresent(state->renderers[i]); - } - } - -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - Uint32 then, now, frames; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - if (SDL_strcasecmp(argv[i], "--target") == 0) { - use_target = SDL_TRUE; - consumed = 1; - } - } - if (consumed < 0) { - SDL_Log("Usage: %s %s [--target]\n", - argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - if (use_target) { - int w, h; - - for (i = 0; i < state->num_windows; ++i) { - SDL_GetWindowSize(state->windows[i], &w, &h); - state->targets[i] = SDL_CreateTexture(state->renderers[i], SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, w, h); - SDL_SetRenderTarget(state->renderers[i], state->targets[i]); - } - } - - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - - /* Main render loop */ - frames = 0; - then = SDL_GetTicks(); - done = 0; - j = 0; - -#ifdef __EMSCRIPTEN__ - wait_start = SDL_GetTicks(); - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - ++frames; - loop(); - SDL_Delay(1000); - } -#endif - - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } - quit(0); - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/testwm2.c b/3rdparty/SDL2/test/testwm2.c deleted file mode 100644 index cd19e9f19f0..00000000000 --- a/3rdparty/SDL2/test/testwm2.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#ifdef __EMSCRIPTEN__ -#include <emscripten/emscripten.h> -#endif - -#include "SDL_test_common.h" - -static SDLTest_CommonState *state; -int done; - -static const char *cursorNames[] = { - "arrow", - "ibeam", - "wait", - "crosshair", - "waitarrow", - "sizeNWSE", - "sizeNESW", - "sizeWE", - "sizeNS", - "sizeALL", - "NO", - "hand", -}; -int system_cursor = -1; -SDL_Cursor *cursor = NULL; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDLTest_CommonQuit(state); - exit(rc); -} - -void -loop() -{ - int i; - SDL_Event event; - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - - if (event.type == SDL_WINDOWEVENT) { - if (event.window.event == SDL_WINDOWEVENT_RESIZED) { - SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); - if (window) { - SDL_Log("Window %d resized to %dx%d\n", - event.window.windowID, - event.window.data1, - event.window.data2); - } - } - if (event.window.event == SDL_WINDOWEVENT_MOVED) { - SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); - if (window) { - SDL_Log("Window %d moved to %d,%d (display %s)\n", - event.window.windowID, - event.window.data1, - event.window.data2, - SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window))); - } - } - } - if (event.type == SDL_KEYUP) { - SDL_bool updateCursor = SDL_FALSE; - - if (event.key.keysym.sym == SDLK_LEFT) { - --system_cursor; - if (system_cursor < 0) { - system_cursor = SDL_NUM_SYSTEM_CURSORS - 1; - } - updateCursor = SDL_TRUE; - } else if (event.key.keysym.sym == SDLK_RIGHT) { - ++system_cursor; - if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) { - system_cursor = 0; - } - updateCursor = SDL_TRUE; - } - if (updateCursor) { - SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]); - SDL_FreeCursor(cursor); - cursor = SDL_CreateSystemCursor((SDL_SystemCursor)system_cursor); - SDL_SetCursor(cursor); - } - } - } - - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - } -#ifdef __EMSCRIPTEN__ - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int -main(int argc, char *argv[]) -{ - int i; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS); - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (!state) { - return 1; - } - for (i = 1; i < argc;) { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - } - if (consumed < 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); - } - - for (i = 0; i < state->num_windows; ++i) { - SDL_Renderer *renderer = state->renderers[i]; - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); - SDL_RenderClear(renderer); - } - - /* Main render loop */ - done = 0; -#ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - SDL_FreeCursor(cursor); - - quit(0); - /* keep the compiler happy ... */ - return(0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/test/torturethread.c b/3rdparty/SDL2/test/torturethread.c deleted file mode 100644 index 6b98a0a9fd2..00000000000 --- a/3rdparty/SDL2/test/torturethread.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely. -*/ - -/* Simple test of the SDL threading code */ - -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <string.h> - -#include "SDL.h" - -#define NUMTHREADS 10 - -static SDL_atomic_t 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; - - SDL_Log("Creating Thread %d\n", tid); - - for (i = 0; i < NUMTHREADS; i++) { - char name[64]; - SDL_snprintf(name, sizeof (name), "Child%d_%d", tid, i); - flags[i] = 0; - sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]); - } - - SDL_Log("Thread '%d' waiting for signal\n", tid); - while (SDL_AtomicGet(&time_for_threads_to_die[tid]) != 1) { - ; /* do nothing */ - } - - SDL_Log("Thread '%d' sending signals to subthreads\n", tid); - for (i = 0; i < NUMTHREADS; i++) { - flags[i] = 1; - SDL_WaitThread(sub_threads[i], NULL); - } - - SDL_Log("Thread '%d' exiting!\n", tid); - - return 0; -} - -int -main(int argc, char *argv[]) -{ - SDL_Thread *threads[NUMTHREADS]; - int i; - - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - - /* Load the SDL library */ - if (SDL_Init(0) < 0) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - signal(SIGSEGV, SIG_DFL); - for (i = 0; i < NUMTHREADS; i++) { - char name[64]; - SDL_snprintf(name, sizeof (name), "Parent%d", i); - SDL_AtomicSet(&time_for_threads_to_die[i], 0); - threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i); - - if (threads[i] == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); - quit(1); - } - } - - for (i = 0; i < NUMTHREADS; i++) { - SDL_AtomicSet(&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/3rdparty/SDL2/test/utf8.txt b/3rdparty/SDL2/test/utf8.txt deleted file mode 100644 index aab22f1d023..00000000000 --- a/3rdparty/SDL2/test/utf8.txt +++ /dev/null @@ -1,287 +0,0 @@ -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 | - |