early-access version 2281
This commit is contained in:
34
externals/SDL/test/CMakeLists.txt
vendored
34
externals/SDL/test/CMakeLists.txt
vendored
@@ -6,14 +6,22 @@ project(SDL2 C)
|
||||
remove_definitions(-DUSING_GENERATED_CONFIG_H)
|
||||
link_libraries(SDL2_test SDL2-static)
|
||||
|
||||
# FIXME: Parent directory CMakeLists.txt only sets these for mingw/cygwin,
|
||||
# but we need them for VS as well.
|
||||
if(WINDOWS)
|
||||
# mingw32 must come before SDL2main to link successfully
|
||||
if(MINGW OR CYGWIN)
|
||||
link_libraries(mingw32)
|
||||
endif()
|
||||
|
||||
# FIXME: Parent directory CMakeLists.txt only sets these for mingw/cygwin,
|
||||
# but we need them for VS as well.
|
||||
link_libraries(SDL2main)
|
||||
add_definitions(-Dmain=SDL_main)
|
||||
endif()
|
||||
|
||||
find_package(OpenGL)
|
||||
# CMake incorrectly detects opengl32.lib being present on MSVC ARM64
|
||||
if(NOT MSVC OR NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
|
||||
find_package(OpenGL)
|
||||
endif()
|
||||
|
||||
if (OPENGL_FOUND)
|
||||
add_definitions(-DHAVE_OPENGL)
|
||||
@@ -23,6 +31,7 @@ add_executable(checkkeys checkkeys.c)
|
||||
add_executable(checkkeysthreads checkkeysthreads.c)
|
||||
add_executable(loopwave loopwave.c)
|
||||
add_executable(loopwavequeue loopwavequeue.c)
|
||||
add_executable(testsurround testsurround.c)
|
||||
add_executable(testresample testresample.c)
|
||||
add_executable(testaudioinfo testaudioinfo.c)
|
||||
|
||||
@@ -42,6 +51,7 @@ add_executable(testdropfile testdropfile.c)
|
||||
add_executable(testerror testerror.c)
|
||||
add_executable(testfile testfile.c)
|
||||
add_executable(testgamecontroller testgamecontroller.c)
|
||||
add_executable(testgeometry testgeometry.c)
|
||||
add_executable(testgesture testgesture.c)
|
||||
add_executable(testgl2 testgl2.c)
|
||||
add_executable(testgles testgles.c)
|
||||
@@ -56,6 +66,7 @@ add_executable(testjoystick testjoystick.c)
|
||||
add_executable(testkeys testkeys.c)
|
||||
add_executable(testloadso testloadso.c)
|
||||
add_executable(testlock testlock.c)
|
||||
add_executable(testmouse testmouse.c)
|
||||
|
||||
if(APPLE)
|
||||
add_executable(testnative testnative.c
|
||||
@@ -102,21 +113,8 @@ target_link_libraries(testshader OpenGL::GL)
|
||||
target_link_libraries(testgl2 OpenGL::GL)
|
||||
endif()
|
||||
|
||||
# HACK: Dummy target to cause the resource files to be copied to the build directory.
|
||||
# Need to make it an executable so we can use the TARGET_FILE_DIR generator expression.
|
||||
# This is needed so they get copied to the correct Debug/Release subdirectory in Xcode.
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/resources_dummy.c "int main(int argc, const char **argv){ return 1; }\n")
|
||||
add_executable(SDL2_test_resources ${CMAKE_CURRENT_BINARY_DIR}/resources_dummy.c)
|
||||
|
||||
file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt)
|
||||
foreach(RESOURCE_FILE ${RESOURCE_FILES})
|
||||
add_custom_command(TARGET SDL2_test_resources POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:SDL2_test_resources>)
|
||||
endforeach(RESOURCE_FILE)
|
||||
|
||||
file(COPY ${RESOURCE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# TODO: Might be easier to make all targets depend on the resources...?
|
||||
|
||||
set(NEEDS_RESOURCES
|
||||
testscale
|
||||
testrendercopyex
|
||||
@@ -138,7 +136,9 @@ set(NEEDS_RESOURCES
|
||||
testmultiaudio
|
||||
)
|
||||
foreach(APP IN LISTS NEEDS_RESOURCES)
|
||||
add_dependencies(${APP} SDL2_test_resources)
|
||||
foreach(RESOURCE_FILE ${RESOURCE_FILES})
|
||||
add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:${APP}>)
|
||||
endforeach(RESOURCE_FILE)
|
||||
if(APPLE)
|
||||
# Make sure resource files get installed into macOS/iOS .app bundles.
|
||||
target_sources(${APP} PRIVATE "${RESOURCE_FILES}")
|
||||
|
50
externals/SDL/test/Makefile.in
vendored
50
externals/SDL/test/Makefile.in
vendored
@@ -29,6 +29,7 @@ TARGETS = \
|
||||
testfile$(EXE) \
|
||||
testfilesystem$(EXE) \
|
||||
testgamecontroller$(EXE) \
|
||||
testgeometry$(EXE) \
|
||||
testgesture$(EXE) \
|
||||
testhaptic$(EXE) \
|
||||
testhittesting$(EXE) \
|
||||
@@ -42,6 +43,7 @@ TARGETS = \
|
||||
testlocale$(EXE) \
|
||||
testlock$(EXE) \
|
||||
testmessage$(EXE) \
|
||||
testmouse$(EXE) \
|
||||
testmultiaudio$(EXE) \
|
||||
testnative$(EXE) \
|
||||
testoverlay2$(EXE) \
|
||||
@@ -60,6 +62,7 @@ TARGETS = \
|
||||
testsprite2$(EXE) \
|
||||
testspriteminimal$(EXE) \
|
||||
teststreaming$(EXE) \
|
||||
testsurround$(EXE) \
|
||||
testthread$(EXE) \
|
||||
testtimer$(EXE) \
|
||||
testurl$(EXE) \
|
||||
@@ -70,7 +73,7 @@ TARGETS = \
|
||||
testyuv$(EXE) \
|
||||
torturethread$(EXE) \
|
||||
|
||||
|
||||
|
||||
@OPENGL_TARGETS@ += testgl2$(EXE) testshader$(EXE)
|
||||
@OPENGLES1_TARGETS@ += testgles$(EXE)
|
||||
@OPENGLES2_TARGETS@ += testgles2$(EXE)
|
||||
@@ -93,6 +96,9 @@ loopwave$(EXE): $(srcdir)/loopwave.c
|
||||
loopwavequeue$(EXE): $(srcdir)/loopwavequeue.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testsurround$(EXE): $(srcdir)/testsurround.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testresample$(EXE): $(srcdir)/testresample.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
@@ -161,7 +167,10 @@ testfile$(EXE): $(srcdir)/testfile.c
|
||||
|
||||
testgamecontroller$(EXE): $(srcdir)/testgamecontroller.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
|
||||
testgeometry$(EXE): $(srcdir)/testgeometry.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testgesture$(EXE): $(srcdir)/testgesture.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
@@ -322,6 +331,8 @@ testvulkan$(EXE): $(srcdir)/testvulkan.c
|
||||
testlocale$(EXE): $(srcdir)/testlocale.c
|
||||
$(CC) -o $@ $? $(CFLAGS) $(LIBS)
|
||||
|
||||
testmouse$(EXE): $(srcdir)/testmouse.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
|
||||
clean:
|
||||
@@ -332,26 +343,25 @@ distclean: clean
|
||||
rm -f config.status config.cache config.log
|
||||
rm -rf $(srcdir)/autom4te*
|
||||
|
||||
DATA = \
|
||||
axis.bmp \
|
||||
button.bmp \
|
||||
controllermap.bmp \
|
||||
controllermap_back.bmp \
|
||||
icon.bmp \
|
||||
moose.dat \
|
||||
sample.bmp \
|
||||
sample.wav \
|
||||
testgles2_sdf_img_normal.bmp \
|
||||
testgles2_sdf_img_sdf.bmp \
|
||||
testyuv.bmp \
|
||||
unifont-13.0.06.hex \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(srcdir), .)
|
||||
%.bmp: $(srcdir)/%.bmp
|
||||
cp $< $@
|
||||
|
||||
%.wav: $(srcdir)/%.wav
|
||||
cp $< $@
|
||||
|
||||
%.dat: $(srcdir)/%.dat
|
||||
$(DATA) : %: $(srcdir)/% Makefile
|
||||
cp $< $@
|
||||
endif
|
||||
|
||||
copydatafiles: copybmpfiles copywavfiles copydatfiles
|
||||
copydatafiles: $(DATA)
|
||||
.PHONY : copydatafiles
|
||||
|
||||
copybmpfiles: $(foreach bmp,$(wildcard $(srcdir)/*.bmp),$(notdir $(bmp)))
|
||||
.PHONY : copybmpfiles
|
||||
|
||||
copywavfiles: $(foreach wav,$(wildcard $(srcdir)/*.wav),$(notdir $(wav)))
|
||||
.PHONY : copywavfiles
|
||||
|
||||
copydatfiles: $(foreach dat,$(wildcard $(srcdir)/*.dat),$(notdir $(dat)))
|
||||
.PHONY : copydatfiles
|
||||
|
||||
|
37
externals/SDL/test/Makefile.os2
vendored
37
externals/SDL/test/Makefile.os2
vendored
@@ -1,8 +1,20 @@
|
||||
BINPATH = .
|
||||
# Open Watcom makefile to build SDL2 tests for OS/2
|
||||
# wmake -f Makefile.os2
|
||||
|
||||
INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h" -I"../include"
|
||||
|
||||
CFLAGS = $(INCPATH) -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei
|
||||
CFLAGS+= -wx -wcd=303
|
||||
|
||||
LIBPATH = ..
|
||||
LIBS = SDL2.lib $(TESTLIB)
|
||||
|
||||
#CFLAGS+= -DHAVE_SDL_TTF
|
||||
#TTFLIBS = SDL2ttf.lib
|
||||
|
||||
TARGETS = testatomic.exe testdisplayinfo.exe testbounds.exe testdraw2.exe &
|
||||
testdrawchessboard.exe testdropfile.exe testerror.exe testfile.exe &
|
||||
testfilesystem.exe testgamecontroller.exe testgesture.exe &
|
||||
testfilesystem.exe testgamecontroller.exe testgeometry.exe testgesture.exe &
|
||||
testhittesting.exe testhotplug.exe testiconv.exe testime.exe testlocale.exe &
|
||||
testintersections.exe testjoystick.exe testkeys.exe testloadso.exe &
|
||||
testlock.exe testmessage.exe testoverlay2.exe testplatform.exe &
|
||||
@@ -11,13 +23,13 @@ TARGETS = testatomic.exe testdisplayinfo.exe testbounds.exe testdraw2.exe &
|
||||
testshader.exe testshape.exe testsprite2.exe testspriteminimal.exe &
|
||||
teststreaming.exe testthread.exe testtimer.exe testver.exe &
|
||||
testviewport.exe testwm2.exe torturethread.exe checkkeys.exe &
|
||||
checkkeysthreads.exe &
|
||||
checkkeysthreads.exe testmouse.exe &
|
||||
controllermap.exe testhaptic.exe testqsort.exe testresample.exe &
|
||||
testaudioinfo.exe testaudiocapture.exe loopwave.exe loopwavequeue.exe &
|
||||
testyuv.exe testgl2.exe testvulkan.exe testnative.exe testautomation.exe
|
||||
testsurround.exe testyuv.exe testgl2.exe testvulkan.exe testnative.exe &
|
||||
testautomation.exe
|
||||
|
||||
# SDL2test.lib sources (../src/test)
|
||||
|
||||
CSRCS = SDL_test_assert.c SDL_test_common.c SDL_test_compare.c &
|
||||
SDL_test_crc32.c SDL_test_font.c SDL_test_fuzzer.c SDL_test_harness.c &
|
||||
SDL_test_imageBlit.c SDL_test_imageBlitBlend.c SDL_test_imageFace.c &
|
||||
@@ -26,7 +38,6 @@ CSRCS = SDL_test_assert.c SDL_test_common.c SDL_test_compare.c &
|
||||
TESTLIB = SDL2test.lib
|
||||
|
||||
# testautomation sources
|
||||
|
||||
TASRCS = testautomation.c testautomation_audio.c testautomation_clipboard.c &
|
||||
testautomation_events.c testautomation_hints.c &
|
||||
testautomation_keyboard.c testautomation_main.c &
|
||||
@@ -43,17 +54,6 @@ TAOBJS = $(TASRCS:.c=.obj)
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
INCPATH = -I$(%WATCOM)/h/os2 -I$(%WATCOM)/h -I../include
|
||||
|
||||
CFLAGS = $(INCPATH) -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei
|
||||
CFLAGS+= -wx -wcd=303
|
||||
|
||||
LIBPATH = ..
|
||||
LIBS = SDL2.lib $(TESTLIB)
|
||||
|
||||
#CFLAGS+= -DHAVE_SDL_TTF
|
||||
#LIBS_TTF = SDL2ttf.lib
|
||||
|
||||
.c: ../src/test
|
||||
|
||||
$(TESTLIB): $(COBJS)
|
||||
@@ -85,10 +85,9 @@ testyuv.exe: testyuv.obj testyuv_cvt.obj
|
||||
|
||||
testime.exe: testime.obj
|
||||
@%make $(TESTLIB)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS) $(LIBS_TTF)} op q op el file {$<} name $@
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS) $(TTFLIBS)} op q op el file {$<} name $@
|
||||
|
||||
clean: .SYMBOLIC
|
||||
@echo * Clean tests in $(BINPATH)
|
||||
@if exist *.obj rm *.obj
|
||||
@if exist *.err rm *.err
|
||||
|
||||
|
2
externals/SDL/test/README
vendored
2
externals/SDL/test/README
vendored
@@ -4,6 +4,7 @@ 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
|
||||
testsurround Audio test -- play test tone on each audio channel
|
||||
testaudioinfo Lists audio device capabilities
|
||||
testerror Tests multi-threaded error handling
|
||||
testfile Tests RWops layer
|
||||
@@ -14,6 +15,7 @@ These are test programs for the SDL library:
|
||||
testloadso Tests the loadable library layer
|
||||
testlocale Test Locale API
|
||||
testlock Hacked up test of multi-threading and locking
|
||||
testmouse Tests mouse coordinates
|
||||
testmultiaudio Tests using several audio devices
|
||||
testoverlay2 Tests the overlay flickering/scaling during playback.
|
||||
testplatform Tests types, endianness and cpu capabilities
|
||||
|
2
externals/SDL/test/acinclude.m4
vendored
2
externals/SDL/test/acinclude.m4
vendored
@@ -287,7 +287,7 @@ 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])
|
||||
AC_MSG_CHECKING([for $2])
|
||||
|
||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||
|
14
externals/SDL/test/checkkeys.c
vendored
14
externals/SDL/test/checkkeys.c
vendored
@@ -86,6 +86,8 @@ print_modifiers(char **text, size_t *maxlen)
|
||||
print_string(text, maxlen, " CAPS");
|
||||
if (mod & KMOD_MODE)
|
||||
print_string(text, maxlen, " MODE");
|
||||
if (mod & KMOD_SCROLL)
|
||||
print_string(text, maxlen, " SCROLL");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -135,9 +137,10 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
|
||||
}
|
||||
|
||||
static void
|
||||
PrintText(char *eventtype, char *text)
|
||||
PrintText(const char *eventtype, const char *text)
|
||||
{
|
||||
char *spot, expanded[1024];
|
||||
const char *spot;
|
||||
char expanded[1024];
|
||||
|
||||
expanded[0] = '\0';
|
||||
for ( spot = text; *spot; ++spot )
|
||||
@@ -199,6 +202,7 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -219,6 +223,12 @@ main(int argc, char *argv[])
|
||||
quit(2);
|
||||
}
|
||||
|
||||
/* On wayland, no window will actually show until something has
|
||||
actually been displayed.
|
||||
*/
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
#if __IPHONEOS__
|
||||
/* Creating the context creates the view, which we need to show keyboard */
|
||||
SDL_GL_CreateContext(window);
|
||||
|
16
externals/SDL/test/checkkeysthreads.c
vendored
16
externals/SDL/test/checkkeysthreads.c
vendored
@@ -86,6 +86,8 @@ print_modifiers(char **text, size_t *maxlen)
|
||||
print_string(text, maxlen, " CAPS");
|
||||
if (mod & KMOD_MODE)
|
||||
print_string(text, maxlen, " MODE");
|
||||
if (mod & KMOD_SCROLL)
|
||||
print_string(text, maxlen, " SCROLL");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -136,9 +138,10 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
|
||||
}
|
||||
|
||||
static void
|
||||
PrintText(char *eventtype, char *text)
|
||||
PrintText(const char *eventtype, const char *text)
|
||||
{
|
||||
char *spot, expanded[1024];
|
||||
const char *spot;
|
||||
char expanded[1024];
|
||||
|
||||
expanded[0] = '\0';
|
||||
for ( spot = text; *spot; ++spot )
|
||||
@@ -207,7 +210,7 @@ static int SDLCALL ping_thread(void *ptr)
|
||||
{
|
||||
int cnt;
|
||||
SDL_Event sdlevent;
|
||||
memset(&sdlevent, 0 , sizeof(SDL_Event));
|
||||
SDL_memset(&sdlevent, 0 , sizeof(SDL_Event));
|
||||
for (cnt = 0; cnt < 10; ++cnt) {
|
||||
fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10); fflush(stderr);
|
||||
sdlevent.type = SDL_KEYDOWN;
|
||||
@@ -222,6 +225,7 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Thread *thread;
|
||||
|
||||
/* Enable standard application logging */
|
||||
@@ -243,6 +247,12 @@ main(int argc, char *argv[])
|
||||
quit(2);
|
||||
}
|
||||
|
||||
/* On wayland, no window will actually show until something has
|
||||
actually been displayed.
|
||||
*/
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
#if __IPHONEOS__
|
||||
/* Creating the context creates the view, which we need to show keyboard */
|
||||
SDL_GL_CreateContext(window);
|
||||
|
93
externals/SDL/test/configure
vendored
93
externals/SDL/test/configure
vendored
@@ -584,6 +584,8 @@ PACKAGE_URL=
|
||||
ac_unique_file="loopwave.c"
|
||||
ac_subst_vars='LTLIBOBJS
|
||||
LIBOBJS
|
||||
LIBUNWIND_LIBS
|
||||
LIBUNWIND_CFLAGS
|
||||
SDL_TTF_LIB
|
||||
XLIB
|
||||
GLES2LIB
|
||||
@@ -681,7 +683,9 @@ PKG_CONFIG_LIBDIR
|
||||
SDL_CFLAGS
|
||||
SDL_LIBS
|
||||
XMKMF
|
||||
CPP'
|
||||
CPP
|
||||
LIBUNWIND_CFLAGS
|
||||
LIBUNWIND_LIBS'
|
||||
|
||||
|
||||
# Initialize some variables set by options.
|
||||
@@ -1323,6 +1327,10 @@ Some influential environment variables:
|
||||
SDL_LIBS linker flags for SDL, overriding pkg-config
|
||||
XMKMF Path to xmkmf, Makefile generator for X Window System
|
||||
CPP C preprocessor
|
||||
LIBUNWIND_CFLAGS
|
||||
C compiler flags for LIBUNWIND, overriding pkg-config
|
||||
LIBUNWIND_LIBS
|
||||
linker flags for LIBUNWIND, overriding pkg-config
|
||||
|
||||
Use these variables to override the choices made by `configure' or to help
|
||||
it to find libraries and programs with nonstandard names/locations.
|
||||
@@ -1921,7 +1929,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
|
||||
|
||||
ac_aux_dir=
|
||||
for ac_dir in $srcdir/../build-scripts; do
|
||||
for ac_dir in ../build-scripts "$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"
|
||||
@@ -1937,7 +1945,7 @@ for ac_dir in $srcdir/../build-scripts; do
|
||||
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
|
||||
as_fn_error $? "cannot find install-sh, install.sh, or shtool in ../build-scripts \"$srcdir\"/../build-scripts" "$LINENO" 5
|
||||
fi
|
||||
|
||||
# These three variables are undocumented and unsupported,
|
||||
@@ -3046,7 +3054,7 @@ esac
|
||||
|
||||
|
||||
|
||||
SDL_VERSION=2.0.0
|
||||
SDL_VERSION=2.0.18
|
||||
|
||||
|
||||
|
||||
@@ -3195,8 +3203,8 @@ fi
|
||||
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; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl2 >= $min_sdl_version" >&5
|
||||
$as_echo_n "checking for sdl2 >= $min_sdl_version... " >&6; }
|
||||
|
||||
if test -n "$SDL_CFLAGS"; then
|
||||
pkg_cv_SDL_CFLAGS="$SDL_CFLAGS"
|
||||
@@ -4020,6 +4028,79 @@ if test x$have_SDL_ttf = xyes; then
|
||||
fi
|
||||
|
||||
|
||||
|
||||
pkg_failed=no
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libunwind" >&5
|
||||
$as_echo_n "checking for libunwind... " >&6; }
|
||||
|
||||
if test -n "$LIBUNWIND_CFLAGS"; then
|
||||
pkg_cv_LIBUNWIND_CFLAGS="$LIBUNWIND_CFLAGS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libunwind\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "libunwind") 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_LIBUNWIND_CFLAGS=`$PKG_CONFIG --cflags "libunwind" 2>/dev/null`
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
if test -n "$LIBUNWIND_LIBS"; then
|
||||
pkg_cv_LIBUNWIND_LIBS="$LIBUNWIND_LIBS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libunwind\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "libunwind") 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_LIBUNWIND_LIBS=`$PKG_CONFIG --libs "libunwind" 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
|
||||
LIBUNWIND_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libunwind" 2>&1`
|
||||
else
|
||||
LIBUNWIND_PKG_ERRORS=`$PKG_CONFIG --print-errors "libunwind" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$LIBUNWIND_PKG_ERRORS" >&5
|
||||
|
||||
have_libunwind=no
|
||||
elif test $pkg_failed = untried; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
have_libunwind=no
|
||||
else
|
||||
LIBUNWIND_CFLAGS=$pkg_cv_LIBUNWIND_CFLAGS
|
||||
LIBUNWIND_LIBS=$pkg_cv_LIBUNWIND_LIBS
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
have_libunwind=yes
|
||||
fi
|
||||
if test x$have_libunwind = xyes ; then
|
||||
LIBS="$LIBS $LIBUNWIND_LIBS"
|
||||
fi
|
||||
|
||||
ac_config_files="$ac_config_files Makefile"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
|
14
externals/SDL/test/configure.ac
vendored
14
externals/SDL/test/configure.ac
vendored
@@ -3,7 +3,7 @@ AC_INIT
|
||||
AC_CONFIG_SRCDIR([loopwave.c])
|
||||
|
||||
dnl Detect the canonical build and host environments
|
||||
AC_CONFIG_AUX_DIRS($srcdir/../build-scripts)
|
||||
AC_CONFIG_AUX_DIR([../build-scripts])
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
dnl Check for tools
|
||||
@@ -92,7 +92,7 @@ AC_SUBST(ISWINDOWS)
|
||||
AC_SUBST(ISUNIX)
|
||||
|
||||
dnl Check for SDL
|
||||
SDL_VERSION=2.0.0
|
||||
SDL_VERSION=2.0.18
|
||||
AM_PATH_SDL2($SDL_VERSION,
|
||||
:,
|
||||
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
|
||||
@@ -192,6 +192,16 @@ if test x$have_SDL_ttf = xyes; then
|
||||
fi
|
||||
AC_SUBST(SDL_TTF_LIB)
|
||||
|
||||
dnl Really, SDL2_test should be linking against libunwind (if it found
|
||||
dnl libunwind.h when configured), but SDL2_test is a static library, so
|
||||
dnl there's no way for it to link against it. We could make SDL2 depend on
|
||||
dnl it, but we don't want all SDL2 build to suddenly gain an extra dependency,
|
||||
dnl so just assume that if it's here now, SDL2_test was probably built with it.
|
||||
PKG_CHECK_MODULES(LIBUNWIND, libunwind, have_libunwind=yes, have_libunwind=no)
|
||||
if test x$have_libunwind = xyes ; then
|
||||
LIBS="$LIBS $LIBUNWIND_LIBS"
|
||||
fi
|
||||
|
||||
dnl Finally create all the generated files
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
18
externals/SDL/test/controllermap.c
vendored
18
externals/SDL/test/controllermap.c
vendored
@@ -119,7 +119,7 @@ static int s_arrBindingOrder[] = {
|
||||
SDL_CONTROLLER_BUTTON_PADDLE2,
|
||||
SDL_CONTROLLER_BUTTON_PADDLE3,
|
||||
SDL_CONTROLLER_BUTTON_PADDLE4,
|
||||
-1,
|
||||
SDL_CONTROLLER_BUTTON_TOUCHPAD,
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(s_arrBindingOrder, SDL_arraysize(s_arrBindingOrder) == BINDING_COUNT);
|
||||
|
||||
@@ -167,6 +167,7 @@ static SDL_bool s_bBindingComplete;
|
||||
static SDL_Window *window;
|
||||
static SDL_Renderer *screen;
|
||||
static SDL_bool done = SDL_FALSE;
|
||||
static SDL_bool bind_touchpad = SDL_FALSE;
|
||||
|
||||
SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
@@ -234,6 +235,13 @@ SetCurrentBinding(int iBinding)
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_arrBindingOrder[iBinding] == SDL_CONTROLLER_BUTTON_TOUCHPAD &&
|
||||
!bind_touchpad)
|
||||
{
|
||||
SetCurrentBinding(iBinding + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
s_iCurrentBinding = iBinding;
|
||||
|
||||
pBinding = &s_arrBindings[s_arrBindingOrder[s_iCurrentBinding]];
|
||||
@@ -562,7 +570,7 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||
if ((event.key.keysym.sym != SDLK_ESCAPE)) {
|
||||
break;
|
||||
}
|
||||
/* Fall through to signal quit */
|
||||
SDL_FALLTHROUGH;
|
||||
case SDL_QUIT:
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
@@ -731,6 +739,10 @@ main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argv[1] && SDL_strcmp(argv[1], "--bind-touchpad") == 0) {
|
||||
bind_touchpad = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Create a window to display joystick axis position */
|
||||
window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
|
||||
@@ -755,7 +767,7 @@ main(int argc, char *argv[])
|
||||
if ((event.key.keysym.sym != SDLK_ESCAPE)) {
|
||||
break;
|
||||
}
|
||||
/* Fall through to signal quit */
|
||||
SDL_FALLTHROUGH;
|
||||
case SDL_QUIT:
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
|
10
externals/SDL/test/testatomic.c
vendored
10
externals/SDL/test/testatomic.c
vendored
@@ -19,13 +19,13 @@
|
||||
*/
|
||||
|
||||
static
|
||||
char *
|
||||
tf(SDL_bool tf)
|
||||
const char *
|
||||
tf(SDL_bool _tf)
|
||||
{
|
||||
static char *t = "TRUE";
|
||||
static char *f = "FALSE";
|
||||
static const char *t = "TRUE";
|
||||
static const char *f = "FALSE";
|
||||
|
||||
if (tf)
|
||||
if (_tf)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
20
externals/SDL/test/testautomation_audio.c
vendored
20
externals/SDL/test/testautomation_audio.c
vendored
@@ -498,7 +498,7 @@ 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",
|
||||
const 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;
|
||||
@@ -697,7 +697,7 @@ int audio_openCloseAndGetAudioStatus()
|
||||
SDL_AudioStatus result;
|
||||
int i;
|
||||
int count;
|
||||
char *device;
|
||||
const char *device;
|
||||
SDL_AudioDeviceID id;
|
||||
SDL_AudioSpec desired, obtained;
|
||||
|
||||
@@ -707,7 +707,7 @@ int audio_openCloseAndGetAudioStatus()
|
||||
if (count > 0) {
|
||||
for (i = 0; i < count; i++) {
|
||||
/* Get device name */
|
||||
device = (char *)SDL_GetAudioDeviceName(i, 0);
|
||||
device = 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;
|
||||
@@ -721,7 +721,7 @@ int audio_openCloseAndGetAudioStatus()
|
||||
desired.userdata=NULL;
|
||||
|
||||
/* Open device */
|
||||
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
|
||||
id = SDL_OpenAudioDevice(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) {
|
||||
@@ -755,7 +755,7 @@ int audio_lockUnlockOpenAudioDevice()
|
||||
{
|
||||
int i;
|
||||
int count;
|
||||
char *device;
|
||||
const char *device;
|
||||
SDL_AudioDeviceID id;
|
||||
SDL_AudioSpec desired, obtained;
|
||||
|
||||
@@ -765,7 +765,7 @@ int audio_lockUnlockOpenAudioDevice()
|
||||
if (count > 0) {
|
||||
for (i = 0; i < count; i++) {
|
||||
/* Get device name */
|
||||
device = (char *)SDL_GetAudioDeviceName(i, 0);
|
||||
device = 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;
|
||||
@@ -779,7 +779,7 @@ int audio_lockUnlockOpenAudioDevice()
|
||||
desired.userdata=NULL;
|
||||
|
||||
/* Open device */
|
||||
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
|
||||
id = SDL_OpenAudioDevice(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) {
|
||||
@@ -917,7 +917,7 @@ int audio_openCloseAudioDeviceConnected()
|
||||
int result = -1;
|
||||
int i;
|
||||
int count;
|
||||
char *device;
|
||||
const char *device;
|
||||
SDL_AudioDeviceID id;
|
||||
SDL_AudioSpec desired, obtained;
|
||||
|
||||
@@ -927,7 +927,7 @@ int audio_openCloseAudioDeviceConnected()
|
||||
if (count > 0) {
|
||||
for (i = 0; i < count; i++) {
|
||||
/* Get device name */
|
||||
device = (char *)SDL_GetAudioDeviceName(i, 0);
|
||||
device = 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;
|
||||
@@ -941,7 +941,7 @@ int audio_openCloseAudioDeviceConnected()
|
||||
desired.userdata=NULL;
|
||||
|
||||
/* Open device */
|
||||
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
|
||||
id = SDL_OpenAudioDevice(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) {
|
||||
|
106
externals/SDL/test/testautomation_hints.c
vendored
106
externals/SDL/test/testautomation_hints.c
vendored
@@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
const int _numHintsEnum = 25;
|
||||
char* _HintsEnum[] =
|
||||
const char* _HintsEnum[] =
|
||||
{
|
||||
SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
|
||||
SDL_HINT_FRAMEBUFFER_ACCELERATION,
|
||||
@@ -37,33 +37,33 @@ char* _HintsEnum[] =
|
||||
SDL_HINT_VIDEO_X11_XVIDMODE,
|
||||
SDL_HINT_XINPUT_ENABLED,
|
||||
};
|
||||
char* _HintsVerbose[] =
|
||||
const 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"
|
||||
"SDL_ACCELEROMETER_AS_JOYSTICK",
|
||||
"SDL_FRAMEBUFFER_ACCELERATION",
|
||||
"SDL_GAMECONTROLLERCONFIG",
|
||||
"SDL_GRAB_KEYBOARD",
|
||||
"SDL_IDLE_TIMER_DISABLED",
|
||||
"SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS",
|
||||
"SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK",
|
||||
"SDL_MOUSE_RELATIVE_MODE_WARP",
|
||||
"SDL_ORIENTATIONS",
|
||||
"SDL_RENDER_DIRECT3D_THREADSAFE",
|
||||
"SDL_RENDER_DRIVER",
|
||||
"SDL_RENDER_OPENGL_SHADERS",
|
||||
"SDL_RENDER_SCALE_QUALITY",
|
||||
"SDL_RENDER_VSYNC",
|
||||
"SDL_TIMER_RESOLUTION",
|
||||
"SDL_VIDEO_ALLOW_SCREENSAVER",
|
||||
"SDL_VIDEO_HIGHDPI_DISABLED",
|
||||
"SDL_VIDEO_MAC_FULLSCREEN_SPACES",
|
||||
"SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS",
|
||||
"SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT",
|
||||
"SDL_VIDEO_WIN_D3DCOMPILER",
|
||||
"SDL_VIDEO_X11_XINERAMA",
|
||||
"SDL_VIDEO_X11_XRANDR",
|
||||
"SDL_VIDEO_X11_XVIDMODE",
|
||||
"SDL_XINPUT_ENABLED"
|
||||
};
|
||||
|
||||
|
||||
@@ -75,14 +75,14 @@ char* _HintsVerbose[] =
|
||||
int
|
||||
hints_getHint(void *arg)
|
||||
{
|
||||
char *result1;
|
||||
char *result2;
|
||||
const char *result1;
|
||||
const char *result2;
|
||||
int i;
|
||||
|
||||
|
||||
for (i=0; i<_numHintsEnum; i++) {
|
||||
result1 = (char *)SDL_GetHint((char*)_HintsEnum[i]);
|
||||
result1 = SDL_GetHint(_HintsEnum[i]);
|
||||
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]);
|
||||
result2 = (char *)SDL_GetHint((char *)_HintsVerbose[i]);
|
||||
result2 = SDL_GetHint(_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),
|
||||
@@ -90,7 +90,7 @@ hints_getHint(void *arg)
|
||||
(result1 == NULL) ? "null" : result1,
|
||||
(result2 == NULL) ? "null" : result2);
|
||||
}
|
||||
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
@@ -100,48 +100,52 @@ hints_getHint(void *arg)
|
||||
int
|
||||
hints_setHint(void *arg)
|
||||
{
|
||||
char *originalValue;
|
||||
char *value;
|
||||
char *testValue;
|
||||
const char *originalValue;
|
||||
const char *value;
|
||||
const char *testValue;
|
||||
SDL_bool result;
|
||||
int i, j;
|
||||
|
||||
/* Create random values to set */
|
||||
/* 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]);
|
||||
|
||||
originalValue = SDL_GetHint(_HintsEnum[i]);
|
||||
SDLTest_AssertPass("Call to SDL_GetHint(%s)", _HintsEnum[i]);
|
||||
|
||||
/* Copy the original value, since it will be freed when we set it again */
|
||||
originalValue = originalValue ? SDL_strdup(originalValue) : NULL;
|
||||
|
||||
/* 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);
|
||||
result = SDL_SetHint(_HintsEnum[i], value);
|
||||
SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", _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]);
|
||||
testValue = SDL_GetHint(_HintsEnum[i]);
|
||||
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", _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]);
|
||||
result = SDL_SetHint(_HintsEnum[i], originalValue);
|
||||
SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", _HintsEnum[i]);
|
||||
SDLTest_AssertCheck(
|
||||
result == SDL_TRUE || result == SDL_FALSE,
|
||||
"Verify valid result was returned, got: %i",
|
||||
(int)result);
|
||||
SDL_free((void *)originalValue);
|
||||
}
|
||||
|
||||
SDL_free(value);
|
||||
|
||||
|
||||
SDL_free((void *)value);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
|
20
externals/SDL/test/testautomation_keyboard.c
vendored
20
externals/SDL/test/testautomation_keyboard.c
vendored
@@ -168,8 +168,8 @@ keyboard_getKeyFromScancode(void *arg)
|
||||
int
|
||||
keyboard_getKeyName(void *arg)
|
||||
{
|
||||
char *result;
|
||||
char *expected;
|
||||
const char *result;
|
||||
const char *expected;
|
||||
|
||||
/* Case where key has a 1 character name */
|
||||
expected = "3";
|
||||
@@ -225,8 +225,8 @@ int
|
||||
keyboard_getScancodeNameNegative(void *arg)
|
||||
{
|
||||
SDL_Scancode scancode;
|
||||
char *result;
|
||||
char *expected = "";
|
||||
const char *result;
|
||||
const char *expected = "";
|
||||
|
||||
/* Clear error message */
|
||||
SDL_ClearError();
|
||||
@@ -252,8 +252,8 @@ int
|
||||
keyboard_getKeyNameNegative(void *arg)
|
||||
{
|
||||
SDL_Keycode keycode;
|
||||
char *result;
|
||||
char *expected = "";
|
||||
const char *result;
|
||||
const char *expected = "";
|
||||
|
||||
/* Unknown keycode */
|
||||
keycode = SDLK_UNKNOWN;
|
||||
@@ -305,7 +305,7 @@ keyboard_getSetModState(void *arg)
|
||||
KMOD_NUM |
|
||||
KMOD_CAPS |
|
||||
KMOD_MODE |
|
||||
KMOD_RESERVED;
|
||||
KMOD_SCROLL;
|
||||
|
||||
/* Get state, cache for later reset */
|
||||
result = SDL_GetModState();
|
||||
@@ -612,7 +612,7 @@ _checkInvalidNameError()
|
||||
int
|
||||
keyboard_getScancodeFromNameNegative(void *arg)
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
SDL_Scancode scancode;
|
||||
|
||||
/* Clear error message */
|
||||
@@ -625,9 +625,9 @@ keyboard_getScancodeFromNameNegative(void *arg)
|
||||
if (name == NULL) {
|
||||
return TEST_ABORTED;
|
||||
}
|
||||
scancode = SDL_GetScancodeFromName((const char *)name);
|
||||
scancode = SDL_GetScancodeFromName(name);
|
||||
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
|
||||
SDL_free(name);
|
||||
SDL_free((void *)name);
|
||||
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
|
||||
_checkInvalidNameError();
|
||||
|
||||
|
1
externals/SDL/test/testautomation_mouse.c
vendored
1
externals/SDL/test/testautomation_mouse.c
vendored
@@ -527,6 +527,7 @@ mouse_getMouseFocus(void *arg)
|
||||
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
|
||||
|
||||
/* Pump events to update focus state */
|
||||
SDL_Delay(100);
|
||||
SDL_PumpEvents();
|
||||
SDLTest_AssertPass("SDL_PumpEvents()");
|
||||
|
||||
|
16
externals/SDL/test/testautomation_pixels.c
vendored
16
externals/SDL/test/testautomation_pixels.c
vendored
@@ -45,7 +45,7 @@ Uint32 _RGBPixelFormats[] =
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
SDL_PIXELFORMAT_ARGB2101010
|
||||
};
|
||||
char* _RGBPixelFormatsVerbose[] =
|
||||
const char* _RGBPixelFormatsVerbose[] =
|
||||
{
|
||||
"SDL_PIXELFORMAT_INDEX1LSB",
|
||||
"SDL_PIXELFORMAT_INDEX1MSB",
|
||||
@@ -92,7 +92,7 @@ Uint32 _nonRGBPixelFormats[] =
|
||||
SDL_PIXELFORMAT_NV12,
|
||||
SDL_PIXELFORMAT_NV21
|
||||
};
|
||||
char* _nonRGBPixelFormatsVerbose[] =
|
||||
const char* _nonRGBPixelFormatsVerbose[] =
|
||||
{
|
||||
"SDL_PIXELFORMAT_YV12",
|
||||
"SDL_PIXELFORMAT_IYUV",
|
||||
@@ -110,7 +110,7 @@ Uint32 _invalidPixelFormats[] =
|
||||
0xfffffffe,
|
||||
0xffffffff
|
||||
};
|
||||
char* _invalidPixelFormatsVerbose[] =
|
||||
const char* _invalidPixelFormatsVerbose[] =
|
||||
{
|
||||
"SDL_PIXELFORMAT_UNKNOWN",
|
||||
"SDL_PIXELFORMAT_UNKNOWN"
|
||||
@@ -237,14 +237,14 @@ pixels_getPixelFormatName(void *arg)
|
||||
const char *error;
|
||||
int i;
|
||||
Uint32 format;
|
||||
char* result;
|
||||
const char *result;
|
||||
|
||||
/* Blank/undefined format */
|
||||
format = 0;
|
||||
SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
|
||||
|
||||
/* Get name of format */
|
||||
result = (char *)SDL_GetPixelFormatName(format);
|
||||
result = SDL_GetPixelFormatName(format);
|
||||
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
|
||||
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
|
||||
if (result != NULL) {
|
||||
@@ -259,7 +259,7 @@ pixels_getPixelFormatName(void *arg)
|
||||
SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
|
||||
|
||||
/* Get name of format */
|
||||
result = (char *)SDL_GetPixelFormatName(format);
|
||||
result = SDL_GetPixelFormatName(format);
|
||||
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
|
||||
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
|
||||
if (result != NULL) {
|
||||
@@ -275,7 +275,7 @@ pixels_getPixelFormatName(void *arg)
|
||||
SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
|
||||
|
||||
/* Get name of format */
|
||||
result = (char *)SDL_GetPixelFormatName(format);
|
||||
result = SDL_GetPixelFormatName(format);
|
||||
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
|
||||
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
|
||||
if (result != NULL) {
|
||||
@@ -292,7 +292,7 @@ pixels_getPixelFormatName(void *arg)
|
||||
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||
for (i = 0; i < _numInvalidPixelFormats; i++) {
|
||||
format = _invalidPixelFormats[i];
|
||||
result = (char *)SDL_GetPixelFormatName(format);
|
||||
result = SDL_GetPixelFormatName(format);
|
||||
SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format);
|
||||
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
|
||||
if (result != NULL) {
|
||||
|
4
externals/SDL/test/testautomation_platform.c
vendored
4
externals/SDL/test/testautomation_platform.c
vendored
@@ -384,7 +384,7 @@ int platform_testSetErrorInvalidInput(void *arg)
|
||||
if (lastError != NULL)
|
||||
{
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0,
|
||||
SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0,
|
||||
"SDL_GetError(): expected message len 0, was len: %i",
|
||||
(int) len);
|
||||
}
|
||||
@@ -404,7 +404,7 @@ int platform_testSetErrorInvalidInput(void *arg)
|
||||
if (lastError != NULL)
|
||||
{
|
||||
len = SDL_strlen(lastError);
|
||||
SDLTest_AssertCheck(len == 0,
|
||||
SDLTest_AssertCheck(len == 0 || SDL_strcmp( lastError, "(null)" ) == 0,
|
||||
"SDL_GetError(): expected message len 0, was len: %i",
|
||||
(int) len);
|
||||
}
|
||||
|
6
externals/SDL/test/testautomation_sdltest.c
vendored
6
externals/SDL/test/testautomation_sdltest.c
vendored
@@ -1131,7 +1131,7 @@ sdltest_randomAsciiString(void *arg)
|
||||
SDLTest_AssertCheck(len >= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int) len);
|
||||
nonAsciiCharacters = 0;
|
||||
for (i=0; i<len; i++) {
|
||||
if (iscntrl(result[i])) {
|
||||
if (SDL_iscntrl(result[i])) {
|
||||
nonAsciiCharacters++;
|
||||
}
|
||||
}
|
||||
@@ -1169,7 +1169,7 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg)
|
||||
SDLTest_AssertCheck(len >= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len);
|
||||
nonAsciiCharacters = 0;
|
||||
for (i=0; i<len; i++) {
|
||||
if (iscntrl(result[i])) {
|
||||
if (SDL_iscntrl(result[i])) {
|
||||
nonAsciiCharacters++;
|
||||
}
|
||||
}
|
||||
@@ -1223,7 +1223,7 @@ sdltest_randomAsciiStringOfSize(void *arg)
|
||||
SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", (int) targetLen, (int) len);
|
||||
nonAsciiCharacters = 0;
|
||||
for (i=0; i<len; i++) {
|
||||
if (iscntrl(result[i])) {
|
||||
if (SDL_iscntrl(result[i])) {
|
||||
nonAsciiCharacters++;
|
||||
}
|
||||
}
|
||||
|
32
externals/SDL/test/testautomation_stdlib.c
vendored
32
externals/SDL/test/testautomation_stdlib.c
vendored
@@ -44,6 +44,7 @@ int
|
||||
stdlib_snprintf(void *arg)
|
||||
{
|
||||
int result;
|
||||
int predicted;
|
||||
char text[1024];
|
||||
const char *expected;
|
||||
|
||||
@@ -60,55 +61,86 @@ stdlib_snprintf(void *arg)
|
||||
SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result);
|
||||
|
||||
result = SDL_snprintf(NULL, 0, "%s", "foo");
|
||||
SDLTest_AssertPass("Call to SDL_snprintf(NULL, 0, \"%%s\", \"foo\")");
|
||||
SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result);
|
||||
|
||||
result = SDL_snprintf(text, 2, "%s\n", "foo");
|
||||
expected = "f";
|
||||
SDLTest_AssertPass("Call to SDL_snprintf(\"%%s\\n\", \"foo\") with buffer size 2");
|
||||
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
|
||||
SDLTest_AssertCheck(result == 4, "Check result value, expected: 4, got: %d", result);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%f", 0.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%f", 0.0);
|
||||
expected = "0.000000";
|
||||
SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 0.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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%f", 1.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%.f", 1.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%.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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%#.f", 1.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%#.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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%f", 1.0 + 1.0 / 3.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%+f", 1.0 + 1.0 / 3.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%+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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%.2f", 1.0 + 1.0 / 3.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%.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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%6.2f", 1.0 + 1.0 / 3.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%06.2f", 1.0 + 1.0 / 3.0);
|
||||
predicted = SDL_snprintf(NULL, 0, "%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", (int) SDL_strlen(text), result);
|
||||
SDLTest_AssertCheck(predicted == result, "Check predicted value, expected: %d, got: %d", result, predicted);
|
||||
|
||||
result = SDL_snprintf(text, 5, "%06.2f", 1.0 + 1.0 / 3.0);
|
||||
expected = "001.";
|
||||
|
2
externals/SDL/test/testautomation_surface.c
vendored
2
externals/SDL/test/testautomation_surface.c
vendored
@@ -333,7 +333,7 @@ surface_testCompleteSurfaceConversion(void *arg)
|
||||
SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
SDL_PIXELFORMAT_ARGB2101010,
|
||||
/*SDL_PIXELFORMAT_ARGB2101010,*/ /* SDL_PIXELFORMAT_ARGB2101010 isn't fully supported yet */
|
||||
};
|
||||
SDL_Surface *face = NULL, *cvt1, *cvt2, *final;
|
||||
SDL_PixelFormat *fmt1, *fmt2;
|
||||
|
2
externals/SDL/test/testcustomcursor.c
vendored
2
externals/SDL/test/testcustomcursor.c
vendored
@@ -128,7 +128,7 @@ init_system_cursor(const char *image[])
|
||||
}
|
||||
}
|
||||
}
|
||||
sscanf(image[4+row], "%d,%d", &hot_x, &hot_y);
|
||||
SDL_sscanf(image[4+row], "%d,%d", &hot_x, &hot_y);
|
||||
return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
|
||||
}
|
||||
|
||||
|
33
externals/SDL/test/testdraw2.c
vendored
33
externals/SDL/test/testdraw2.c
vendored
@@ -32,6 +32,8 @@ static int cycle_direction = 1;
|
||||
static int current_alpha = 255;
|
||||
static int current_color = 255;
|
||||
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
|
||||
static Uint32 next_fps_check, frames;
|
||||
static const Uint32 fps_check_delay = 5000;
|
||||
|
||||
int done;
|
||||
|
||||
@@ -178,6 +180,7 @@ DrawRects(SDL_Renderer * renderer)
|
||||
void
|
||||
loop()
|
||||
{
|
||||
Uint32 now;
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
||||
@@ -203,13 +206,23 @@ loop()
|
||||
emscripten_cancel_main_loop();
|
||||
}
|
||||
#endif
|
||||
frames++;
|
||||
now = SDL_GetTicks();
|
||||
if (SDL_TICKS_PASSED(now, next_fps_check)) {
|
||||
/* Print out some timing information */
|
||||
const Uint32 then = next_fps_check - fps_check_delay;
|
||||
const double fps = ((double) frames * 1000) / (now - then);
|
||||
SDL_Log("%2.2f frames per second\n", fps);
|
||||
next_fps_check = now + fps_check_delay;
|
||||
frames = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -256,7 +269,12 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
if (consumed < 0) {
|
||||
static const char *options[] = { "[--blend none|blend|add|mod]", "[--cyclecolor]", "[--cyclealpha]", NULL };
|
||||
static const char *options[] = {
|
||||
"[--blend none|blend|add|mod]",
|
||||
"[--cyclecolor]",
|
||||
"[--cyclealpha]",
|
||||
"[num_objects]",
|
||||
NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
@@ -278,27 +296,20 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Main render loop */
|
||||
frames = 0;
|
||||
then = SDL_GetTicks();
|
||||
next_fps_check = SDL_GetTicks() + fps_check_delay;
|
||||
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;
|
||||
}
|
||||
|
||||
|
19
externals/SDL/test/testgamecontroller.c
vendored
19
externals/SDL/test/testgamecontroller.c
vendored
@@ -168,6 +168,14 @@ static void AddController(int device_index, SDL_bool verbose)
|
||||
SDL_GameControllerSetSensorEnabled(gamecontroller, SDL_SENSOR_GYRO, SDL_TRUE);
|
||||
}
|
||||
|
||||
if (SDL_GameControllerHasRumble(gamecontroller)) {
|
||||
SDL_Log("Rumble supported");
|
||||
}
|
||||
|
||||
if (SDL_GameControllerHasRumbleTriggers(gamecontroller)) {
|
||||
SDL_Log("Trigger rumble supported");
|
||||
}
|
||||
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
@@ -236,12 +244,12 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
return texture;
|
||||
}
|
||||
|
||||
static Uint16 ConvertAxisToRumble(Sint16 axis)
|
||||
static Uint16 ConvertAxisToRumble(Sint16 axisval)
|
||||
{
|
||||
/* Only start rumbling if the axis is past the halfway point */
|
||||
const Sint16 half_axis = (Sint16)SDL_ceil(SDL_JOYSTICK_AXIS_MAX / 2.0f);
|
||||
if (axis > half_axis) {
|
||||
return (Uint16)(axis - half_axis) * 4;
|
||||
if (axisval > half_axis) {
|
||||
return (Uint16)(axisval - half_axis) * 4;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -386,7 +394,7 @@ loop(void *arg)
|
||||
if (event.key.keysym.sym != SDLK_ESCAPE) {
|
||||
break;
|
||||
}
|
||||
/* Fall through to signal quit */
|
||||
SDL_FALLTHROUGH;
|
||||
case SDL_QUIT:
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
@@ -522,6 +530,7 @@ main(int argc, char *argv[])
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
SDL_SetHint(SDL_HINT_LINUX_JOYSTICK_DEADZONES, "1");
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -531,7 +540,7 @@ main(int argc, char *argv[])
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt");
|
||||
|
||||
/* Print information about the mappings */
|
||||
|
303
externals/SDL/test/testgeometry.c
vendored
Executable file
303
externals/SDL/test/testgeometry.c
vendored
Executable file
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 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 a RGB triangle, with texture */
|
||||
|
||||
#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;
|
||||
static SDL_bool use_texture = SDL_FALSE;
|
||||
static SDL_Texture **sprites;
|
||||
static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
|
||||
static double angle = 0.0;
|
||||
static int sprite_w, sprite_h;
|
||||
|
||||
int done;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
quit(int rc)
|
||||
{
|
||||
SDL_free(sprites);
|
||||
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);
|
||||
}
|
||||
if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
SDL_DestroyTexture(sprites[i]);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
loop()
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
||||
/* Check for events */
|
||||
while (SDL_PollEvent(&event)) {
|
||||
|
||||
if (event.type == SDL_MOUSEMOTION) {
|
||||
if (event.motion.state) {
|
||||
int xrel, yrel;
|
||||
int window_w, window_h;
|
||||
SDL_Window *window = SDL_GetWindowFromID(event.motion.windowID);
|
||||
SDL_GetWindowSize(window, &window_w, &window_h);
|
||||
xrel = event.motion.xrel;
|
||||
yrel = event.motion.yrel;
|
||||
if (event.motion.y < window_h / 2) {
|
||||
angle += xrel;
|
||||
} else {
|
||||
angle -= xrel;
|
||||
}
|
||||
if (event.motion.x < window_w / 2) {
|
||||
angle -= yrel;
|
||||
} else {
|
||||
angle += yrel;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
|
||||
{
|
||||
SDL_Rect viewport;
|
||||
SDL_Vertex verts[3];
|
||||
double a;
|
||||
double d;
|
||||
int cx, cy;
|
||||
|
||||
/* Query the sizes */
|
||||
SDL_RenderGetViewport(renderer, &viewport);
|
||||
SDL_zeroa(verts);
|
||||
cx = viewport.x + viewport.w / 2;
|
||||
cy = viewport.y + viewport.h / 2;
|
||||
d = (viewport.w + viewport.h) / 5;
|
||||
|
||||
a = (angle * 3.1415) / 180.0;
|
||||
verts[0].position.x = cx + d * SDL_cos(a);
|
||||
verts[0].position.y = cy + d * SDL_sin(a);
|
||||
verts[0].color.r = 0xFF;
|
||||
verts[0].color.g = 0;
|
||||
verts[0].color.b = 0;
|
||||
verts[0].color.a = 0xFF;
|
||||
|
||||
a = ((angle + 120) * 3.1415) / 180.0;
|
||||
verts[1].position.x = cx + d * SDL_cos(a);
|
||||
verts[1].position.y = cy + d * SDL_sin(a);
|
||||
verts[1].color.r = 0;
|
||||
verts[1].color.g = 0xFF;
|
||||
verts[1].color.b = 0;
|
||||
verts[1].color.a = 0xFF;
|
||||
|
||||
a = ((angle + 240) * 3.1415) / 180.0;
|
||||
verts[2].position.x = cx + d * SDL_cos(a);
|
||||
verts[2].position.y = cy + d * SDL_sin(a);
|
||||
verts[2].color.r = 0;
|
||||
verts[2].color.g = 0;
|
||||
verts[2].color.b = 0xFF;
|
||||
verts[2].color.a = 0xFF;
|
||||
|
||||
if (use_texture) {
|
||||
verts[0].tex_coord.x = 0.5;
|
||||
verts[0].tex_coord.y = 0.0;
|
||||
verts[1].tex_coord.x = 1.0;
|
||||
verts[1].tex_coord.y = 1.0;
|
||||
verts[2].tex_coord.x = 0.0;
|
||||
verts[2].tex_coord.y = 1.0;
|
||||
}
|
||||
|
||||
SDL_RenderGeometry(renderer, sprites[i], verts, 3, NULL, 0);
|
||||
}
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done) {
|
||||
emscripten_cancel_main_loop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
const char *icon = "icon.bmp";
|
||||
Uint32 then, now, frames;
|
||||
|
||||
/* 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], "--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], "--use-texture") == 0) {
|
||||
use_texture = SDL_TRUE;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed < 0) {
|
||||
static const char *options[] = { "[--blend none|blend|add|mod]", "[--use-texture]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
i += consumed;
|
||||
}
|
||||
if (!SDLTest_CommonInit(state)) {
|
||||
return 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);
|
||||
}
|
||||
/* 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);
|
||||
sprites[i] = NULL;
|
||||
}
|
||||
if (use_texture) {
|
||||
if (LoadSprite(icon) < 0) {
|
||||
quit(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
/* 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: */
|
2
externals/SDL/test/testgesture.c
vendored
2
externals/SDL/test/testgesture.c
vendored
@@ -215,7 +215,7 @@ loop(void)
|
||||
|
||||
#if VERBOSE
|
||||
case SDL_FINGERMOTION:
|
||||
SDL_Log("Finger: %"SDL_PRIs64",x: %f, y: %f",event.tfinger.fingerId,
|
||||
SDL_Log("Finger: %"SDL_PRIs64", x: %f, y: %f",event.tfinger.fingerId,
|
||||
event.tfinger.x,event.tfinger.y);
|
||||
break;
|
||||
|
||||
|
4
externals/SDL/test/testgl2.c
vendored
4
externals/SDL/test/testgl2.c
vendored
@@ -238,10 +238,10 @@ main(int argc, char *argv[])
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (consumed == 0) {
|
||||
if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i+1 < argc) {
|
||||
fsaa = atoi(argv[i+1]);
|
||||
fsaa = SDL_atoi(argv[i+1]);
|
||||
consumed = 2;
|
||||
} else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) {
|
||||
accel = atoi(argv[i+1]);
|
||||
accel = SDL_atoi(argv[i+1]);
|
||||
consumed = 2;
|
||||
} else {
|
||||
consumed = -1;
|
||||
|
2
externals/SDL/test/testgles2.c
vendored
2
externals/SDL/test/testgles2.c
vendored
@@ -22,8 +22,10 @@
|
||||
|
||||
#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) \
|
||||
|| defined(__WINDOWS__) || defined(__LINUX__)
|
||||
#ifndef HAVE_OPENGLES2
|
||||
#define HAVE_OPENGLES2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENGLES2
|
||||
|
||||
|
9
externals/SDL/test/testgles2_sdf.c
vendored
9
externals/SDL/test/testgles2_sdf.c
vendored
@@ -163,11 +163,10 @@ process_shader(GLuint *shader, const char * source, GLint shader_type)
|
||||
}
|
||||
|
||||
/* Notes on a_angle:
|
||||
* It is a vector containing sin and cos for rotation matrix
|
||||
* To get correct rotation for most cases when a_angle is disabled cos
|
||||
value is decremented by 1.0 to get proper output with 0.0 which is
|
||||
default value
|
||||
*/
|
||||
* It is a vector containing sine and cosine for rotation matrix
|
||||
* To get correct rotation for most cases when a_angle is disabled cosine
|
||||
* value is decremented by 1.0 to get proper output with 0.0 which is default value
|
||||
*/
|
||||
static const Uint8 GLES2_VertexSrc_Default_[] = " \
|
||||
uniform mat4 u_projection; \
|
||||
attribute vec2 a_position; \
|
||||
|
24
externals/SDL/test/testhaptic.c
vendored
24
externals/SDL/test/testhaptic.c
vendored
@@ -14,10 +14,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
/*
|
||||
* includes
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* strstr */
|
||||
#include <ctype.h> /* isdigit */
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#ifndef SDL_HAPTIC_DISABLED
|
||||
@@ -29,7 +25,7 @@ static SDL_Haptic *haptic;
|
||||
* prototypes
|
||||
*/
|
||||
static void abort_execution(void);
|
||||
static void HapticPrintSupported(SDL_Haptic * haptic);
|
||||
static void HapticPrintSupported(SDL_Haptic *);
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,7 +51,7 @@ main(int argc, char **argv)
|
||||
index = -1;
|
||||
if (argc > 1) {
|
||||
name = argv[1];
|
||||
if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
|
||||
if ((SDL_strcmp(name, "--help") == 0) || (SDL_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",
|
||||
@@ -63,9 +59,9 @@ main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = strlen(name);
|
||||
if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) {
|
||||
index = atoi(name);
|
||||
i = SDL_strlen(name);
|
||||
if ((i < 3) && SDL_isdigit(name[0]) && ((i == 1) || SDL_isdigit(name[1]))) {
|
||||
index = SDL_atoi(name);
|
||||
name = NULL;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +78,7 @@ main(int argc, char **argv)
|
||||
/* Try to find matching device */
|
||||
else {
|
||||
for (i = 0; i < SDL_NumHaptics(); i++) {
|
||||
if (strstr(SDL_HapticName(i), name) != NULL)
|
||||
if (SDL_strstr(SDL_HapticName(i), name) != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -110,7 +106,7 @@ main(int argc, char **argv)
|
||||
SDL_ClearError();
|
||||
|
||||
/* Create effects. */
|
||||
memset(&efx, 0, sizeof(efx));
|
||||
SDL_memset(&efx, 0, sizeof(efx));
|
||||
nefx = 0;
|
||||
supported = SDL_HapticQuery(haptic);
|
||||
|
||||
@@ -314,13 +310,13 @@ abort_execution(void)
|
||||
* Displays information about the haptic device.
|
||||
*/
|
||||
static void
|
||||
HapticPrintSupported(SDL_Haptic * haptic)
|
||||
HapticPrintSupported(SDL_Haptic * ptr)
|
||||
{
|
||||
unsigned int supported;
|
||||
|
||||
supported = SDL_HapticQuery(haptic);
|
||||
supported = SDL_HapticQuery(ptr);
|
||||
SDL_Log(" Supported effects [%d effects, %d playing]:\n",
|
||||
SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic));
|
||||
SDL_HapticNumEffects(ptr), SDL_HapticNumEffectsPlaying(ptr));
|
||||
if (supported & SDL_HAPTIC_CONSTANT)
|
||||
SDL_Log(" constant\n");
|
||||
if (supported & SDL_HAPTIC_SINE)
|
||||
|
10
externals/SDL/test/testiconv.c
vendored
10
externals/SDL/test/testiconv.c
vendored
@@ -42,6 +42,8 @@ main(int argc, char *argv[])
|
||||
"UCS4",
|
||||
"UCS-4",
|
||||
};
|
||||
|
||||
const char * fname;
|
||||
char buffer[BUFSIZ];
|
||||
char *ucs4;
|
||||
char *test[2];
|
||||
@@ -52,12 +54,10 @@ main(int argc, char *argv[])
|
||||
/* 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");
|
||||
fname = (argc < 2) ? "utf8.txt" : argv[1];
|
||||
file = fopen(fname, "rb");
|
||||
if (!file) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", fname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
4
externals/SDL/test/testime.c
vendored
4
externals/SDL/test/testime.c
vendored
@@ -648,12 +648,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
for (argc--, argv++; argc > 0; argc--, argv++)
|
||||
{
|
||||
if (strcmp(argv[0], "--help") == 0) {
|
||||
if (SDL_strcmp(argv[0], "--help") == 0) {
|
||||
usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[0], "--font") == 0)
|
||||
else if (SDL_strcmp(argv[0], "--font") == 0)
|
||||
{
|
||||
argc--;
|
||||
argv++;
|
||||
|
31
externals/SDL/test/testjoystick.c
vendored
31
externals/SDL/test/testjoystick.c
vendored
@@ -38,14 +38,14 @@ static SDL_Joystick *joystick = NULL;
|
||||
static SDL_bool done = SDL_FALSE;
|
||||
|
||||
static void
|
||||
PrintJoystick(SDL_Joystick *joystick)
|
||||
PrintJoystick(SDL_Joystick *joy)
|
||||
{
|
||||
const char *type;
|
||||
char guid[64];
|
||||
|
||||
SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), guid, sizeof (guid));
|
||||
switch (SDL_JoystickGetType(joystick)) {
|
||||
SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joy)) == joy);
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), guid, sizeof (guid));
|
||||
switch (SDL_JoystickGetType(joy)) {
|
||||
case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
|
||||
type = "Game Controller";
|
||||
break;
|
||||
@@ -78,15 +78,18 @@ PrintJoystick(SDL_Joystick *joystick)
|
||||
break;
|
||||
}
|
||||
SDL_Log("Joystick\n");
|
||||
SDL_Log(" name: %s\n", SDL_JoystickName(joystick));
|
||||
SDL_Log(" type: %s\n", type);
|
||||
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_Log(" VID/PID: 0x%.4x/0x%.4x\n", SDL_JoystickGetVendor(joystick), SDL_JoystickGetProduct(joystick));
|
||||
SDL_Log(" name: %s\n", SDL_JoystickName(joy));
|
||||
SDL_Log(" type: %s\n", type);
|
||||
SDL_Log(" LED: %s\n", SDL_JoystickHasLED(joy) ? "yes" : "no");
|
||||
SDL_Log(" rumble: %s\n", SDL_JoystickHasRumble(joy) ? "yes" : "no");
|
||||
SDL_Log("trigger rumble: %s\n", SDL_JoystickHasRumbleTriggers(joy) ? "yes" : "no");
|
||||
SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joy));
|
||||
SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joy));
|
||||
SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joy));
|
||||
SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joy));
|
||||
SDL_Log(" instance id: %d\n", SDL_JoystickInstanceID(joy));
|
||||
SDL_Log(" guid: %s\n", guid);
|
||||
SDL_Log(" VID/PID: 0x%.4x/0x%.4x\n", SDL_JoystickGetVendor(joy), SDL_JoystickGetProduct(joy));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -183,7 +186,7 @@ loop(void *arg)
|
||||
(event.key.keysym.sym != SDLK_AC_BACK)) {
|
||||
break;
|
||||
}
|
||||
/* Fall through to signal quit */
|
||||
SDL_FALLTHROUGH;
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_QUIT:
|
||||
|
2
externals/SDL/test/testloadso.c
vendored
2
externals/SDL/test/testloadso.c
vendored
@@ -44,7 +44,7 @@ main(int argc, char *argv[])
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "--hello") == 0) {
|
||||
if (SDL_strcmp(argv[1], "--hello") == 0) {
|
||||
hello = 1;
|
||||
libname = argv[2];
|
||||
symname = "puts";
|
||||
|
8
externals/SDL/test/testmessage.c
vendored
8
externals/SDL/test/testmessage.c
vendored
@@ -61,9 +61,9 @@ button_messagebox(void *eventNumber)
|
||||
if (success == -1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
|
||||
if (eventNumber) {
|
||||
SDL_UserEvent event;
|
||||
SDL_Event event;
|
||||
event.type = (intptr_t)eventNumber;
|
||||
SDL_PushEvent((SDL_Event*)&event);
|
||||
SDL_PushEvent(&event);
|
||||
return 1;
|
||||
} else {
|
||||
quit(2);
|
||||
@@ -72,9 +72,9 @@ button_messagebox(void *eventNumber)
|
||||
SDL_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel" : "OK");
|
||||
|
||||
if (eventNumber) {
|
||||
SDL_UserEvent event;
|
||||
SDL_Event event;
|
||||
event.type = (intptr_t)eventNumber;
|
||||
SDL_PushEvent((SDL_Event*)&event);
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
193
externals/SDL/test/testmouse.c
vendored
Executable file
193
externals/SDL/test/testmouse.c
vendored
Executable file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 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"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* exit() */
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
#define SCREEN_WIDTH 320
|
||||
#define SCREEN_HEIGHT 480
|
||||
#else
|
||||
#define SCREEN_WIDTH 640
|
||||
#define SCREEN_HEIGHT 480
|
||||
#endif
|
||||
|
||||
static SDL_Window *window;
|
||||
|
||||
typedef struct _Line {
|
||||
struct _Line *next;
|
||||
|
||||
int x1, y1, x2, y2;
|
||||
Uint8 r, g, b;
|
||||
} Line;
|
||||
|
||||
static Line *active = NULL;
|
||||
static Line *lines = NULL;
|
||||
static int buttons = 0;
|
||||
|
||||
static SDL_bool done = SDL_FALSE;
|
||||
|
||||
void
|
||||
DrawLine(SDL_Renderer * renderer, Line * line)
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, line->r, line->g, line->b, 255);
|
||||
SDL_RenderDrawLine(renderer, line->x1, line->y1, line->x2, line->y2);
|
||||
}
|
||||
|
||||
void
|
||||
DrawLines(SDL_Renderer * renderer)
|
||||
{
|
||||
Line *next = lines;
|
||||
while (next != NULL) {
|
||||
DrawLine(renderer, next);
|
||||
next = next->next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AppendLine(Line *line)
|
||||
{
|
||||
if (lines) {
|
||||
Line *next = lines;
|
||||
while (next->next != NULL) {
|
||||
next = next->next;
|
||||
}
|
||||
next->next = line;
|
||||
} else {
|
||||
lines = line;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
loop(void *arg)
|
||||
{
|
||||
SDL_Renderer *renderer = (SDL_Renderer *)arg;
|
||||
SDL_Event event;
|
||||
|
||||
/* Check for events */
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
if (!active)
|
||||
break;
|
||||
|
||||
active->x2 = event.motion.x;
|
||||
active->y2 = event.motion.y;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (!active) {
|
||||
active = SDL_calloc(1, sizeof(*active));
|
||||
active->x1 = active->x2 = event.button.x;
|
||||
active->y1 = active->y2 = event.button.y;
|
||||
}
|
||||
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT: active->r = 255; buttons |= SDL_BUTTON_LMASK; break;
|
||||
case SDL_BUTTON_MIDDLE: active->g = 255; buttons |= SDL_BUTTON_MMASK; break;
|
||||
case SDL_BUTTON_RIGHT: active->b = 255; buttons |= SDL_BUTTON_RMASK; break;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (!active)
|
||||
break;
|
||||
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT: buttons &= ~SDL_BUTTON_LMASK; break;
|
||||
case SDL_BUTTON_MIDDLE: buttons &= ~SDL_BUTTON_MMASK; break;
|
||||
case SDL_BUTTON_RIGHT: buttons &= ~SDL_BUTTON_RMASK; break;
|
||||
}
|
||||
|
||||
if (buttons == 0) {
|
||||
AppendLine(active);
|
||||
active = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
DrawLines(renderer);
|
||||
if (active)
|
||||
DrawLine(renderer, active);
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done) {
|
||||
emscripten_cancel_main_loop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
/* 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) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Create a window to display joystick axis position */
|
||||
window = SDL_CreateWindow("Mouse 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;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
if (renderer == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
|
||||
SDL_DestroyWindow(window);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Main render loop */
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop_arg(loop, renderer, 0, 1);
|
||||
#else
|
||||
while (!done) {
|
||||
loop(renderer);
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
8
externals/SDL/test/testmultiaudio.c
vendored
8
externals/SDL/test/testmultiaudio.c
vendored
@@ -180,13 +180,11 @@ main(int argc, char **argv)
|
||||
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";
|
||||
}
|
||||
const char *file = (argc < 2) ? "sample.wav" : argv[1];
|
||||
|
||||
/* 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],
|
||||
if (SDL_LoadWAV(file, &spec, &sound, &soundlen) == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file,
|
||||
SDL_GetError());
|
||||
} else {
|
||||
test_multi_audio(devcount);
|
||||
|
2
externals/SDL/test/testnative.c
vendored
2
externals/SDL/test/testnative.c
vendored
@@ -53,7 +53,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
SDL_Texture *
|
||||
LoadSprite(SDL_Renderer *renderer, char *file)
|
||||
LoadSprite(SDL_Renderer *renderer, const char *file)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *sprite;
|
||||
|
44
externals/SDL/test/testnativeos2.c
vendored
44
externals/SDL/test/testnativeos2.c
vendored
@@ -14,46 +14,44 @@
|
||||
|
||||
#ifdef TEST_NATIVE_OS2
|
||||
|
||||
#define WIN_CLIENT_CLASS "SDL Test"
|
||||
#define WIN_CLIENT_CLASS "SDL Test"
|
||||
|
||||
static void *CreateWindowNative(int w, int h);
|
||||
static void DestroyWindowNative(void *window);
|
||||
|
||||
NativeWindowFactory OS2WindowFactory = {
|
||||
"DIVE",
|
||||
CreateWindowNative,
|
||||
DestroyWindowNative
|
||||
"DIVE",
|
||||
CreateWindowNative,
|
||||
DestroyWindowNative
|
||||
};
|
||||
|
||||
static void *CreateWindowNative(int w, int h)
|
||||
{
|
||||
HWND hwnd;
|
||||
HWND hwndFrame;
|
||||
ULONG ulFrameFlags = FCF_TASKLIST | FCF_DLGBORDER | FCF_TITLEBAR |
|
||||
FCF_SYSMENU | FCF_SHELLPOSITION |
|
||||
FCF_SIZEBORDER | FCF_MINBUTTON | FCF_MAXBUTTON;
|
||||
HWND hwnd, hwndFrame;
|
||||
ULONG ulFrameFlags = FCF_TASKLIST | FCF_DLGBORDER | FCF_TITLEBAR |
|
||||
FCF_SYSMENU | FCF_SHELLPOSITION |
|
||||
FCF_SIZEBORDER | FCF_MINBUTTON | FCF_MAXBUTTON;
|
||||
|
||||
WinRegisterClass( 0, WIN_CLIENT_CLASS, WinDefWindowProc,
|
||||
CS_SIZEREDRAW | CS_MOVENOTIFY,
|
||||
sizeof(ULONG) ); // We should have minimum 4 bytes.
|
||||
WinRegisterClass(0, WIN_CLIENT_CLASS, WinDefWindowProc,
|
||||
CS_SIZEREDRAW | CS_MOVENOTIFY,
|
||||
sizeof(ULONG)); /* We should have minimum 4 bytes. */
|
||||
|
||||
hwndFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &ulFrameFlags,
|
||||
WIN_CLIENT_CLASS, "SDL Test", 0, 0, 1, &hwnd );
|
||||
if ( hwndFrame == NULLHANDLE )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
hwndFrame = WinCreateStdWindow(HWND_DESKTOP, 0, &ulFrameFlags,
|
||||
WIN_CLIENT_CLASS, "SDL Test", 0, 0, 1, &hwnd);
|
||||
if (hwndFrame == NULLHANDLE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WinSetWindowPos( hwndFrame, HWND_TOP, 0, 0, w, h,
|
||||
SWP_ZORDER | SWP_ACTIVATE | SWP_SIZE | SWP_SHOW );
|
||||
WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, w, h,
|
||||
SWP_ZORDER | SWP_ACTIVATE | SWP_SIZE | SWP_SHOW);
|
||||
|
||||
return (void *)hwndFrame; // We may returns client or frame window handle
|
||||
// for SDL_CreateWindowFrom().
|
||||
return (void *)hwndFrame; /* We may return client or frame window
|
||||
handle for SDL_CreateWindowFrom(). */
|
||||
}
|
||||
|
||||
static void DestroyWindowNative(void *window)
|
||||
{
|
||||
WinDestroyWindow( (HWND)window );
|
||||
WinDestroyWindow((HWND) window);
|
||||
}
|
||||
|
||||
#endif /* TEST_NATIVE_OS2 */
|
||||
|
4
externals/SDL/test/testpower.c
vendored
4
externals/SDL/test/testpower.c
vendored
@@ -19,7 +19,7 @@ report_power(void)
|
||||
{
|
||||
int seconds, percent;
|
||||
const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
|
||||
char *statestr = NULL;
|
||||
const char *statestr = NULL;
|
||||
|
||||
SDL_Log("SDL-reported power info...\n");
|
||||
switch (state) {
|
||||
@@ -55,7 +55,7 @@ report_power(void)
|
||||
SDL_Log("Time left: unknown\n");
|
||||
} else {
|
||||
SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
|
||||
(int) (seconds % 60));
|
||||
(int) (seconds % 60));
|
||||
}
|
||||
}
|
||||
|
||||
|
2
externals/SDL/test/testrendertarget.c
vendored
2
externals/SDL/test/testrendertarget.c
vendored
@@ -46,7 +46,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *texture;
|
||||
|
8
externals/SDL/test/testrumble.c
vendored
8
externals/SDL/test/testrumble.c
vendored
@@ -25,10 +25,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
/*
|
||||
* includes
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* strstr */
|
||||
#include <ctype.h> /* isdigit */
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#ifndef SDL_HAPTIC_DISABLED
|
||||
@@ -56,7 +52,7 @@ main(int argc, char **argv)
|
||||
if (argc > 1) {
|
||||
size_t l;
|
||||
name = argv[1];
|
||||
if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
|
||||
if ((SDL_strcmp(name, "--help") == 0) || (SDL_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",
|
||||
@@ -83,7 +79,7 @@ main(int argc, char **argv)
|
||||
/* Try to find matching device */
|
||||
else {
|
||||
for (i = 0; i < SDL_NumHaptics(); i++) {
|
||||
if (strstr(SDL_HapticName(i), name) != NULL)
|
||||
if (SDL_strstr(SDL_HapticName(i), name) != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
|
2
externals/SDL/test/testscale.c
vendored
2
externals/SDL/test/testscale.c
vendored
@@ -47,7 +47,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *texture;
|
||||
|
2
externals/SDL/test/testsem.c
vendored
2
externals/SDL/test/testsem.c
vendored
@@ -262,7 +262,7 @@ main(int argc, char **argv)
|
||||
signal(SIGTERM, killed);
|
||||
signal(SIGINT, killed);
|
||||
|
||||
init_sem = atoi(argv[1]);
|
||||
init_sem = SDL_atoi(argv[1]);
|
||||
if (init_sem > 0) {
|
||||
TestRealWorld(init_sem);
|
||||
}
|
||||
|
219
externals/SDL/test/testsprite2.c
vendored
219
externals/SDL/test/testsprite2.c
vendored
@@ -39,6 +39,7 @@ static int sprite_w, sprite_h;
|
||||
static SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND;
|
||||
static Uint32 next_fps_check, frames;
|
||||
static const Uint32 fps_check_delay = 5000;
|
||||
static int use_rendergeometry = 0;
|
||||
|
||||
/* Number of iterations to move sprites - used for visual tests. */
|
||||
/* -1: infinite random moves (default); >=0: enables N deterministic moves */
|
||||
@@ -175,7 +176,38 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite)
|
||||
temp.y = 1;
|
||||
temp.w = sprite_w;
|
||||
temp.h = sprite_h;
|
||||
SDL_RenderFillRect(renderer, &temp);
|
||||
if (use_rendergeometry == 0) {
|
||||
SDL_RenderFillRect(renderer, &temp);
|
||||
} else {
|
||||
/* Draw two triangles, filled, uniform */
|
||||
SDL_Color color;
|
||||
SDL_Vertex verts[3];
|
||||
SDL_zeroa(verts);
|
||||
color.r = 0xFF;
|
||||
color.g = 0xFF;
|
||||
color.b = 0xFF;
|
||||
color.a = 0xFF;
|
||||
|
||||
verts[0].position.x = (float)temp.x;
|
||||
verts[0].position.y = (float)temp.y;
|
||||
verts[0].color = color;
|
||||
|
||||
verts[1].position.x = (float)temp.x + temp.w;
|
||||
verts[1].position.y = (float)temp.y;
|
||||
verts[1].color = color;
|
||||
|
||||
verts[2].position.x = (float)temp.x + temp.w;
|
||||
verts[2].position.y = (float)temp.y + temp.h;
|
||||
verts[2].color = color;
|
||||
|
||||
SDL_RenderGeometry(renderer, NULL, verts, 3, NULL, 0);
|
||||
|
||||
verts[1].position.x = (float)temp.x;
|
||||
verts[1].position.y = (float)temp.y + temp.h;
|
||||
verts[1].color = color;
|
||||
|
||||
SDL_RenderGeometry(renderer, NULL, verts, 3, NULL, 0);
|
||||
}
|
||||
SDL_RenderCopy(renderer, sprite, NULL, &temp);
|
||||
temp.x = viewport.w-sprite_w-1;
|
||||
temp.y = 1;
|
||||
@@ -220,7 +252,7 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Countdown sprite-move iterations and disable color changes at iteration end - used for visual tests. */
|
||||
if (iterations > 0) {
|
||||
iterations--;
|
||||
@@ -232,11 +264,160 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite)
|
||||
}
|
||||
|
||||
/* Draw sprites */
|
||||
for (i = 0; i < num_sprites; ++i) {
|
||||
position = &positions[i];
|
||||
if (use_rendergeometry == 0) {
|
||||
for (i = 0; i < num_sprites; ++i) {
|
||||
position = &positions[i];
|
||||
|
||||
/* Blit the sprite onto the screen */
|
||||
SDL_RenderCopy(renderer, sprite, NULL, position);
|
||||
/* Blit the sprite onto the screen */
|
||||
SDL_RenderCopy(renderer, sprite, NULL, position);
|
||||
}
|
||||
} else if (use_rendergeometry == 1) {
|
||||
/*
|
||||
* 0--1
|
||||
* | /|
|
||||
* |/ |
|
||||
* 3--2
|
||||
*
|
||||
* Draw sprite2 as triangles that can be recombined as rect by software renderer
|
||||
*/
|
||||
SDL_Vertex *verts = (SDL_Vertex *) SDL_malloc(num_sprites * sizeof (SDL_Vertex) * 6);
|
||||
SDL_Vertex *verts2 = verts;
|
||||
if (verts) {
|
||||
SDL_Color color;
|
||||
SDL_GetTextureColorMod(sprite, &color.r, &color.g, &color.b);
|
||||
SDL_GetTextureAlphaMod(sprite, &color.a);
|
||||
for (i = 0; i < num_sprites; ++i) {
|
||||
position = &positions[i];
|
||||
/* 0 */
|
||||
verts->position.x = (float)position->x;
|
||||
verts->position.y = (float)position->y;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 0.0f;
|
||||
verts->tex_coord.y = 0.0f;
|
||||
verts++;
|
||||
/* 1 */
|
||||
verts->position.x = (float)position->x + position->w;
|
||||
verts->position.y = (float)position->y;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 1.0f;
|
||||
verts->tex_coord.y = 0.0f;
|
||||
verts++;
|
||||
/* 2 */
|
||||
verts->position.x = (float)position->x + position->w;
|
||||
verts->position.y = (float)position->y + position->h;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 1.0f;
|
||||
verts->tex_coord.y = 1.0f;
|
||||
verts++;
|
||||
/* 0 */
|
||||
verts->position.x = (float)position->x;
|
||||
verts->position.y = (float)position->y;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 0.0f;
|
||||
verts->tex_coord.y = 0.0f;
|
||||
verts++;
|
||||
/* 2 */
|
||||
verts->position.x = (float)position->x + position->w;
|
||||
verts->position.y = (float)position->y + position->h;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 1.0f;
|
||||
verts->tex_coord.y = 1.0f;
|
||||
verts++;
|
||||
/* 3 */
|
||||
verts->position.x = (float)position->x;
|
||||
verts->position.y = (float)position->y + position->h;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 0.0f;
|
||||
verts->tex_coord.y = 1.0f;
|
||||
verts++;
|
||||
}
|
||||
|
||||
/* Blit sprites as triangles onto the screen */
|
||||
SDL_RenderGeometry(renderer, sprite, verts2, num_sprites * 6, NULL, 0);
|
||||
SDL_free(verts2);
|
||||
}
|
||||
} else if (use_rendergeometry == 2) {
|
||||
/* 0-----1
|
||||
* |\ A /|
|
||||
* | \ / |
|
||||
* |D 2 B|
|
||||
* | / \ |
|
||||
* |/ C \|
|
||||
* 3-----4
|
||||
*
|
||||
* Draw sprite2 as triangles that can *not* be recombined as rect by software renderer
|
||||
* Use an 'indices' array
|
||||
*/
|
||||
SDL_Vertex *verts = (SDL_Vertex *) SDL_malloc(num_sprites * sizeof (SDL_Vertex) * 5);
|
||||
SDL_Vertex *verts2 = verts;
|
||||
int *indices = (int *) SDL_malloc(num_sprites * sizeof (int) * 4 * 3);
|
||||
int *indices2 = indices;
|
||||
if (verts && indices) {
|
||||
int pos = 0;
|
||||
SDL_Color color;
|
||||
SDL_GetTextureColorMod(sprite, &color.r, &color.g, &color.b);
|
||||
SDL_GetTextureAlphaMod(sprite, &color.a);
|
||||
for (i = 0; i < num_sprites; ++i) {
|
||||
position = &positions[i];
|
||||
/* 0 */
|
||||
verts->position.x = (float)position->x;
|
||||
verts->position.y = (float)position->y;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 0.0f;
|
||||
verts->tex_coord.y = 0.0f;
|
||||
verts++;
|
||||
/* 1 */
|
||||
verts->position.x = (float)position->x + position->w;
|
||||
verts->position.y = (float)position->y;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 1.0f;
|
||||
verts->tex_coord.y = 0.0f;
|
||||
verts++;
|
||||
/* 2 */
|
||||
verts->position.x = (float)position->x + position->w / 2.0f;
|
||||
verts->position.y = (float)position->y + position->h / 2.0f;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 0.5f;
|
||||
verts->tex_coord.y = 0.5f;
|
||||
verts++;
|
||||
/* 3 */
|
||||
verts->position.x = (float)position->x;
|
||||
verts->position.y = (float)position->y + position->h;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 0.0f;
|
||||
verts->tex_coord.y = 1.0f;
|
||||
verts++;
|
||||
/* 4 */
|
||||
verts->position.x = (float)position->x + position->w;
|
||||
verts->position.y = (float)position->y + position->h;
|
||||
verts->color = color;
|
||||
verts->tex_coord.x = 1.0f;
|
||||
verts->tex_coord.y = 1.0f;
|
||||
verts++;
|
||||
/* A */
|
||||
*indices++ = pos + 0;
|
||||
*indices++ = pos + 1;
|
||||
*indices++ = pos + 2;
|
||||
/* B */
|
||||
*indices++ = pos + 1;
|
||||
*indices++ = pos + 2;
|
||||
*indices++ = pos + 4;
|
||||
/* C */
|
||||
*indices++ = pos + 3;
|
||||
*indices++ = pos + 2;
|
||||
*indices++ = pos + 4;
|
||||
/* D */
|
||||
*indices++ = pos + 3;
|
||||
*indices++ = pos + 2;
|
||||
*indices++ = pos + 0;
|
||||
pos += 5;
|
||||
}
|
||||
}
|
||||
|
||||
/* Blit sprites as triangles onto the screen */
|
||||
SDL_RenderGeometry(renderer, sprite, verts2, num_sprites * 5, indices2, num_sprites * 4 * 3);
|
||||
SDL_free(verts2);
|
||||
SDL_free(indices2);
|
||||
}
|
||||
|
||||
/* Update the screen! */
|
||||
@@ -331,6 +512,20 @@ main(int argc, char *argv[])
|
||||
} else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) {
|
||||
cycle_alpha = SDL_TRUE;
|
||||
consumed = 1;
|
||||
} else if (SDL_strcasecmp(argv[i], "--use-rendergeometry") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
if (SDL_strcasecmp(argv[i + 1], "mode1") == 0) {
|
||||
/* Draw sprite2 as triangles that can be recombined as rect by software renderer */
|
||||
use_rendergeometry = 1;
|
||||
} else if (SDL_strcasecmp(argv[i + 1], "mode2") == 0) {
|
||||
/* Draw sprite2 as triangles that can *not* be recombined as rect by software renderer
|
||||
* Use an 'indices' array */
|
||||
use_rendergeometry = 2;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
consumed = 2;
|
||||
} else if (SDL_isdigit(*argv[i])) {
|
||||
num_sprites = SDL_atoi(argv[i]);
|
||||
consumed = 1;
|
||||
@@ -340,7 +535,15 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
if (consumed < 0) {
|
||||
static const char *options[] = { "[--blend none|blend|add|mod]", "[--cyclecolor]", "[--cyclealpha]", "[--iterations N]", "[num_sprites]", "[icon.bmp]", NULL };
|
||||
static const char *options[] = {
|
||||
"[--blend none|blend|add|mod]",
|
||||
"[--cyclecolor]",
|
||||
"[--cyclealpha]",
|
||||
"[--iterations N]",
|
||||
"[--use-rendergeometry mode1|mode2]",
|
||||
"[num_sprites]",
|
||||
"[icon.bmp]",
|
||||
NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
quit(1);
|
||||
}
|
||||
@@ -374,7 +577,7 @@ main(int argc, char *argv[])
|
||||
quit(2);
|
||||
}
|
||||
|
||||
/* Position sprites and set their velocities using the fuzzer */
|
||||
/* Position sprites and set their velocities using the fuzzer */
|
||||
if (iterations >= 0) {
|
||||
/* Deterministic seed - used for visual tests */
|
||||
seed = (Uint64)iterations;
|
||||
|
2
externals/SDL/test/testspriteminimal.c
vendored
2
externals/SDL/test/testspriteminimal.c
vendored
@@ -43,7 +43,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
int
|
||||
LoadSprite(char *file)
|
||||
LoadSprite(const char *file)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
|
||||
|
200
externals/SDL/test/testsurround.c
vendored
Executable file
200
externals/SDL/test/testsurround.c
vendored
Executable file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 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 surround sound audio channels */
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
static int total_channels;
|
||||
static int active_channel;
|
||||
|
||||
#define SAMPLE_RATE_HZ 48000
|
||||
#define CHANNEL_TEST_TIME_SEC 5
|
||||
#define MAX_AMPLITUDE SDL_MAX_SINT16
|
||||
|
||||
#define SINE_FREQ_HZ 500
|
||||
#define LFE_SINE_FREQ_HZ 50
|
||||
|
||||
/* The channel layout is defined in SDL_audio.h */
|
||||
const char*
|
||||
get_channel_name(int channel_index, int channel_count)
|
||||
{
|
||||
switch (channel_index) {
|
||||
case 0:
|
||||
return "Front Left";
|
||||
case 1:
|
||||
return "Front Right";
|
||||
case 2:
|
||||
switch (channel_count) {
|
||||
case 3:
|
||||
return "Low Frequency Effects";
|
||||
case 4:
|
||||
return "Back Left";
|
||||
default:
|
||||
return "Front Center";
|
||||
}
|
||||
case 3:
|
||||
switch (channel_count) {
|
||||
case 4:
|
||||
return "Back Right";
|
||||
case 5:
|
||||
return "Back Left";
|
||||
default:
|
||||
return "Low Frequency Effects";
|
||||
}
|
||||
case 4:
|
||||
switch (channel_count) {
|
||||
case 5:
|
||||
return "Back Right";
|
||||
case 7:
|
||||
return "Back Center";
|
||||
case 6:
|
||||
case 8:
|
||||
return "Back Left";
|
||||
}
|
||||
case 5:
|
||||
switch (channel_count) {
|
||||
case 7:
|
||||
return "Back Left";
|
||||
case 6:
|
||||
case 8:
|
||||
return "Back Right";
|
||||
}
|
||||
case 6:
|
||||
switch (channel_count) {
|
||||
case 7:
|
||||
return "Back Right";
|
||||
case 8:
|
||||
return "Side Left";
|
||||
}
|
||||
case 7:
|
||||
return "Side Right";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
is_lfe_channel(int channel_index, int channel_count)
|
||||
{
|
||||
return (channel_count == 3 && channel_index == 2) || (channel_count >= 6 && channel_index == 3);
|
||||
}
|
||||
|
||||
void SDLCALL
|
||||
fill_buffer(void* unused, Uint8* stream, int len)
|
||||
{
|
||||
Sint16* buffer = (Sint16*)stream;
|
||||
int samples = len / sizeof(Sint16);
|
||||
static int total_samples = 0;
|
||||
int i;
|
||||
|
||||
SDL_memset(stream, 0, len);
|
||||
|
||||
/* This can happen for a short time when switching devices */
|
||||
if (active_channel == total_channels) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Play a sine wave on the active channel only */
|
||||
for (i = active_channel; i < samples; i += total_channels) {
|
||||
float time = (float)total_samples++ / SAMPLE_RATE_HZ;
|
||||
int sine_freq = is_lfe_channel(active_channel, total_channels) ? LFE_SINE_FREQ_HZ : SINE_FREQ_HZ;
|
||||
int amplitude;
|
||||
|
||||
/* Gradually ramp up and down to avoid audible pops when switching between channels */
|
||||
if (total_samples < SAMPLE_RATE_HZ) {
|
||||
amplitude = total_samples * MAX_AMPLITUDE / SAMPLE_RATE_HZ;
|
||||
} else if (total_samples > (CHANNEL_TEST_TIME_SEC - 1) * SAMPLE_RATE_HZ) {
|
||||
amplitude = (CHANNEL_TEST_TIME_SEC * SAMPLE_RATE_HZ - total_samples) * MAX_AMPLITUDE / SAMPLE_RATE_HZ;
|
||||
} else {
|
||||
amplitude = MAX_AMPLITUDE;
|
||||
}
|
||||
|
||||
buffer[i] = (Sint16)(SDL_sin(6.283185f * sine_freq * time) * amplitude);
|
||||
|
||||
/* Reset our state for next callback if this channel test is finished */
|
||||
if (total_samples == CHANNEL_TEST_TIME_SEC * SAMPLE_RATE_HZ) {
|
||||
total_samples = 0;
|
||||
active_channel++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 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("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
|
||||
|
||||
for (i = 0; i < SDL_GetNumAudioDevices(0); i++) {
|
||||
const char *devname = SDL_GetAudioDeviceName(i, 0);
|
||||
int j;
|
||||
SDL_AudioSpec spec;
|
||||
SDL_AudioDeviceID dev;
|
||||
|
||||
if (SDL_GetAudioDeviceSpec(i, 0, &spec) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioSpec() failed: %s\n", SDL_GetError());
|
||||
continue;
|
||||
}
|
||||
|
||||
spec.freq = SAMPLE_RATE_HZ;
|
||||
spec.format = AUDIO_S16SYS;
|
||||
spec.samples = 4096;
|
||||
spec.callback = fill_buffer;
|
||||
|
||||
dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
|
||||
if (dev == 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_OpenAudioDevice() failed: %s\n", SDL_GetError());
|
||||
continue;
|
||||
}
|
||||
|
||||
SDL_Log("Testing audio device: %s (%d channels)\n", devname, spec.channels);
|
||||
|
||||
/* These are used by the fill_buffer callback */
|
||||
total_channels = spec.channels;
|
||||
active_channel = 0;
|
||||
|
||||
SDL_PauseAudioDevice(dev, 0);
|
||||
|
||||
for (j = 0; j < total_channels; j++) {
|
||||
int sine_freq = is_lfe_channel(j, total_channels) ? LFE_SINE_FREQ_HZ : SINE_FREQ_HZ;
|
||||
|
||||
SDL_Log("Playing %d Hz test tone on channel: %s\n", sine_freq, get_channel_name(j, total_channels));
|
||||
|
||||
/* fill_buffer() will increment the active channel */
|
||||
SDL_Delay(CHANNEL_TEST_TIME_SEC * 1000);
|
||||
}
|
||||
|
||||
SDL_CloseAudioDevice(dev);
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
22
externals/SDL/test/testtimer.c
vendored
22
externals/SDL/test/testtimer.c
vendored
@@ -42,6 +42,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
int i, desired;
|
||||
SDL_TimerID t1, t2, t3;
|
||||
Uint64 start64, now64;
|
||||
Uint32 start32, now32;
|
||||
Uint64 start, now;
|
||||
|
||||
@@ -53,10 +54,25 @@ main(int argc, char *argv[])
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Verify SDL_GetTicks* acts monotonically increasing, and not erratic. */
|
||||
SDL_Log("Sanity-checking GetTicks\n");
|
||||
for (i = 0; i < 1000; ++i) {
|
||||
start64 = SDL_GetTicks64();
|
||||
start32 = SDL_GetTicks();
|
||||
SDL_Delay(1);
|
||||
now64 = SDL_GetTicks64() - start64;
|
||||
now32 = SDL_GetTicks() - start32;
|
||||
if (now32 > 100 || now64 > 100) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testtimer.c: Delta time erratic at iter %d. Delay 1ms = %d ms in ticks, %d ms in ticks64\n", i, (int)now32, (int)now64);
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Start the timer */
|
||||
desired = 0;
|
||||
if (argv[1]) {
|
||||
desired = atoi(argv[1]);
|
||||
desired = SDL_atoi(argv[1]);
|
||||
}
|
||||
if (desired == 0) {
|
||||
desired = DEFAULT_RESOLUTION;
|
||||
@@ -108,12 +124,14 @@ main(int argc, char *argv[])
|
||||
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", SDL_GetPerformanceFrequency());
|
||||
start64 = SDL_GetTicks64();
|
||||
start32 = SDL_GetTicks();
|
||||
start = SDL_GetPerformanceCounter();
|
||||
SDL_Delay(1000);
|
||||
now = SDL_GetPerformanceCounter();
|
||||
now64 = SDL_GetTicks64();
|
||||
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_Log("Delay 1 second = %d ms in ticks, %d ms in ticks64, %f ms according to performance counter\n", (int) (now32-start32), (int) (now64-start64), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
|
||||
|
||||
SDL_Quit();
|
||||
return (0);
|
||||
|
2
externals/SDL/test/testviewport.c
vendored
2
externals/SDL/test/testviewport.c
vendored
@@ -43,7 +43,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
int
|
||||
LoadSprite(char *file, SDL_Renderer *renderer)
|
||||
LoadSprite(const char *file, SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
|
||||
|
790
externals/SDL/test/testvulkan.c
vendored
790
externals/SDL/test/testvulkan.c
vendored
File diff suppressed because it is too large
Load Diff
123
externals/SDL/test/testwm2.c
vendored
123
externals/SDL/test/testwm2.c
vendored
@@ -18,6 +18,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL_test_common.h"
|
||||
#include "SDL_test_font.h"
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
int done;
|
||||
@@ -39,6 +40,7 @@ static const char *cursorNames[] = {
|
||||
int system_cursor = -1;
|
||||
SDL_Cursor *cursor = NULL;
|
||||
SDL_bool relative_mode = SDL_FALSE;
|
||||
int highlighted_mode = -1;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
@@ -48,6 +50,99 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
/* Draws the modes menu, and stores the mode index under the mouse in highlighted_mode */
|
||||
static void
|
||||
draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
char text[1024];
|
||||
const int lineHeight = 10;
|
||||
const int display_index = SDL_GetWindowDisplayIndex(window);
|
||||
const int num_modes = SDL_GetNumDisplayModes(display_index);
|
||||
int i;
|
||||
int column_chars = 0;
|
||||
int text_length;
|
||||
int x, y;
|
||||
int table_top;
|
||||
SDL_Point mouse_pos = { -1, -1 };
|
||||
|
||||
/* Get mouse position */
|
||||
if (SDL_GetMouseFocus() == window) {
|
||||
int window_x, window_y;
|
||||
float logical_x, logical_y;
|
||||
|
||||
SDL_GetMouseState(&window_x, &window_y);
|
||||
SDL_RenderWindowToLogical(renderer, window_x, window_y, &logical_x, &logical_y);
|
||||
|
||||
mouse_pos.x = (int)logical_x;
|
||||
mouse_pos.y = (int)logical_y;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = viewport.y;
|
||||
|
||||
y += lineHeight;
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "Click on a mode to set it with SDL_SetWindowDisplayMode");
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
y += lineHeight;
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "Press Ctrl+Enter to toggle SDL_WINDOW_FULLSCREEN");
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
y += lineHeight;
|
||||
|
||||
table_top = y;
|
||||
|
||||
/* Clear the cached mode under the mouse */
|
||||
if (window == SDL_GetMouseFocus()) {
|
||||
highlighted_mode = -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_modes; ++i) {
|
||||
SDL_Rect cell_rect;
|
||||
|
||||
if (0 != SDL_GetDisplayMode(display_index, i, &mode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "%d: %dx%d@%dHz",
|
||||
i, mode.w, mode.h, mode.refresh_rate);
|
||||
|
||||
/* Update column width */
|
||||
text_length = (int)SDL_strlen(text);
|
||||
column_chars = SDL_max(column_chars, text_length);
|
||||
|
||||
/* Check if under mouse */
|
||||
cell_rect.x = x;
|
||||
cell_rect.y = y;
|
||||
cell_rect.w = text_length * FONT_CHARACTER_SIZE;
|
||||
cell_rect.h = lineHeight;
|
||||
|
||||
if (SDL_PointInRect(&mouse_pos, &cell_rect)) {
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
|
||||
/* Update cached mode under the mouse */
|
||||
if (window == SDL_GetMouseFocus()) {
|
||||
highlighted_mode = i;
|
||||
}
|
||||
} else {
|
||||
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
|
||||
}
|
||||
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
y += lineHeight;
|
||||
|
||||
if (y + lineHeight > (viewport.y + viewport.h)) {
|
||||
/* Advance to next column */
|
||||
x += (column_chars + 1) * FONT_CHARACTER_SIZE;
|
||||
y = table_top;
|
||||
column_chars = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
loop()
|
||||
{
|
||||
@@ -112,16 +207,40 @@ loop()
|
||||
SDL_SetCursor(cursor);
|
||||
}
|
||||
}
|
||||
if (event.type == SDL_MOUSEBUTTONUP) {
|
||||
SDL_Window* window = SDL_GetMouseFocus();
|
||||
if (highlighted_mode != -1 && window != NULL) {
|
||||
const int display_index = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_DisplayMode mode;
|
||||
if (0 != SDL_GetDisplayMode(display_index, highlighted_mode, &mode)) {
|
||||
SDL_Log("Couldn't get display mode");
|
||||
} else {
|
||||
SDL_SetWindowDisplayMode(window, &mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
SDL_Window* window = state->windows[i];
|
||||
SDL_Renderer *renderer = state->renderers[i];
|
||||
if (renderer != NULL) {
|
||||
if (window != NULL && renderer != NULL) {
|
||||
int y = 0;
|
||||
SDL_Rect viewport, menurect;
|
||||
|
||||
SDL_RenderGetViewport(renderer, &viewport);
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDLTest_CommonDrawWindowInfo(renderer, state->windows[i]);
|
||||
SDLTest_CommonDrawWindowInfo(renderer, state->windows[i], &y);
|
||||
|
||||
menurect.x = 0;
|
||||
menurect.y = y;
|
||||
menurect.w = viewport.w;
|
||||
menurect.h = viewport.h - y;
|
||||
draw_modes_menu(window, renderer, menurect);
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
6
externals/SDL/test/testyuv_cvt.c
vendored
6
externals/SDL/test/testyuv_cvt.c
vendored
@@ -31,9 +31,9 @@ static void RGBtoYUV(Uint8 * rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int mo
|
||||
// This formula is from Microsoft's documentation:
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx
|
||||
// L = Kr * R + Kb * B + (1 - Kr - Kb) * G
|
||||
// Y = floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5);
|
||||
// U = clip3(0, (2^M)-1, floor(2^(M-8) * (112*(B-L) / ((1-Kb)*S) + 128) + 0.5));
|
||||
// V = clip3(0, (2^M)-1, floor(2^(M-8) * (112*(R-L) / ((1-Kr)*S) + 128) + 0.5));
|
||||
// Y = SDL_floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5);
|
||||
// U = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(B-L) / ((1-Kb)*S) + 128) + 0.5));
|
||||
// V = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(R-L) / ((1-Kr)*S) + 128) + 0.5));
|
||||
float S, Z, R, G, B, L, Kr, Kb, Y, U, V;
|
||||
|
||||
if (mode == SDL_YUV_CONVERSION_BT709) {
|
||||
|
Reference in New Issue
Block a user