early-access version 2835
This commit is contained in:
411
externals/SDL/test/CMakeLists.txt
vendored
411
externals/SDL/test/CMakeLists.txt
vendored
@@ -1,10 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(SDL2 C)
|
||||
include(CTest)
|
||||
|
||||
if(SDL_INSTALL_TESTS)
|
||||
include(GNUInstallDirs)
|
||||
endif()
|
||||
|
||||
# Global settings for all of the test targets
|
||||
# FIXME: is this wrong?
|
||||
remove_definitions(-DUSING_GENERATED_CONFIG_H)
|
||||
link_libraries(SDL2_test SDL2-static)
|
||||
|
||||
if(PSP)
|
||||
link_libraries(
|
||||
SDL2main
|
||||
SDL2_test
|
||||
SDL2-static
|
||||
GL
|
||||
pspvram
|
||||
pspvfpu
|
||||
pspdisplay
|
||||
pspgu
|
||||
pspge
|
||||
pspaudio
|
||||
pspctrl
|
||||
psphprm
|
||||
psppower
|
||||
)
|
||||
else()
|
||||
link_libraries(SDL2_test SDL2-static)
|
||||
endif()
|
||||
|
||||
if(WINDOWS)
|
||||
# mingw32 must come before SDL2main to link successfully
|
||||
@@ -20,6 +44,8 @@ endif()
|
||||
|
||||
# CMake incorrectly detects opengl32.lib being present on MSVC ARM64
|
||||
if(NOT MSVC OR NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
|
||||
# Prefer GLVND, if present
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL)
|
||||
endif()
|
||||
|
||||
@@ -29,8 +55,8 @@ endif()
|
||||
|
||||
add_executable(checkkeys checkkeys.c)
|
||||
add_executable(checkkeysthreads checkkeysthreads.c)
|
||||
add_executable(loopwave loopwave.c)
|
||||
add_executable(loopwavequeue loopwavequeue.c)
|
||||
add_executable(loopwave loopwave.c testutils.c)
|
||||
add_executable(loopwavequeue loopwavequeue.c testutils.c)
|
||||
add_executable(testsurround testsurround.c)
|
||||
add_executable(testresample testresample.c)
|
||||
add_executable(testaudioinfo testaudioinfo.c)
|
||||
@@ -38,8 +64,8 @@ add_executable(testaudioinfo testaudioinfo.c)
|
||||
file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c)
|
||||
add_executable(testautomation ${TESTAUTOMATION_SOURCE_FILES})
|
||||
|
||||
add_executable(testmultiaudio testmultiaudio.c)
|
||||
add_executable(testaudiohotplug testaudiohotplug.c)
|
||||
add_executable(testmultiaudio testmultiaudio.c testutils.c)
|
||||
add_executable(testaudiohotplug testaudiohotplug.c testutils.c)
|
||||
add_executable(testaudiocapture testaudiocapture.c)
|
||||
add_executable(testatomic testatomic.c)
|
||||
add_executable(testintersections testintersections.c)
|
||||
@@ -49,95 +75,342 @@ add_executable(testdraw2 testdraw2.c)
|
||||
add_executable(testdrawchessboard testdrawchessboard.c)
|
||||
add_executable(testdropfile testdropfile.c)
|
||||
add_executable(testerror testerror.c)
|
||||
|
||||
if(LINUX)
|
||||
add_executable(testevdev testevdev.c)
|
||||
endif()
|
||||
|
||||
add_executable(testfile testfile.c)
|
||||
add_executable(testgamecontroller testgamecontroller.c)
|
||||
add_executable(testgeometry testgeometry.c)
|
||||
add_executable(testgamecontroller testgamecontroller.c testutils.c)
|
||||
add_executable(testgeometry testgeometry.c testutils.c)
|
||||
add_executable(testgesture testgesture.c)
|
||||
add_executable(testgl2 testgl2.c)
|
||||
add_executable(testgles testgles.c)
|
||||
add_executable(testgles2 testgles2.c)
|
||||
add_executable(testguid testguid.c)
|
||||
add_executable(testhaptic testhaptic.c)
|
||||
add_executable(testhotplug testhotplug.c)
|
||||
add_executable(testrumble testrumble.c)
|
||||
add_executable(testthread testthread.c)
|
||||
add_executable(testiconv testiconv.c)
|
||||
add_executable(testime testime.c)
|
||||
add_executable(testiconv testiconv.c testutils.c)
|
||||
add_executable(testime testime.c testutils.c)
|
||||
add_executable(testjoystick testjoystick.c)
|
||||
add_executable(testkeys testkeys.c)
|
||||
add_executable(testloadso testloadso.c)
|
||||
add_executable(testlocale testlocale.c)
|
||||
add_executable(testlock testlock.c)
|
||||
add_executable(testmouse testmouse.c)
|
||||
|
||||
if(APPLE)
|
||||
add_executable(testnative testnative.c
|
||||
testnativecocoa.m
|
||||
testnativex11.c)
|
||||
testnativex11.c
|
||||
testutils.c)
|
||||
elseif(WINDOWS)
|
||||
add_executable(testnative testnative.c testnativew32.c)
|
||||
elseif(UNIX)
|
||||
add_executable(testnative testnative.c testnativex11.c)
|
||||
add_executable(testnative testnative.c testnativew32.c testutils.c)
|
||||
elseif(SDL_X11)
|
||||
add_executable(testnative testnative.c testnativex11.c testutils.c)
|
||||
target_link_libraries(testnative X11)
|
||||
endif()
|
||||
|
||||
add_executable(testoverlay2 testoverlay2.c testyuv_cvt.c)
|
||||
add_executable(testoverlay2 testoverlay2.c testyuv_cvt.c testutils.c)
|
||||
add_executable(testplatform testplatform.c)
|
||||
add_executable(testpower testpower.c)
|
||||
add_executable(testfilesystem testfilesystem.c)
|
||||
add_executable(testrendertarget testrendertarget.c)
|
||||
add_executable(testscale testscale.c)
|
||||
add_executable(testrendertarget testrendertarget.c testutils.c)
|
||||
add_executable(testscale testscale.c testutils.c)
|
||||
add_executable(testsem testsem.c)
|
||||
add_executable(testsensor testsensor.c)
|
||||
add_executable(testshader testshader.c)
|
||||
add_executable(testshape testshape.c)
|
||||
add_executable(testsprite2 testsprite2.c)
|
||||
add_executable(testspriteminimal testspriteminimal.c)
|
||||
add_executable(teststreaming teststreaming.c)
|
||||
add_executable(testsprite2 testsprite2.c testutils.c)
|
||||
add_executable(testspriteminimal testspriteminimal.c testutils.c)
|
||||
add_executable(teststreaming teststreaming.c testutils.c)
|
||||
add_executable(testtimer testtimer.c)
|
||||
add_executable(testurl testurl.c)
|
||||
add_executable(testver testver.c)
|
||||
add_executable(testviewport testviewport.c)
|
||||
add_executable(testviewport testviewport.c testutils.c)
|
||||
add_executable(testwm2 testwm2.c)
|
||||
add_executable(testyuv testyuv.c testyuv_cvt.c)
|
||||
add_executable(torturethread torturethread.c)
|
||||
add_executable(testrendercopyex testrendercopyex.c)
|
||||
add_executable(testrendercopyex testrendercopyex.c testutils.c)
|
||||
add_executable(testmessage testmessage.c)
|
||||
add_executable(testdisplayinfo testdisplayinfo.c)
|
||||
add_executable(testqsort testqsort.c)
|
||||
add_executable(testbounds testbounds.c)
|
||||
add_executable(testcustomcursor testcustomcursor.c)
|
||||
add_executable(controllermap controllermap.c)
|
||||
add_executable(controllermap controllermap.c testutils.c)
|
||||
add_executable(testvulkan testvulkan.c)
|
||||
add_executable(testoffscreen testoffscreen.c)
|
||||
|
||||
SET(ALL_TESTS
|
||||
checkkeys
|
||||
checkkeysthreads
|
||||
controllermap
|
||||
loopwave
|
||||
loopwavequeue
|
||||
testatomic
|
||||
testaudiocapture
|
||||
testaudiohotplug
|
||||
testaudioinfo
|
||||
testautomation
|
||||
testbounds
|
||||
testcustomcursor
|
||||
testdisplayinfo
|
||||
testdraw2
|
||||
testdrawchessboard
|
||||
testdropfile
|
||||
testerror
|
||||
testfile
|
||||
testfilesystem
|
||||
testgamecontroller
|
||||
testgeometry
|
||||
testgesture
|
||||
testgl2
|
||||
testgles
|
||||
testgles2
|
||||
testguid
|
||||
testhaptic
|
||||
testhittesting
|
||||
testhotplug
|
||||
testiconv
|
||||
testime
|
||||
testintersections
|
||||
testjoystick
|
||||
testkeys
|
||||
testloadso
|
||||
testlocale
|
||||
testlock
|
||||
testmessage
|
||||
testmouse
|
||||
testmultiaudio
|
||||
testoffscreen
|
||||
testoverlay2
|
||||
testplatform
|
||||
testpower
|
||||
testqsort
|
||||
testrelative
|
||||
testrendercopyex
|
||||
testrendertarget
|
||||
testresample
|
||||
testrumble
|
||||
testscale
|
||||
testsem
|
||||
testsensor
|
||||
testshader
|
||||
testshape
|
||||
testsprite2
|
||||
testspriteminimal
|
||||
teststreaming
|
||||
testsurround
|
||||
testthread
|
||||
testtimer
|
||||
testurl
|
||||
testver
|
||||
testviewport
|
||||
testvulkan
|
||||
testwm2
|
||||
testyuv
|
||||
torturethread
|
||||
)
|
||||
|
||||
set(NONINTERACTIVE
|
||||
testatomic
|
||||
testerror
|
||||
testfilesystem
|
||||
testguid
|
||||
testlocale
|
||||
testplatform
|
||||
testpower
|
||||
testqsort
|
||||
testthread
|
||||
testtimer
|
||||
testver
|
||||
)
|
||||
|
||||
if(WINDOWS OR APPLE OR SDL_X11)
|
||||
list(APPEND ALL_TESTS testnative)
|
||||
endif()
|
||||
|
||||
if(LINUX)
|
||||
list(APPEND ALL_TESTS testevdev)
|
||||
list(APPEND NONINTERACTIVE testevdev)
|
||||
endif()
|
||||
|
||||
if(SDL_DUMMYAUDIO)
|
||||
set(NEEDS_AUDIO
|
||||
testaudioinfo
|
||||
testsurround
|
||||
)
|
||||
endif()
|
||||
|
||||
if(SDL_DUMMYVIDEO)
|
||||
set(NEEDS_DISPLAY
|
||||
testkeys
|
||||
testbounds
|
||||
testdisplayinfo
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OPENGL_FOUND)
|
||||
add_dependencies(testshader OpenGL::GL)
|
||||
add_dependencies(testgl2 OpenGL::GL)
|
||||
target_link_libraries(testshader OpenGL::GL)
|
||||
target_link_libraries(testgl2 OpenGL::GL)
|
||||
target_link_libraries(testshader OpenGL::GL)
|
||||
target_link_libraries(testgl2 OpenGL::GL)
|
||||
endif()
|
||||
|
||||
file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt)
|
||||
file(COPY ${RESOURCE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(NEEDS_RESOURCES
|
||||
testscale
|
||||
testrendercopyex
|
||||
controllermap
|
||||
testyuv
|
||||
testgamecontroller
|
||||
testshape
|
||||
testshader
|
||||
testnative
|
||||
testspriteminimal
|
||||
testautomation
|
||||
testcustomcursor
|
||||
testrendertarget
|
||||
testsprite2
|
||||
loopwave
|
||||
loopwavequeue
|
||||
testresample
|
||||
testaudiohotplug
|
||||
testmultiaudio
|
||||
)
|
||||
if(PSP OR PS2)
|
||||
set(NEEDS_RESOURCES
|
||||
testscale
|
||||
testrendercopyex
|
||||
controllermap
|
||||
testyuv
|
||||
testgamecontroller
|
||||
testshape
|
||||
testshader
|
||||
testspriteminimal
|
||||
testautomation
|
||||
testrendertarget
|
||||
testsprite2
|
||||
loopwave
|
||||
loopwavequeue
|
||||
testresample
|
||||
testaudiohotplug
|
||||
testmultiaudio
|
||||
testiconv
|
||||
testoverlay2
|
||||
teststreaming
|
||||
testviewport
|
||||
)
|
||||
else()
|
||||
set(NEEDS_RESOURCES
|
||||
testscale
|
||||
testrendercopyex
|
||||
controllermap
|
||||
testyuv
|
||||
testgamecontroller
|
||||
testshape
|
||||
testshader
|
||||
testspriteminimal
|
||||
testautomation
|
||||
testcustomcursor
|
||||
testrendertarget
|
||||
testsprite2
|
||||
loopwave
|
||||
loopwavequeue
|
||||
testresample
|
||||
testaudiohotplug
|
||||
testmultiaudio
|
||||
testime
|
||||
testiconv
|
||||
testoverlay2
|
||||
teststreaming
|
||||
testviewport
|
||||
)
|
||||
if(WINDOWS OR APPLE OR SDL_X11)
|
||||
list(APPEND NEEDS_RESOURCES testnative)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PSP)
|
||||
# Build EBOOT files if building for PSP
|
||||
set(BUILD_EBOOT
|
||||
${NEEDS_RESOURCES}
|
||||
testatomic
|
||||
testaudiocapture
|
||||
testaudioinfo
|
||||
testbounds
|
||||
testdisplayinfo
|
||||
testdraw2
|
||||
testdrawchessboard
|
||||
testerror
|
||||
testfile
|
||||
testfilesystem
|
||||
testgeometry
|
||||
testgl2
|
||||
testguid
|
||||
testhittesting
|
||||
testiconv
|
||||
testintersections
|
||||
testjoystick
|
||||
testlock
|
||||
testmessage
|
||||
testoverlay2
|
||||
testplatform
|
||||
testpower
|
||||
testqsort
|
||||
testsem
|
||||
teststreaming
|
||||
testsurround
|
||||
testthread
|
||||
testtimer
|
||||
testver
|
||||
testviewport
|
||||
testwm2
|
||||
torturethread
|
||||
)
|
||||
foreach(APP IN LISTS BUILD_EBOOT)
|
||||
create_pbp_file(
|
||||
TARGET ${APP}
|
||||
TITLE SDL-${APP}
|
||||
ICON_PATH NULL
|
||||
BACKGROUND_PATH NULL
|
||||
PREVIEW_PATH NULL
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${APP} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${APP} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rename
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/EBOOT.PBP
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/EBOOT.PBP
|
||||
)
|
||||
if(${BUILD_PRX})
|
||||
add_custom_command(
|
||||
TARGET ${APP} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/${APP}
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/${APP}
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${APP} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rename
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/${APP}.prx
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/sdl-${APP}/${APP}.prx
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET ${APP} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E remove
|
||||
$<TARGET_FILE_DIR:${ARG_TARGET}>/PARAM.SFO
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(RISCOS)
|
||||
set(ALL_TESTS_AIF "")
|
||||
foreach(APP IN LISTS ALL_TESTS)
|
||||
target_link_options(${APP} PRIVATE -static)
|
||||
add_custom_command(
|
||||
OUTPUT ${APP},ff8
|
||||
COMMAND elf2aif ${APP} ${APP},ff8
|
||||
DEPENDS ${APP}
|
||||
)
|
||||
add_custom_target(${APP}-aif ALL DEPENDS ${APP},ff8)
|
||||
list(APPEND ALL_TESTS_AIF ${CMAKE_CURRENT_BINARY_DIR}/${APP},ff8)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
foreach(APP IN LISTS NEEDS_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}>)
|
||||
if(PSP OR PS2)
|
||||
add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:${APP}>/sdl-${APP})
|
||||
else()
|
||||
add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:${APP}>)
|
||||
endif()
|
||||
endforeach(RESOURCE_FILE)
|
||||
if(APPLE)
|
||||
# Make sure resource files get installed into macOS/iOS .app bundles.
|
||||
@@ -167,3 +440,47 @@ if(APPLE)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(TESTS_ENVIRONMENT
|
||||
SDL_AUDIODRIVER=dummy
|
||||
SDL_VIDEODRIVER=dummy
|
||||
)
|
||||
|
||||
foreach(TESTCASE ${NONINTERACTIVE} ${NEEDS_AUDIO} ${NEEDS_DISPLAY})
|
||||
add_test(
|
||||
NAME ${TESTCASE}
|
||||
COMMAND ${TESTCASE}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
set_tests_properties(
|
||||
${TESTCASE}
|
||||
PROPERTIES ENVIRONMENT "${TESTS_ENVIRONMENT}"
|
||||
)
|
||||
if(SDL_INSTALL_TESTS)
|
||||
set(exe ${TESTCASE})
|
||||
set(installedtestsdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}/installed-tests/SDL2")
|
||||
configure_file(template.test.in "${exe}.test" @ONLY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${exe}.test"
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/installed-tests/SDL2
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(SDL_INSTALL_TESTS)
|
||||
if(RISCOS)
|
||||
install(
|
||||
FILES ${ALL_TESTS_AIF}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS ${ALL_TESTS}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
|
||||
)
|
||||
endif()
|
||||
install(
|
||||
FILES ${RESOURCE_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
|
||||
)
|
||||
endif()
|
||||
|
124
externals/SDL/test/Makefile.in
vendored
124
externals/SDL/test/Makefile.in
vendored
@@ -2,6 +2,15 @@
|
||||
|
||||
srcdir = @srcdir@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
includedir = @includedir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
|
||||
CC = @CC@
|
||||
EXE = @EXE@
|
||||
CFLAGS = @CFLAGS@ -g
|
||||
@@ -31,6 +40,7 @@ TARGETS = \
|
||||
testgamecontroller$(EXE) \
|
||||
testgeometry$(EXE) \
|
||||
testgesture$(EXE) \
|
||||
testguid$(EXE) \
|
||||
testhaptic$(EXE) \
|
||||
testhittesting$(EXE) \
|
||||
testhotplug$(EXE) \
|
||||
@@ -79,7 +89,26 @@ TARGETS = \
|
||||
@OPENGLES2_TARGETS@ += testgles2$(EXE)
|
||||
|
||||
|
||||
all: Makefile $(TARGETS) copydatafiles
|
||||
all: Makefile $(TARGETS) copydatafiles generatetestmeta
|
||||
|
||||
installedtestsdir = $(libexecdir)/installed-tests/SDL2
|
||||
installedtestsmetadir = $(datadir)/installed-tests/SDL2
|
||||
|
||||
generatetestmeta:
|
||||
rm -f *.test
|
||||
set -e; for exe in $(noninteractive) $(needs_audio) $(needs_display); do \
|
||||
sed \
|
||||
-e 's#@installedtestsdir@#$(installedtestsdir)#g' \
|
||||
-e "s#@exe@#$$exe#g" \
|
||||
< $(srcdir)/template.test.in > $$exe.test; \
|
||||
done
|
||||
|
||||
install: all
|
||||
install -d $(DESTDIR)$(installedtestsdir)
|
||||
install $(TARGETS) $(DESTDIR)$(installedtestsdir)
|
||||
install -m644 $(DATA) $(DESTDIR)$(installedtestsdir)
|
||||
install -d $(DESTDIR)$(installedtestsmetadir)
|
||||
install -m644 *.test $(DESTDIR)$(installedtestsmetadir)
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in
|
||||
$(SHELL) config.status $@
|
||||
@@ -90,10 +119,10 @@ checkkeys$(EXE): $(srcdir)/checkkeys.c
|
||||
checkkeysthreads$(EXE): $(srcdir)/checkkeysthreads.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
loopwave$(EXE): $(srcdir)/loopwave.c
|
||||
loopwave$(EXE): $(srcdir)/loopwave.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
loopwavequeue$(EXE): $(srcdir)/loopwavequeue.c
|
||||
loopwavequeue$(EXE): $(srcdir)/loopwavequeue.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testsurround$(EXE): $(srcdir)/testsurround.c
|
||||
@@ -123,13 +152,14 @@ testautomation$(EXE): $(srcdir)/testautomation.c \
|
||||
$(srcdir)/testautomation_syswm.c \
|
||||
$(srcdir)/testautomation_timer.c \
|
||||
$(srcdir)/testautomation_video.c \
|
||||
$(srcdir)/testautomation_hints.c
|
||||
$(srcdir)/testautomation_hints.c \
|
||||
$(srcdir)/testautomation_math.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c
|
||||
testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testaudiohotplug$(EXE): $(srcdir)/testaudiohotplug.c
|
||||
testaudiohotplug$(EXE): $(srcdir)/testaudiohotplug.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testaudiocapture$(EXE): $(srcdir)/testaudiocapture.c
|
||||
@@ -165,15 +195,15 @@ testevdev$(EXE): $(srcdir)/testevdev.c
|
||||
testfile$(EXE): $(srcdir)/testfile.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testgamecontroller$(EXE): $(srcdir)/testgamecontroller.c
|
||||
testgamecontroller$(EXE): $(srcdir)/testgamecontroller.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testgeometry$(EXE): $(srcdir)/testgeometry.c
|
||||
testgeometry$(EXE): $(srcdir)/testgeometry.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testgesture$(EXE): $(srcdir)/testgesture.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
|
||||
testgl2$(EXE): $(srcdir)/testgl2.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
@@ -183,9 +213,12 @@ testgles$(EXE): $(srcdir)/testgles.c
|
||||
testgles2$(EXE): $(srcdir)/testgles2.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
testgles2_sdf$(EXE): $(srcdir)/testgles2_sdf.c
|
||||
testgles2_sdf$(EXE): $(srcdir)/testgles2_sdf.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
testguid$(EXE): $(srcdir)/testguid.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testhaptic$(EXE): $(srcdir)/testhaptic.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
@@ -198,10 +231,10 @@ testrumble$(EXE): $(srcdir)/testrumble.c
|
||||
testthread$(EXE): $(srcdir)/testthread.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testiconv$(EXE): $(srcdir)/testiconv.c
|
||||
testiconv$(EXE): $(srcdir)/testiconv.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testime$(EXE): $(srcdir)/testime.c
|
||||
testime$(EXE): $(srcdir)/testime.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @SDL_TTF_LIB@
|
||||
|
||||
testjoystick$(EXE): $(srcdir)/testjoystick.c
|
||||
@@ -219,18 +252,21 @@ testlock$(EXE): $(srcdir)/testlock.c
|
||||
ifeq (@ISMACOSX@,true)
|
||||
testnative$(EXE): $(srcdir)/testnative.c \
|
||||
$(srcdir)/testnativecocoa.m \
|
||||
$(srcdir)/testutils.c \
|
||||
$(srcdir)/testnativex11.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -framework Cocoa @XLIB@
|
||||
endif
|
||||
|
||||
ifeq (@ISWINDOWS@,true)
|
||||
testnative$(EXE): $(srcdir)/testnative.c \
|
||||
$(srcdir)/testutils.c \
|
||||
$(srcdir)/testnativew32.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
endif
|
||||
|
||||
ifeq (@ISUNIX@,true)
|
||||
testnative$(EXE): $(srcdir)/testnative.c \
|
||||
$(srcdir)/testutils.c \
|
||||
$(srcdir)/testnativex11.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @XLIB@
|
||||
endif
|
||||
@@ -252,7 +288,7 @@ endif
|
||||
endif
|
||||
endif
|
||||
|
||||
testoverlay2$(EXE): $(srcdir)/testoverlay2.c $(srcdir)/testyuv_cvt.c
|
||||
testoverlay2$(EXE): $(srcdir)/testoverlay2.c $(srcdir)/testyuv_cvt.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testplatform$(EXE): $(srcdir)/testplatform.c
|
||||
@@ -264,10 +300,10 @@ testpower$(EXE): $(srcdir)/testpower.c
|
||||
testfilesystem$(EXE): $(srcdir)/testfilesystem.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testrendertarget$(EXE): $(srcdir)/testrendertarget.c
|
||||
testrendertarget$(EXE): $(srcdir)/testrendertarget.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testscale$(EXE): $(srcdir)/testscale.c
|
||||
testscale$(EXE): $(srcdir)/testscale.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testsem$(EXE): $(srcdir)/testsem.c
|
||||
@@ -282,13 +318,13 @@ testshader$(EXE): $(srcdir)/testshader.c
|
||||
testshape$(EXE): $(srcdir)/testshape.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testsprite2$(EXE): $(srcdir)/testsprite2.c
|
||||
testsprite2$(EXE): $(srcdir)/testsprite2.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testspriteminimal$(EXE): $(srcdir)/testspriteminimal.c
|
||||
testspriteminimal$(EXE): $(srcdir)/testspriteminimal.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
teststreaming$(EXE): $(srcdir)/teststreaming.c
|
||||
teststreaming$(EXE): $(srcdir)/teststreaming.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
testtimer$(EXE): $(srcdir)/testtimer.c
|
||||
@@ -300,7 +336,7 @@ testurl$(EXE): $(srcdir)/testurl.c
|
||||
testver$(EXE): $(srcdir)/testver.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testviewport$(EXE): $(srcdir)/testviewport.c
|
||||
testviewport$(EXE): $(srcdir)/testviewport.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testwm2$(EXE): $(srcdir)/testwm2.c
|
||||
@@ -312,7 +348,7 @@ testyuv$(EXE): $(srcdir)/testyuv.c $(srcdir)/testyuv_cvt.c
|
||||
torturethread$(EXE): $(srcdir)/torturethread.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testrendercopyex$(EXE): $(srcdir)/testrendercopyex.c
|
||||
testrendercopyex$(EXE): $(srcdir)/testrendercopyex.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
|
||||
|
||||
testmessage$(EXE): $(srcdir)/testmessage.c
|
||||
@@ -330,7 +366,7 @@ testbounds$(EXE): $(srcdir)/testbounds.c
|
||||
testcustomcursor$(EXE): $(srcdir)/testcustomcursor.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
controllermap$(EXE): $(srcdir)/controllermap.c
|
||||
controllermap$(EXE): $(srcdir)/controllermap.c $(srcdir)/testutils.c
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
testvulkan$(EXE): $(srcdir)/testvulkan.c
|
||||
@@ -344,13 +380,56 @@ testmouse$(EXE): $(srcdir)/testmouse.c
|
||||
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS)
|
||||
rm -f $(TARGETS) *.test
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
||||
rm -f config.status config.cache config.log
|
||||
rm -rf $(srcdir)/autom4te*
|
||||
|
||||
noninteractive = \
|
||||
testatomic$(EXE) \
|
||||
testerror$(EXE) \
|
||||
testevdev$(EXE) \
|
||||
testfilesystem$(EXE) \
|
||||
testkeys$(EXE) \
|
||||
testlocale$(EXE) \
|
||||
testplatform$(EXE) \
|
||||
testpower$(EXE) \
|
||||
testqsort$(EXE) \
|
||||
testthread$(EXE) \
|
||||
testtimer$(EXE) \
|
||||
testver$(EXE) \
|
||||
$(NULL)
|
||||
|
||||
needs_audio = \
|
||||
testaudioinfo$(EXE) \
|
||||
testsurround$(EXE) \
|
||||
$(NULL)
|
||||
|
||||
needs_display = \
|
||||
testbounds$(EXE) \
|
||||
testdisplayinfo$(EXE) \
|
||||
$(NULL)
|
||||
|
||||
TESTS = $(noninteractive) $(needs_audio) $(needs_display)
|
||||
|
||||
check:
|
||||
@set -e; \
|
||||
status=0; \
|
||||
export SDL_AUDIODRIVER=dummy; \
|
||||
export SDL_VIDEODRIVER=dummy; \
|
||||
for exe in $(TESTS); do \
|
||||
echo "$$exe..."; \
|
||||
if ./"$$exe"; then \
|
||||
echo "$$exe: OK"; \
|
||||
else \
|
||||
echo "$$exe: FAILED: $$?"; \
|
||||
status=1; \
|
||||
fi; \
|
||||
done; \
|
||||
exit "$$status"
|
||||
|
||||
DATA = \
|
||||
axis.bmp \
|
||||
button.bmp \
|
||||
@@ -364,6 +443,7 @@ DATA = \
|
||||
testgles2_sdf_img_sdf.bmp \
|
||||
testyuv.bmp \
|
||||
unifont-13.0.06.hex \
|
||||
utf8.txt \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(srcdir), .)
|
||||
|
95
externals/SDL/test/Makefile.os2
vendored
95
externals/SDL/test/Makefile.os2
vendored
@@ -1,96 +1,13 @@
|
||||
# Open Watcom makefile to build SDL2 tests for OS/2
|
||||
# wmake -f Makefile.os2
|
||||
|
||||
INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h" -I"../include"
|
||||
SYSTEM = os2v2
|
||||
|
||||
CFLAGS = $(INCPATH) -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei
|
||||
INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h"
|
||||
|
||||
CFLAGS = -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei
|
||||
CFLAGS+= -wx -wcd=303
|
||||
|
||||
LIBPATH = ..
|
||||
LIBS = SDL2.lib $(TESTLIB)
|
||||
TNSRCS = testnative.c testnativeos2.c
|
||||
|
||||
#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 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 &
|
||||
testpower.exe testsensor.exe testrelative.exe testrendercopyex.exe &
|
||||
testrendertarget.exe testrumble.exe testscale.exe testsem.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 testmouse.exe &
|
||||
controllermap.exe testhaptic.exe testqsort.exe testresample.exe &
|
||||
testaudioinfo.exe testaudiocapture.exe loopwave.exe loopwavequeue.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 &
|
||||
SDL_test_imagePrimitives.c SDL_test_imagePrimitivesBlend.c &
|
||||
SDL_test_log.c SDL_test_md5.c SDL_test_random.c SDL_test_memory.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 &
|
||||
testautomation_mouse.c testautomation_pixels.c &
|
||||
testautomation_platform.c testautomation_rect.c &
|
||||
testautomation_render.c testautomation_rwops.c &
|
||||
testautomation_sdltest.c testautomation_stdlib.c &
|
||||
testautomation_surface.c testautomation_syswm.c &
|
||||
testautomation_timer.c testautomation_video.c
|
||||
|
||||
OBJS = $(TARGETS:.exe=.obj)
|
||||
COBJS = $(CSRCS:.c=.obj)
|
||||
TAOBJS = $(TASRCS:.c=.obj)
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
.c: ../src/test
|
||||
|
||||
$(TESTLIB): $(COBJS)
|
||||
wlib -q -b -n -c $@ $(COBJS)
|
||||
|
||||
.obj.exe:
|
||||
@%make $(TESTLIB)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
.c.obj:
|
||||
wcc386 $(CFLAGS) -fo=$^@ $<
|
||||
|
||||
# specials
|
||||
testautomation.exe: $(TAOBJS)
|
||||
@%make $(TESTLIB)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testnative.exe: testnative.obj testnativeos2.obj
|
||||
@%make $(TESTLIB)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testoverlay2.exe: testoverlay2.obj testyuv_cvt.obj
|
||||
@%make $(TESTLIB)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testyuv.exe: testyuv.obj testyuv_cvt.obj
|
||||
@%make $(TESTLIB)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testime.exe: testime.obj
|
||||
@%make $(TESTLIB)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS) $(TTFLIBS)} op q op el file {$<} name $@
|
||||
|
||||
clean: .SYMBOLIC
|
||||
@if exist *.obj rm *.obj
|
||||
@if exist *.err rm *.err
|
||||
|
||||
distclean: .SYMBOLIC clean
|
||||
@if exist *.exe rm *.exe
|
||||
@if exist $(TESTLIB) rm $(TESTLIB)
|
||||
!include watcom.mif
|
||||
|
16
externals/SDL/test/Makefile.w32
vendored
Executable file
16
externals/SDL/test/Makefile.w32
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
# Open Watcom makefile to build SDL2 tests for Win32
|
||||
# wmake -f Makefile.w32
|
||||
|
||||
SYSTEM = nt
|
||||
|
||||
INCPATH = -I"$(%WATCOM)/h/nt" -I"$(%WATCOM)/h" -I"../src/video/khronos"
|
||||
|
||||
CFLAGS = -bt=nt -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei
|
||||
CFLAGS+= -wx -wcd=303
|
||||
CFLAGS+= -DSDL_MAIN_HANDLED
|
||||
CFLAGS+= -DHAVE_OPENGL
|
||||
GLLIBS = opengl32.lib
|
||||
|
||||
TNSRCS = testnative.c testnativew32.c
|
||||
|
||||
!include watcom.mif
|
8
externals/SDL/test/autogen.sh
vendored
8
externals/SDL/test/autogen.sh
vendored
@@ -1,11 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cp acinclude.m4 aclocal.m4
|
||||
|
||||
if test "$AUTOCONF"x = x; then
|
||||
AUTOCONF=autoconf
|
||||
fi
|
||||
|
||||
$AUTOCONF || exit 1
|
||||
"${AUTOCONF:-autoconf}"
|
||||
rm aclocal.m4
|
||||
rm -rf autom4te.cache
|
||||
|
11
externals/SDL/test/checkkeys.c
vendored
11
externals/SDL/test/checkkeys.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -165,7 +165,11 @@ loop()
|
||||
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
|
||||
break;
|
||||
case SDL_TEXTEDITING:
|
||||
PrintText("EDIT", event.text.text);
|
||||
PrintText("EDIT", event.edit.text);
|
||||
break;
|
||||
case SDL_TEXTEDITING_EXT:
|
||||
PrintText("EDIT_EXT", event.editExt.text);
|
||||
SDL_free(event.editExt.text);
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
PrintText("INPUT", event.text.text);
|
||||
@@ -207,6 +211,9 @@ main(int argc, char *argv[])
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Enable extended text editing events */
|
||||
SDL_SetHint(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1");
|
||||
|
||||
/* Initialize SDL */
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
|
2
externals/SDL/test/checkkeysthreads.c
vendored
2
externals/SDL/test/checkkeysthreads.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2419
externals/SDL/test/configure
vendored
2419
externals/SDL/test/configure
vendored
File diff suppressed because it is too large
Load Diff
44
externals/SDL/test/controllermap.c
vendored
44
externals/SDL/test/controllermap.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
|
||||
@@ -169,39 +170,6 @@ 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)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *texture;
|
||||
|
||||
/* Load the sprite image */
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create textures from the image */
|
||||
texture = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
return NULL;
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return texture;
|
||||
}
|
||||
|
||||
static int
|
||||
StandardizeAxisValue(int nValue)
|
||||
{
|
||||
@@ -392,10 +360,10 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||
Uint32 alpha_ticks = 0;
|
||||
SDL_JoystickID nJoystickID;
|
||||
|
||||
background_front = LoadTexture(screen, "controllermap.bmp", SDL_FALSE);
|
||||
background_back = LoadTexture(screen, "controllermap_back.bmp", SDL_FALSE);
|
||||
button = LoadTexture(screen, "button.bmp", SDL_TRUE);
|
||||
axis = LoadTexture(screen, "axis.bmp", SDL_TRUE);
|
||||
background_front = LoadTexture(screen, "controllermap.bmp", SDL_FALSE, NULL, NULL);
|
||||
background_back = LoadTexture(screen, "controllermap_back.bmp", SDL_FALSE, NULL, NULL);
|
||||
button = LoadTexture(screen, "button.bmp", SDL_TRUE, NULL, NULL);
|
||||
axis = LoadTexture(screen, "axis.bmp", SDL_TRUE, NULL, NULL);
|
||||
SDL_RaiseWindow(window);
|
||||
|
||||
/* scale for platforms that don't give you the window size you asked for. */
|
||||
|
16
externals/SDL/test/loopwave.c
vendored
16
externals/SDL/test/loopwave.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
static struct
|
||||
{
|
||||
@@ -114,7 +115,7 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char filename[4096];
|
||||
char *filename = NULL;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -125,11 +126,13 @@ main(int argc, char *argv[])
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
SDL_strlcpy(filename, argv[1], sizeof(filename));
|
||||
} else {
|
||||
SDL_strlcpy(filename, "sample.wav", sizeof(filename));
|
||||
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
|
||||
@@ -172,6 +175,7 @@ main(int argc, char *argv[])
|
||||
/* Clean up on signal */
|
||||
close_audio();
|
||||
SDL_FreeWAV(wave.sound);
|
||||
SDL_free(filename);
|
||||
SDL_Quit();
|
||||
return (0);
|
||||
}
|
||||
|
17
externals/SDL/test/loopwavequeue.c
vendored
17
externals/SDL/test/loopwavequeue.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
static struct
|
||||
{
|
||||
SDL_AudioSpec spec;
|
||||
@@ -74,7 +76,7 @@ loop()
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char filename[4096];
|
||||
char *filename = NULL;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -85,11 +87,13 @@ main(int argc, char *argv[])
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
SDL_strlcpy(filename, argv[1], sizeof(filename));
|
||||
} else {
|
||||
SDL_strlcpy(filename, "sample.wav", sizeof(filename));
|
||||
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
|
||||
@@ -142,6 +146,7 @@ main(int argc, char *argv[])
|
||||
/* Clean up on signal */
|
||||
SDL_CloseAudio();
|
||||
SDL_FreeWAV(wave.sound);
|
||||
SDL_free(filename);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
3
externals/SDL/test/template.test.in
vendored
Executable file
3
externals/SDL/test/template.test.in
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
[Test]
|
||||
Type=session
|
||||
Exec=@installedtestsdir@/@exe@
|
35
externals/SDL/test/testatomic.c
vendored
35
externals/SDL/test/testatomic.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -471,9 +471,6 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
|
||||
return status;
|
||||
}
|
||||
|
||||
static SDL_sem *writersDone;
|
||||
static SDL_sem *readersDone;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_EventQueue *queue;
|
||||
@@ -482,6 +479,7 @@ typedef struct
|
||||
int waits;
|
||||
SDL_bool lock_free;
|
||||
char padding2[SDL_CACHELINE_SIZE-sizeof(int)-sizeof(SDL_bool)];
|
||||
SDL_Thread *thread;
|
||||
} WriterData;
|
||||
|
||||
typedef struct
|
||||
@@ -491,6 +489,7 @@ typedef struct
|
||||
int waits;
|
||||
SDL_bool lock_free;
|
||||
char padding[SDL_CACHELINE_SIZE-(sizeof(SDL_EventQueue*)+sizeof(int)*NUM_WRITERS+sizeof(int)+sizeof(SDL_bool))%SDL_CACHELINE_SIZE];
|
||||
SDL_Thread *thread;
|
||||
} ReaderData;
|
||||
|
||||
static int SDLCALL FIFO_Writer(void* _data)
|
||||
@@ -523,7 +522,6 @@ static int SDLCALL FIFO_Writer(void* _data)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_SemPost(writersDone);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -560,7 +558,6 @@ static int SDLCALL FIFO_Reader(void* _data)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_SemPost(readersDone);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -590,6 +587,7 @@ static int SDLCALL FIFO_Watcher(void* _data)
|
||||
static void RunFIFOTest(SDL_bool lock_free)
|
||||
{
|
||||
SDL_EventQueue queue;
|
||||
SDL_Thread *fifo_thread = NULL;
|
||||
WriterData writerData[NUM_WRITERS];
|
||||
ReaderData readerData[NUM_READERS];
|
||||
Uint32 start, end;
|
||||
@@ -601,9 +599,6 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
SDL_Log("\nFIFO test---------------------------------------\n\n");
|
||||
SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
|
||||
|
||||
readersDone = SDL_CreateSemaphore(0);
|
||||
writersDone = SDL_CreateSemaphore(0);
|
||||
|
||||
SDL_memset(&queue, 0xff, sizeof(queue));
|
||||
|
||||
InitEventQueue(&queue);
|
||||
@@ -616,7 +611,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
#ifdef TEST_SPINLOCK_FIFO
|
||||
/* Start a monitoring thread */
|
||||
if (lock_free) {
|
||||
SDL_CreateThread(FIFO_Watcher, "FIFOWatcher", &queue);
|
||||
fifo_thread = SDL_CreateThread(FIFO_Watcher, "FIFOWatcher", &queue);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -628,7 +623,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
SDL_snprintf(name, sizeof (name), "FIFOReader%d", i);
|
||||
readerData[i].queue = &queue;
|
||||
readerData[i].lock_free = lock_free;
|
||||
SDL_CreateThread(FIFO_Reader, name, &readerData[i]);
|
||||
readerData[i].thread = SDL_CreateThread(FIFO_Reader, name, &readerData[i]);
|
||||
}
|
||||
|
||||
/* Start up the writers */
|
||||
@@ -640,12 +635,12 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
writerData[i].queue = &queue;
|
||||
writerData[i].index = i;
|
||||
writerData[i].lock_free = lock_free;
|
||||
SDL_CreateThread(FIFO_Writer, name, &writerData[i]);
|
||||
writerData[i].thread = SDL_CreateThread(FIFO_Writer, name, &writerData[i]);
|
||||
}
|
||||
|
||||
/* Wait for the writers */
|
||||
for (i = 0; i < NUM_WRITERS; ++i) {
|
||||
SDL_SemWait(writersDone);
|
||||
SDL_WaitThread(writerData[i].thread, NULL);
|
||||
}
|
||||
|
||||
/* Shut down the queue so readers exit */
|
||||
@@ -653,13 +648,15 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
|
||||
/* Wait for the readers */
|
||||
for (i = 0; i < NUM_READERS; ++i) {
|
||||
SDL_SemWait(readersDone);
|
||||
SDL_WaitThread(readerData[i].thread, NULL);
|
||||
}
|
||||
|
||||
end = SDL_GetTicks();
|
||||
|
||||
SDL_DestroySemaphore(readersDone);
|
||||
SDL_DestroySemaphore(writersDone);
|
||||
/* Wait for the FIFO thread */
|
||||
if (fifo_thread) {
|
||||
SDL_WaitThread(fifo_thread, NULL);
|
||||
}
|
||||
|
||||
if (!lock_free) {
|
||||
SDL_DestroyMutex(queue.mutex);
|
||||
@@ -709,6 +706,12 @@ main(int argc, char *argv[])
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
RunBasicTest();
|
||||
|
||||
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
|
||||
SDL_Log("Not running slower tests");
|
||||
return 0;
|
||||
}
|
||||
|
||||
RunEpicTest();
|
||||
/* This test is really slow, so don't run it by default */
|
||||
#if 0
|
||||
|
2
externals/SDL/test/testaudiocapture.c
vendored
2
externals/SDL/test/testaudiocapture.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
16
externals/SDL/test/testaudiohotplug.c
vendored
16
externals/SDL/test/testaudiohotplug.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -26,6 +26,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
static SDL_AudioSpec spec;
|
||||
static Uint8 *sound = NULL; /* Pointer to wave data */
|
||||
@@ -137,7 +138,7 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char filename[4096];
|
||||
char *filename = NULL;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -151,11 +152,13 @@ main(int argc, char *argv[])
|
||||
/* Some targets (Mac CoreAudio) need an event queue for audio hotplug, so make and immediately hide a window. */
|
||||
SDL_MinimizeWindow(SDL_CreateWindow("testaudiohotplug", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0));
|
||||
|
||||
if (argc > 1) {
|
||||
SDL_strlcpy(filename, argv[1], sizeof(filename));
|
||||
} else {
|
||||
SDL_strlcpy(filename, "sample.wav", sizeof(filename));
|
||||
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
|
||||
@@ -196,6 +199,7 @@ main(int argc, char *argv[])
|
||||
/* Quit audio first, then free WAV. This prevents access violations in the audio threads. */
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
SDL_FreeWAV(sound);
|
||||
SDL_free(filename);
|
||||
SDL_Quit();
|
||||
return (0);
|
||||
}
|
||||
|
2
externals/SDL/test/testaudioinfo.c
vendored
2
externals/SDL/test/testaudioinfo.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testautomation.c
vendored
2
externals/SDL/test/testautomation.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
8
externals/SDL/test/testautomation_hints.c
vendored
8
externals/SDL/test/testautomation_hints.c
vendored
@@ -8,7 +8,6 @@
|
||||
#include "SDL_test.h"
|
||||
|
||||
|
||||
const int _numHintsEnum = 25;
|
||||
const char* _HintsEnum[] =
|
||||
{
|
||||
SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
|
||||
@@ -32,9 +31,7 @@ const char* _HintsEnum[] =
|
||||
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,
|
||||
};
|
||||
const char* _HintsVerbose[] =
|
||||
@@ -60,12 +57,13 @@ const char* _HintsVerbose[] =
|
||||
"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"
|
||||
};
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(HintsEnum, SDL_arraysize(_HintsEnum) == SDL_arraysize(_HintsVerbose));
|
||||
|
||||
const int _numHintsEnum = SDL_arraysize(_HintsEnum);
|
||||
|
||||
/* Test case functions */
|
||||
|
||||
|
3351
externals/SDL/test/testautomation_math.c
vendored
Executable file
3351
externals/SDL/test/testautomation_math.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
21
externals/SDL/test/testautomation_platform.c
vendored
21
externals/SDL/test/testautomation_platform.c
vendored
@@ -54,12 +54,18 @@ int platform_testTypes(void *arg)
|
||||
int platform_testEndianessAndSwap(void *arg)
|
||||
{
|
||||
int real_byteorder;
|
||||
int real_floatwordorder = 0;
|
||||
Uint16 value = 0x1234;
|
||||
Uint16 value16 = 0xCDAB;
|
||||
Uint16 swapped16 = 0xABCD;
|
||||
Uint32 value32 = 0xEFBEADDE;
|
||||
Uint32 swapped32 = 0xDEADBEEF;
|
||||
|
||||
union {
|
||||
double d;
|
||||
Uint32 ui32[2];
|
||||
} value_double;
|
||||
|
||||
Uint64 value64, swapped64;
|
||||
value64 = 0xEFBEADDE;
|
||||
value64 <<= 32;
|
||||
@@ -67,6 +73,7 @@ int platform_testEndianessAndSwap(void *arg)
|
||||
swapped64 = 0x1234ABCD;
|
||||
swapped64 <<= 32;
|
||||
swapped64 |= 0xDEADBEEF;
|
||||
value_double.d = 3.141593;
|
||||
|
||||
if ((*((char *) &value) >> 4) == 0x1) {
|
||||
real_byteorder = SDL_BIG_ENDIAN;
|
||||
@@ -80,6 +87,18 @@ int platform_testEndianessAndSwap(void *arg)
|
||||
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
|
||||
(real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" );
|
||||
|
||||
if (value_double.ui32[0] == 0x82c2bd7f && value_double.ui32[1] == 0x400921fb) {
|
||||
real_floatwordorder = SDL_LIL_ENDIAN;
|
||||
} else if (value_double.ui32[0] == 0x400921fb && value_double.ui32[1] == 0x82c2bd7f) {
|
||||
real_floatwordorder = SDL_BIG_ENDIAN;
|
||||
}
|
||||
|
||||
/* Test endianness. */
|
||||
SDLTest_AssertCheck( real_floatwordorder == SDL_FLOATWORDORDER,
|
||||
"Machine detected as having %s endian float word order, appears to be %s endian.",
|
||||
(SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big",
|
||||
(real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" : "unknown" );
|
||||
|
||||
/* Test 16 swap. */
|
||||
SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16,
|
||||
"SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X",
|
||||
@@ -525,7 +544,7 @@ static const SDLTest_TestCaseReference platformTest1 =
|
||||
{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest2 =
|
||||
{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED};
|
||||
{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianness and swap functions", TEST_ENABLED};
|
||||
|
||||
static const SDLTest_TestCaseReference platformTest3 =
|
||||
{ (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED};
|
||||
|
106
externals/SDL/test/testautomation_rect.c
vendored
106
externals/SDL/test/testautomation_rect.c
vendored
@@ -408,6 +408,32 @@ void _validateRectEqualsResults(
|
||||
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
|
||||
}
|
||||
|
||||
/* !
|
||||
* \brief Private helper to check SDL_FRectEquals results
|
||||
*/
|
||||
void _validateFRectEqualsResults(
|
||||
SDL_bool equals, SDL_bool expectedEquals,
|
||||
SDL_FRect *rectA, SDL_FRect *rectB, SDL_FRect *refRectA, SDL_FRect *refRectB)
|
||||
{
|
||||
int cmpRes;
|
||||
SDLTest_AssertCheck(equals == expectedEquals,
|
||||
"Check for correct equals result: expected %s, got %s testing (%f,%f,%f,%f) and (%f,%f,%f,%f)",
|
||||
(expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
|
||||
(equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE",
|
||||
rectA->x, rectA->y, rectA->w, rectA->h,
|
||||
rectB->x, rectB->y, rectB->w, rectB->h);
|
||||
cmpRes = SDL_memcmp(rectA, refRectA, sizeof(*rectA));
|
||||
SDLTest_AssertCheck(cmpRes == 0,
|
||||
"Check that source rectangle A was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)",
|
||||
rectA->x, rectA->y, rectA->w, rectA->h,
|
||||
refRectA->x, refRectA->y, refRectA->w, refRectA->h);
|
||||
cmpRes = SDL_memcmp(rectB, refRectB, sizeof(*rectB));
|
||||
SDLTest_AssertCheck(cmpRes == 0,
|
||||
"Check that source rectangle B was not modified: got (%f,%f,%f,%f) expected (%f,%f,%f,%f)",
|
||||
rectB->x, rectB->y, rectB->w, rectB->h,
|
||||
refRectB->x, refRectB->y, refRectB->w, refRectB->h);
|
||||
}
|
||||
|
||||
/* !
|
||||
* \brief Tests SDL_IntersectRect() with B fully inside A
|
||||
*
|
||||
@@ -681,7 +707,7 @@ int rect_testIntersectRectEmpty (void *arg)
|
||||
int rect_testIntersectRectParam(void *arg)
|
||||
{
|
||||
SDL_Rect rectA;
|
||||
SDL_Rect rectB;
|
||||
SDL_Rect rectB = {0};
|
||||
SDL_Rect result;
|
||||
SDL_bool intersection;
|
||||
|
||||
@@ -936,7 +962,7 @@ int rect_testHasIntersectionEmpty (void *arg)
|
||||
int rect_testHasIntersectionParam(void *arg)
|
||||
{
|
||||
SDL_Rect rectA;
|
||||
SDL_Rect rectB;
|
||||
SDL_Rect rectB = {0};
|
||||
SDL_bool intersection;
|
||||
|
||||
/* invalid parameter combinations */
|
||||
@@ -1205,7 +1231,7 @@ int rect_testEnclosePointsParam(void *arg)
|
||||
{
|
||||
SDL_Point points[1];
|
||||
int count;
|
||||
SDL_Rect clip;
|
||||
SDL_Rect clip = { 0 };
|
||||
SDL_Rect result;
|
||||
SDL_bool anyEnclosed;
|
||||
|
||||
@@ -1431,7 +1457,7 @@ int rect_testUnionRectInside(void *arg)
|
||||
*/
|
||||
int rect_testUnionRectParam(void *arg)
|
||||
{
|
||||
SDL_Rect rectA, rectB;
|
||||
SDL_Rect rectA, rectB = { 0 };
|
||||
SDL_Rect result;
|
||||
|
||||
/* invalid parameter combinations */
|
||||
@@ -1574,6 +1600,69 @@ int rect_testRectEqualsParam(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* !
|
||||
* \brief Tests SDL_FRectEquals() with various inputs
|
||||
*
|
||||
* \sa
|
||||
* http://wiki.libsdl.org/SDL_FRectEquals
|
||||
*/
|
||||
int rect_testFRectEquals(void *arg)
|
||||
{
|
||||
SDL_FRect refRectA;
|
||||
SDL_FRect refRectB;
|
||||
SDL_FRect rectA;
|
||||
SDL_FRect rectB;
|
||||
SDL_bool expectedResult;
|
||||
SDL_bool result;
|
||||
|
||||
/* Equals */
|
||||
refRectA.x=(float)SDLTest_RandomIntegerInRange(-1024, 1024);
|
||||
refRectA.y=(float)SDLTest_RandomIntegerInRange(-1024, 1024);
|
||||
refRectA.w=(float)SDLTest_RandomIntegerInRange(1, 1024);
|
||||
refRectA.h=(float)SDLTest_RandomIntegerInRange(1, 1024);
|
||||
refRectB = refRectA;
|
||||
expectedResult = SDL_TRUE;
|
||||
rectA = refRectA;
|
||||
rectB = refRectB;
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)&rectA, (const SDL_FRect *)&rectB);
|
||||
_validateFRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* !
|
||||
* \brief Negative tests against SDL_FRectEquals() with invalid parameters
|
||||
*
|
||||
* \sa
|
||||
* http://wiki.libsdl.org/SDL_FRectEquals
|
||||
*/
|
||||
int rect_testFRectEqualsParam(void *arg)
|
||||
{
|
||||
SDL_FRect rectA;
|
||||
SDL_FRect rectB;
|
||||
SDL_bool result;
|
||||
|
||||
/* data setup -- For the purpose of this test, the values don't matter. */
|
||||
rectA.x=SDLTest_RandomFloat();
|
||||
rectA.y=SDLTest_RandomFloat();
|
||||
rectA.w=SDLTest_RandomFloat();
|
||||
rectA.h=SDLTest_RandomFloat();
|
||||
rectB.x=SDLTest_RandomFloat();
|
||||
rectB.y=SDLTest_RandomFloat();
|
||||
rectB.w=SDLTest_RandomFloat();
|
||||
rectB.h=SDLTest_RandomFloat();
|
||||
|
||||
/* invalid parameter combinations */
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)NULL, (const SDL_FRect *)&rectB);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)&rectA, (const SDL_FRect *)NULL);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)NULL, (const SDL_FRect *)NULL);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Rect test cases */
|
||||
@@ -1673,6 +1762,13 @@ static const SDLTest_TestCaseReference rectTest28 =
|
||||
static const SDLTest_TestCaseReference rectTest29 =
|
||||
{ (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED };
|
||||
|
||||
/* SDL_FRectEquals */
|
||||
|
||||
static const SDLTest_TestCaseReference rectTest30 =
|
||||
{ (SDLTest_TestCaseFp)rect_testFRectEquals, "rect_testFRectEquals", "Tests SDL_FRectEquals with various inputs", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference rectTest31 =
|
||||
{ (SDLTest_TestCaseFp)rect_testFRectEqualsParam, "rect_testFRectEqualsParam", "Negative tests against SDL_FRectEquals with invalid parameters", TEST_ENABLED };
|
||||
|
||||
/* !
|
||||
* \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
|
||||
@@ -1683,7 +1779,7 @@ static const SDLTest_TestCaseReference rectTest29 =
|
||||
static const SDLTest_TestCaseReference *rectTests[] = {
|
||||
&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14,
|
||||
&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
|
||||
&rectTest28, &rectTest29, NULL
|
||||
&rectTest28, &rectTest29, &rectTest30, &rectTest31, NULL
|
||||
};
|
||||
|
||||
|
||||
|
59
externals/SDL/test/testautomation_render.c
vendored
59
externals/SDL/test/testautomation_render.c
vendored
@@ -187,14 +187,14 @@ int render_testPrimitives (void *arg)
|
||||
|
||||
ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 );
|
||||
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret);
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
|
||||
/* See if it's the same. */
|
||||
referenceSurface = SDLTest_ImagePrimitives();
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE );
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Clean up. */
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
referenceSurface = NULL;
|
||||
@@ -335,13 +335,13 @@ int render_testPrimitivesBlend (void *arg)
|
||||
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2);
|
||||
SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3);
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* See if it's the same. */
|
||||
referenceSurface = SDLTest_ImagePrimitivesBlend();
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED );
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Clean up. */
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
referenceSurface = NULL;
|
||||
@@ -404,13 +404,13 @@ render_testBlit(void *arg)
|
||||
}
|
||||
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount1);
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* See if it's the same */
|
||||
referenceSurface = SDLTest_ImageBlit();
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE );
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Clean up. */
|
||||
SDL_DestroyTexture( tface );
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
@@ -478,13 +478,13 @@ render_testBlitColor (void *arg)
|
||||
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1);
|
||||
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* See if it's the same. */
|
||||
referenceSurface = SDLTest_ImageBlitColor();
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE );
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Clean up. */
|
||||
SDL_DestroyTexture( tface );
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
@@ -555,13 +555,13 @@ render_testBlitAlpha (void *arg)
|
||||
SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1);
|
||||
SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2);
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* See if it's the same. */
|
||||
referenceSurface = SDLTest_ImageBlitAlpha();
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED );
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Clean up. */
|
||||
SDL_DestroyTexture( tface );
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
@@ -674,9 +674,10 @@ render_testBlitBlend (void *arg)
|
||||
_testBlitBlendMode( tface, SDL_BLENDMODE_NONE );
|
||||
referenceSurface = SDLTest_ImageBlitBlendNone();
|
||||
|
||||
/* Make current and compare */
|
||||
SDL_RenderPresent(renderer);
|
||||
/* Compare, then Present */
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE );
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
referenceSurface = NULL;
|
||||
|
||||
@@ -684,9 +685,10 @@ render_testBlitBlend (void *arg)
|
||||
_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND );
|
||||
referenceSurface = SDLTest_ImageBlitBlend();
|
||||
|
||||
/* Make current and compare */
|
||||
SDL_RenderPresent(renderer);
|
||||
/* Compare, then Present */
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED );
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
referenceSurface = NULL;
|
||||
|
||||
@@ -694,9 +696,10 @@ render_testBlitBlend (void *arg)
|
||||
_testBlitBlendMode( tface, SDL_BLENDMODE_ADD );
|
||||
referenceSurface = SDLTest_ImageBlitBlendAdd();
|
||||
|
||||
/* Make current and compare */
|
||||
SDL_RenderPresent(renderer);
|
||||
/* Compare, then Present */
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED );
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
referenceSurface = NULL;
|
||||
|
||||
@@ -704,9 +707,10 @@ render_testBlitBlend (void *arg)
|
||||
_testBlitBlendMode( tface, SDL_BLENDMODE_MOD);
|
||||
referenceSurface = SDLTest_ImageBlitBlendMod();
|
||||
|
||||
/* Make current and compare */
|
||||
SDL_RenderPresent(renderer);
|
||||
/* Compare, then Present */
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED );
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
referenceSurface = NULL;
|
||||
|
||||
@@ -753,12 +757,13 @@ render_testBlitBlend (void *arg)
|
||||
/* Clean up. */
|
||||
SDL_DestroyTexture( tface );
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Check to see if final image matches. */
|
||||
referenceSurface = SDLTest_ImageBlitBlendAll();
|
||||
_compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
|
||||
|
||||
/* Make current */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
SDL_FreeSurface(referenceSurface);
|
||||
referenceSurface = NULL;
|
||||
|
||||
|
172
externals/SDL/test/testautomation_stdlib.c
vendored
172
externals/SDL/test/testautomation_stdlib.c
vendored
@@ -322,6 +322,168 @@ stdlib_sscanf(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
#if defined(_WIN64)
|
||||
# define SIZE_FORMAT "I64u"
|
||||
#elif defined(__WIN32__)
|
||||
# define SIZE_FORMAT "I32u"
|
||||
#else
|
||||
# define SIZE_FORMAT "zu"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t a;
|
||||
size_t b;
|
||||
size_t result;
|
||||
int status;
|
||||
} overflow_test;
|
||||
|
||||
static const overflow_test multiplications[] =
|
||||
{
|
||||
{ 1, 1, 1, 0 },
|
||||
{ 0, 0, 0, 0 },
|
||||
{ SDL_SIZE_MAX, 0, 0, 0 },
|
||||
{ SDL_SIZE_MAX, 1, SDL_SIZE_MAX, 0 },
|
||||
{ SDL_SIZE_MAX / 2, 2, SDL_SIZE_MAX - (SDL_SIZE_MAX % 2), 0 },
|
||||
{ SDL_SIZE_MAX / 23, 23, SDL_SIZE_MAX - (SDL_SIZE_MAX % 23), 0 },
|
||||
|
||||
{ (SDL_SIZE_MAX / 2) + 1, 2, 0, -1 },
|
||||
{ (SDL_SIZE_MAX / 23) + 42, 23, 0, -1 },
|
||||
{ SDL_SIZE_MAX, SDL_SIZE_MAX, 0, -1 },
|
||||
};
|
||||
|
||||
static const overflow_test additions[] =
|
||||
{
|
||||
{ 1, 1, 2, 0 },
|
||||
{ 0, 0, 0, 0 },
|
||||
{ SDL_SIZE_MAX, 0, SDL_SIZE_MAX, 0 },
|
||||
{ SDL_SIZE_MAX - 1, 1, SDL_SIZE_MAX, 0 },
|
||||
{ SDL_SIZE_MAX - 42, 23, SDL_SIZE_MAX - (42 - 23), 0 },
|
||||
|
||||
{ SDL_SIZE_MAX, 1, 0, -1 },
|
||||
{ SDL_SIZE_MAX, 23, 0, -1 },
|
||||
{ SDL_SIZE_MAX, SDL_SIZE_MAX, 0, -1 },
|
||||
};
|
||||
|
||||
static int
|
||||
stdlib_overflow(void *arg)
|
||||
{
|
||||
size_t i;
|
||||
size_t useBuiltin;
|
||||
|
||||
for (useBuiltin = 0; useBuiltin < 2; useBuiltin++) {
|
||||
if (useBuiltin) {
|
||||
SDLTest_Log("Using gcc/clang builtins if possible");
|
||||
} else {
|
||||
SDLTest_Log("Not using gcc/clang builtins");
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_arraysize(multiplications); i++) {
|
||||
const overflow_test *t = &multiplications[i];
|
||||
int status;
|
||||
size_t result = ~t->result;
|
||||
|
||||
if (useBuiltin) {
|
||||
status = SDL_size_mul_overflow(t->a, t->b, &result);
|
||||
} else {
|
||||
/* This disables the macro that tries to use a gcc/clang
|
||||
* builtin, so we test the fallback implementation instead. */
|
||||
status = (SDL_size_mul_overflow)(t->a, t->b, &result);
|
||||
}
|
||||
|
||||
if (t->status == 0) {
|
||||
SDLTest_AssertCheck(status == 0,
|
||||
"(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should succeed",
|
||||
t->a, t->b);
|
||||
SDLTest_AssertCheck(result == t->result,
|
||||
"(%" SIZE_FORMAT " * %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT,
|
||||
t->a, t->b, t->result, result);
|
||||
} else {
|
||||
SDLTest_AssertCheck(status == -1,
|
||||
"(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should fail",
|
||||
t->a, t->b);
|
||||
}
|
||||
|
||||
if (t->a == t->b) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = ~t->result;
|
||||
|
||||
if (useBuiltin) {
|
||||
status = SDL_size_mul_overflow(t->b, t->a, &result);
|
||||
} else {
|
||||
status = (SDL_size_mul_overflow)(t->b, t->a, &result);
|
||||
}
|
||||
|
||||
if (t->status == 0) {
|
||||
SDLTest_AssertCheck(status == 0,
|
||||
"(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should succeed",
|
||||
t->b, t->a);
|
||||
SDLTest_AssertCheck(result == t->result,
|
||||
"(%" SIZE_FORMAT " * %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT,
|
||||
t->b, t->a, t->result, result);
|
||||
} else {
|
||||
SDLTest_AssertCheck(status == -1,
|
||||
"(%" SIZE_FORMAT " * %" SIZE_FORMAT ") should fail",
|
||||
t->b, t->a);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_arraysize(additions); i++) {
|
||||
const overflow_test *t = &additions[i];
|
||||
int status;
|
||||
size_t result = ~t->result;
|
||||
|
||||
if (useBuiltin) {
|
||||
status = SDL_size_add_overflow(t->a, t->b, &result);
|
||||
} else {
|
||||
status = (SDL_size_add_overflow)(t->a, t->b, &result);
|
||||
}
|
||||
|
||||
if (t->status == 0) {
|
||||
SDLTest_AssertCheck(status == 0,
|
||||
"(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should succeed",
|
||||
t->a, t->b);
|
||||
SDLTest_AssertCheck(result == t->result,
|
||||
"(%" SIZE_FORMAT " + %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT,
|
||||
t->a, t->b, t->result, result);
|
||||
} else {
|
||||
SDLTest_AssertCheck(status == -1,
|
||||
"(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should fail",
|
||||
t->a, t->b);
|
||||
}
|
||||
|
||||
if (t->a == t->b) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = ~t->result;
|
||||
|
||||
if (useBuiltin) {
|
||||
status = SDL_size_add_overflow(t->b, t->a, &result);
|
||||
} else {
|
||||
status = (SDL_size_add_overflow)(t->b, t->a, &result);
|
||||
}
|
||||
|
||||
if (t->status == 0) {
|
||||
SDLTest_AssertCheck(status == 0,
|
||||
"(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should succeed",
|
||||
t->b, t->a);
|
||||
SDLTest_AssertCheck(result == t->result,
|
||||
"(%" SIZE_FORMAT " + %" SIZE_FORMAT "): expected %" SIZE_FORMAT ", got %" SIZE_FORMAT,
|
||||
t->b, t->a, t->result, result);
|
||||
} else {
|
||||
SDLTest_AssertCheck(status == -1,
|
||||
"(%" SIZE_FORMAT " + %" SIZE_FORMAT ") should fail",
|
||||
t->b, t->a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Standard C routine test cases */
|
||||
@@ -337,9 +499,17 @@ static const SDLTest_TestCaseReference stdlibTest3 =
|
||||
static const SDLTest_TestCaseReference stdlibTest4 =
|
||||
{ (SDLTest_TestCaseFp)stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTestOverflow =
|
||||
{ stdlib_overflow, "stdlib_overflow", "Overflow detection", TEST_ENABLED };
|
||||
|
||||
/* Sequence of Standard C routine test cases */
|
||||
static const SDLTest_TestCaseReference *stdlibTests[] = {
|
||||
&stdlibTest1, &stdlibTest2, &stdlibTest3, &stdlibTest4, NULL
|
||||
&stdlibTest1,
|
||||
&stdlibTest2,
|
||||
&stdlibTest3,
|
||||
&stdlibTest4,
|
||||
&stdlibTestOverflow,
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Standard C routine test suite (global) */
|
||||
|
2
externals/SDL/test/testautomation_suites.h
vendored
2
externals/SDL/test/testautomation_suites.h
vendored
@@ -27,6 +27,7 @@ extern SDLTest_TestSuiteReference syswmTestSuite;
|
||||
extern SDLTest_TestSuiteReference timerTestSuite;
|
||||
extern SDLTest_TestSuiteReference videoTestSuite;
|
||||
extern SDLTest_TestSuiteReference hintsTestSuite;
|
||||
extern SDLTest_TestSuiteReference mathTestSuite;
|
||||
|
||||
/* All test suites */
|
||||
SDLTest_TestSuiteReference *testSuites[] = {
|
||||
@@ -48,6 +49,7 @@ SDLTest_TestSuiteReference *testSuites[] = {
|
||||
&timerTestSuite,
|
||||
&videoTestSuite,
|
||||
&hintsTestSuite,
|
||||
&mathTestSuite,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
182
externals/SDL/test/testautomation_surface.c
vendored
182
externals/SDL/test/testautomation_surface.c
vendored
@@ -178,6 +178,10 @@ void _testBlitBlendMode(int mode)
|
||||
bmode = SDL_BLENDMODE_ADD;
|
||||
} else if (nmode==3) {
|
||||
bmode = SDL_BLENDMODE_MOD;
|
||||
} else {
|
||||
/* Should be impossible, but some static checkers are too imprecise and will complain */
|
||||
SDLTest_LogError("Invalid: nmode=%d", nmode);
|
||||
return;
|
||||
}
|
||||
ret = SDL_SetSurfaceBlendMode( face, bmode );
|
||||
if (ret != 0) checkFailCount4++;
|
||||
@@ -333,7 +337,7 @@ surface_testCompleteSurfaceConversion(void *arg)
|
||||
SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
/*SDL_PIXELFORMAT_ARGB2101010,*/ /* SDL_PIXELFORMAT_ARGB2101010 isn't fully supported yet */
|
||||
SDL_PIXELFORMAT_ARGB2101010,
|
||||
};
|
||||
SDL_Surface *face = NULL, *cvt1, *cvt2, *final;
|
||||
SDL_PixelFormat *fmt1, *fmt2;
|
||||
@@ -589,6 +593,177 @@ surface_testBlitBlendLoop(void *arg) {
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
surface_testOverflow(void *arg)
|
||||
{
|
||||
char buf[1024];
|
||||
const char *expectedError;
|
||||
SDL_Surface *surface;
|
||||
|
||||
SDL_memset(buf, '\0', sizeof(buf));
|
||||
|
||||
expectedError = "Parameter 'width' is invalid";
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, -3, 100, 8, SDL_PIXELFORMAT_INDEX8);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, -1, 1, 8, 4, SDL_PIXELFORMAT_INDEX8);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, -1, 1, 32, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
expectedError = "Parameter 'height' is invalid";
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, 100, -3, 8, SDL_PIXELFORMAT_INDEX8);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 1, -1, 8, 4, SDL_PIXELFORMAT_INDEX8);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 1, -1, 32, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
expectedError = "Parameter 'pitch' is invalid";
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, 8, -1, SDL_PIXELFORMAT_INDEX8);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative pitch");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 1, 1, 32, -1, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect negative pitch");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
/* Less than 1 byte per pixel: the pitch can legitimately be less than
|
||||
* the width, but it must be enough to hold the appropriate number of
|
||||
* bits per pixel. SDL_PIXELFORMAT_INDEX4* needs 1 byte per 2 pixels. */
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 4, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 6, 1, 4, 3, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 4, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 7, 1, 4, 3, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 4, 4, SDL_PIXELFORMAT_INDEX4LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 7, 1, 4, 4, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
/* SDL_PIXELFORMAT_INDEX1* needs 1 byte per 8 pixels. */
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 16, 1, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 16, 1, 1, 2, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 17, 1, 1, 2, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 1, 3, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 7, 1, 1, 3, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
/* SDL_PIXELFORMAT_INDEX8 and SDL_PIXELFORMAT_RGB332 require 1 byte per pixel. */
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 5, 1, 8, 5, SDL_PIXELFORMAT_RGB332);
|
||||
SDLTest_AssertCheck(surface != NULL, "5px * 8 bits per px fits in 5 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 5, 1, 8, 5, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface != NULL, "5px * 8 bits per px fits in 5 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 8, 5, SDL_PIXELFORMAT_RGB332);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 6, 1, 8, 5, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
/* Everything else requires more than 1 byte per pixel, and rounds up
|
||||
* each pixel to an integer number of bytes (e.g. RGB555 is really
|
||||
* XRGB1555, with 1 bit per pixel wasted). */
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 3, 1, 15, 6, SDL_PIXELFORMAT_RGB555);
|
||||
SDLTest_AssertCheck(surface != NULL, "3px * 15 (really 16) bits per px fits in 6 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 3, 1, 15, 6, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface != NULL, "5px * 15 (really 16) bits per px fits in 6 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, 15, 6, SDL_PIXELFORMAT_RGB555);
|
||||
SDLTest_AssertCheck(surface == NULL, "4px * 15 (really 16) bits per px doesn't fit in 6 bytes");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceFrom(buf, 4, 1, 15, 6, 0, 0, 0, 0);
|
||||
SDLTest_AssertCheck(surface == NULL, "4px * 15 (really 16) bits per px doesn't fit in 6 bytes");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
|
||||
if (sizeof (size_t) == 4 && sizeof (int) >= 4) {
|
||||
expectedError = "Out of memory";
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32, 1, 8, SDL_PIXELFORMAT_INDEX8);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width + alignment");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32 / 2, 1, 32, SDL_PIXELFORMAT_ARGB8888);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * bytes per pixel");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 29) - 1, (1 << 29) - 1, 8, SDL_PIXELFORMAT_INDEX8);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 15) + 1, (1 << 15) + 1, 32, SDL_PIXELFORMAT_ARGB8888);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height * bytes per pixel");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
}
|
||||
else {
|
||||
SDLTest_Log("Can't easily overflow size_t on this platform");
|
||||
}
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Surface test cases */
|
||||
@@ -631,11 +806,14 @@ static const SDLTest_TestCaseReference surfaceTest11 =
|
||||
static const SDLTest_TestCaseReference surfaceTest12 =
|
||||
{ (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED};
|
||||
|
||||
static const SDLTest_TestCaseReference surfaceTestOverflow =
|
||||
{ surface_testOverflow, "surface_testOverflow", "Test overflow detection.", TEST_ENABLED};
|
||||
|
||||
/* Sequence of Surface test cases */
|
||||
static const SDLTest_TestCaseReference *surfaceTests[] = {
|
||||
&surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
|
||||
&surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10,
|
||||
&surfaceTest11, &surfaceTest12, NULL
|
||||
&surfaceTest11, &surfaceTest12, &surfaceTestOverflow, NULL
|
||||
};
|
||||
|
||||
/* Surface test suite (global) */
|
||||
|
131
externals/SDL/test/testautomation_video.c
vendored
131
externals/SDL/test/testautomation_video.c
vendored
@@ -1372,7 +1372,8 @@ video_getSetWindowMinimumSize(void *arg)
|
||||
int wVariation, hVariation;
|
||||
int referenceW, referenceH;
|
||||
int currentW, currentH;
|
||||
int desiredW, desiredH;
|
||||
int desiredW = 1;
|
||||
int desiredH = 1;
|
||||
|
||||
/* Get display bounds for size range */
|
||||
result = SDL_GetDisplayBounds(0, &display);
|
||||
@@ -1848,6 +1849,129 @@ video_getSetWindowData(void *arg)
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tests the functionality of the SDL_WINDOWPOS_CENTERED_DISPLAY along with SDL_WINDOW_FULLSCREEN_DESKTOP.
|
||||
*
|
||||
* Espeically useful when run on a multi-monitor system with different DPI scales per monitor,
|
||||
* to test that the window size is maintained when moving between monitors.
|
||||
*/
|
||||
int
|
||||
video_setWindowCenteredOnDisplay(void *arg)
|
||||
{
|
||||
SDL_Window *window;
|
||||
const char *title = "video_setWindowCenteredOnDisplay Test Window";
|
||||
int x, y, w, h;
|
||||
int xVariation, yVariation;
|
||||
int displayNum;
|
||||
int result;
|
||||
SDL_Rect display0, display1;
|
||||
|
||||
displayNum = SDL_GetNumVideoDisplays();
|
||||
|
||||
/* Get display bounds */
|
||||
result = SDL_GetDisplayBounds(0 % displayNum, &display0);
|
||||
SDLTest_AssertPass("SDL_GetDisplayBounds()");
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
if (result != 0)
|
||||
return TEST_ABORTED;
|
||||
|
||||
result = SDL_GetDisplayBounds(1 % displayNum, &display1);
|
||||
SDLTest_AssertPass("SDL_GetDisplayBounds()");
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
if (result != 0)
|
||||
return TEST_ABORTED;
|
||||
|
||||
for (xVariation = 0; xVariation < 2; xVariation++) {
|
||||
for (yVariation = 0; yVariation < 2; yVariation++) {
|
||||
int currentX = 0, currentY = 0;
|
||||
int currentW = 0, currentH = 0;
|
||||
int expectedX = 0, expectedY = 0;
|
||||
int currentDisplay;
|
||||
int expectedDisplay;
|
||||
SDL_Rect expectedDisplayRect;
|
||||
|
||||
/* xVariation is the display we start on */
|
||||
expectedDisplay = xVariation % displayNum;
|
||||
x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
|
||||
y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
|
||||
w = SDLTest_RandomIntegerInRange(640, 800);
|
||||
h = SDLTest_RandomIntegerInRange(400, 600);
|
||||
expectedDisplayRect = (xVariation == 0) ? display0 : display1;
|
||||
expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
|
||||
expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
|
||||
|
||||
window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
|
||||
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
|
||||
|
||||
/* Check the window is centered on the requested display */
|
||||
currentDisplay = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
|
||||
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
|
||||
|
||||
/* Enter fullscreen desktop */
|
||||
result = SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
|
||||
/* Check we are filling the full display */
|
||||
currentDisplay = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
SDLTest_AssertCheck(currentW == expectedDisplayRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedDisplayRect.w);
|
||||
SDLTest_AssertCheck(currentH == expectedDisplayRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedDisplayRect.h);
|
||||
SDLTest_AssertCheck(currentX == expectedDisplayRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedDisplayRect.x);
|
||||
SDLTest_AssertCheck(currentY == expectedDisplayRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedDisplayRect.y);
|
||||
|
||||
/* Leave fullscreen desktop */
|
||||
result = SDL_SetWindowFullscreen(window, 0);
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
|
||||
/* Check window was restored correctly */
|
||||
currentDisplay = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
|
||||
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
|
||||
|
||||
/* Center on display yVariation, and check window properties */
|
||||
|
||||
expectedDisplay = yVariation % displayNum;
|
||||
x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
|
||||
y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
|
||||
expectedDisplayRect = (expectedDisplay == 0) ? display0 : display1;
|
||||
expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
|
||||
expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
|
||||
currentDisplay = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
|
||||
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
|
||||
|
||||
/* Clean up */
|
||||
_destroyVideoSuiteTestWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
@@ -1921,13 +2045,16 @@ static const SDLTest_TestCaseReference videoTest22 =
|
||||
static const SDLTest_TestCaseReference videoTest23 =
|
||||
{ (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference videoTest24 =
|
||||
{ (SDLTest_TestCaseFp) video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED };
|
||||
|
||||
/* Sequence of Video test cases */
|
||||
static const SDLTest_TestCaseReference *videoTests[] = {
|
||||
&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
|
||||
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
|
||||
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
|
||||
&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
|
||||
&videoTest23, NULL
|
||||
&videoTest23, &videoTest24, NULL
|
||||
};
|
||||
|
||||
/* Video test suite (global) */
|
||||
|
2
externals/SDL/test/testbounds.c
vendored
2
externals/SDL/test/testbounds.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
72
externals/SDL/test/testcustomcursor.c
vendored
72
externals/SDL/test/testcustomcursor.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -135,6 +135,8 @@ init_system_cursor(const char *image[])
|
||||
static SDLTest_CommonState *state;
|
||||
int done;
|
||||
static SDL_Cursor *cursors[1+SDL_NUM_SYSTEM_CURSORS];
|
||||
static SDL_SystemCursor cursor_types[1+SDL_NUM_SYSTEM_CURSORS];
|
||||
static int num_cursors;
|
||||
static int current_cursor;
|
||||
static int show_cursor;
|
||||
|
||||
@@ -156,11 +158,34 @@ loop()
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||
if (num_cursors == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
++current_cursor;
|
||||
if (current_cursor == SDL_arraysize(cursors)) {
|
||||
if (current_cursor == num_cursors) {
|
||||
current_cursor = 0;
|
||||
}
|
||||
|
||||
SDL_SetCursor(cursors[current_cursor]);
|
||||
|
||||
switch (cursor_types[current_cursor]) {
|
||||
case (SDL_SystemCursor)-1: SDL_Log("Custom cursor"); break;
|
||||
case SDL_SYSTEM_CURSOR_ARROW: SDL_Log("Arrow"); break;
|
||||
case SDL_SYSTEM_CURSOR_IBEAM: SDL_Log("I-beam"); break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT: SDL_Log("Wait"); break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR: SDL_Log("Crosshair"); break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW: SDL_Log("Small wait cursor (or Wait if not available)"); break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE: SDL_Log("Double arrow pointing northwest and southeast"); break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW: SDL_Log("Double arrow pointing northeast and southwest"); break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE: SDL_Log("Double arrow pointing west and east"); break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS: SDL_Log("Double arrow pointing north and south"); break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL: SDL_Log("Four pointed arrow pointing north, south, east, and west"); break;
|
||||
case SDL_SYSTEM_CURSOR_NO: SDL_Log("Slashed circle or crossbones"); break;
|
||||
case SDL_SYSTEM_CURSOR_HAND: SDL_Log("Hand"); break;
|
||||
default: SDL_Log("UNKNOWN CURSOR TYPE, FIX THIS PROGRAM."); break;
|
||||
}
|
||||
|
||||
} else {
|
||||
show_cursor = !show_cursor;
|
||||
SDL_ShowCursor(show_cursor);
|
||||
@@ -219,23 +244,38 @@ main(int argc, char *argv[])
|
||||
SDL_RenderClear(renderer);
|
||||
}
|
||||
|
||||
num_cursors = 0;
|
||||
|
||||
if (color_cursor) {
|
||||
cursors[0] = init_color_cursor(color_cursor);
|
||||
SDL_Cursor *cursor = init_color_cursor(color_cursor);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
||||
num_cursors++;
|
||||
}
|
||||
} else {
|
||||
cursors[0] = init_system_cursor(arrow);
|
||||
}
|
||||
if (!cursors[0]) {
|
||||
SDL_Log("Error, couldn't create cursor\n");
|
||||
quit(2);
|
||||
}
|
||||
for (i = 0; i < SDL_NUM_SYSTEM_CURSORS; ++i) {
|
||||
cursors[1+i] = SDL_CreateSystemCursor((SDL_SystemCursor)i);
|
||||
if (!cursors[1+i]) {
|
||||
SDL_Log("Error, couldn't create system cursor %d\n", i);
|
||||
quit(2);
|
||||
SDL_Cursor *cursor = init_system_cursor(arrow);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
||||
num_cursors++;
|
||||
}
|
||||
}
|
||||
SDL_SetCursor(cursors[0]);
|
||||
|
||||
for (i = 0; i < SDL_NUM_SYSTEM_CURSORS; ++i) {
|
||||
SDL_Cursor *cursor = SDL_CreateSystemCursor((SDL_SystemCursor)i);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = i;
|
||||
num_cursors++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_cursors > 0) {
|
||||
SDL_SetCursor(cursors[0]);
|
||||
}
|
||||
|
||||
show_cursor = SDL_ShowCursor(SDL_QUERY);
|
||||
|
||||
/* Main render loop */
|
||||
done = 0;
|
||||
@@ -247,7 +287,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < SDL_arraysize(cursors); ++i) {
|
||||
for (i = 0; i < num_cursors; ++i) {
|
||||
SDL_FreeCursor(cursors[i]);
|
||||
}
|
||||
quit(0);
|
||||
|
2
externals/SDL/test/testdisplayinfo.c
vendored
2
externals/SDL/test/testdisplayinfo.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testdraw2.c
vendored
2
externals/SDL/test/testdraw2.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testdrawchessboard.c
vendored
2
externals/SDL/test/testdrawchessboard.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testdropfile.c
vendored
2
externals/SDL/test/testdropfile.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
8
externals/SDL/test/testerror.c
vendored
8
externals/SDL/test/testerror.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -58,6 +58,12 @@ main(int argc, char *argv[])
|
||||
/* Set the error value for the main thread */
|
||||
SDL_SetError("No worries");
|
||||
|
||||
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
|
||||
SDL_Log("Not running slower tests");
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
alive = 1;
|
||||
thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
|
||||
if (thread == NULL) {
|
||||
|
40
externals/SDL/test/testevdev.c
vendored
40
externals/SDL/test/testevdev.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 2020 Collabora Ltd.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
@@ -41,6 +41,7 @@ static const struct
|
||||
CLS(SOUND),
|
||||
CLS(TOUCHSCREEN),
|
||||
CLS(ACCELEROMETER),
|
||||
CLS(TOUCHPAD),
|
||||
#undef CLS
|
||||
{ 0, NULL }
|
||||
};
|
||||
@@ -185,9 +186,7 @@ static const GuessTest guess_tests[] =
|
||||
.bus_type = 0x0003,
|
||||
.vendor_id = 0x054c,
|
||||
.product_id = 0x09cc,
|
||||
/* TODO: Should this be MOUSE? That's what it most closely
|
||||
* resembles */
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
.expected = SDL_UDEV_DEVICE_TOUCHPAD,
|
||||
/* SYN, KEY, ABS */
|
||||
.ev = { 0x0b },
|
||||
/* X, Y, multitouch */
|
||||
@@ -596,7 +595,7 @@ static const GuessTest guess_tests[] =
|
||||
* to the arrow, page up and page down keys, so it's a joystick
|
||||
* with a subset of a keyboard attached. */
|
||||
/* TODO: Should this be JOYSTICK, or even JOYSTICK|KEYBOARD? */
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
.expected = SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY */
|
||||
.ev = { 0x03 },
|
||||
.keys = {
|
||||
@@ -608,7 +607,7 @@ static const GuessTest guess_tests[] =
|
||||
/* BTN_1, BTN_2, BTN_A, BTN_B, BTN_MODE */
|
||||
/* 0x100 */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x10,
|
||||
/* 0x140 */ ZEROx8,
|
||||
/* next, previous */
|
||||
/* next (keyboard page down), previous (keyboard page up) */
|
||||
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
|
||||
},
|
||||
},
|
||||
@@ -659,7 +658,7 @@ static const GuessTest guess_tests[] =
|
||||
.name = "Wiimote - Classic Controller",
|
||||
/* TODO: Should this be JOYSTICK, or maybe JOYSTICK|KEYBOARD?
|
||||
* It's unusual in the same ways as the Wiimote */
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
.expected = SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY, ABS */
|
||||
.ev = { 0x0b },
|
||||
/* Hat 1-3 */
|
||||
@@ -673,7 +672,7 @@ static const GuessTest guess_tests[] =
|
||||
/* A, B, X, Y, MODE, TL, TL2, TR, TR2 */
|
||||
/* 0x100 */ ZEROx4, 0x00, 0x13, 0xdb, 0x10,
|
||||
/* 0x140 */ ZEROx8,
|
||||
/* next, previous */
|
||||
/* next (keyboard page down), previous (keyboard page up) */
|
||||
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
|
||||
},
|
||||
},
|
||||
@@ -718,9 +717,7 @@ static const GuessTest guess_tests[] =
|
||||
.vendor_id = 0x06cb,
|
||||
.product_id = 0x0000,
|
||||
.version = 0x0000,
|
||||
/* TODO: Should this be MOUSE? That's what it most closely
|
||||
* resembles */
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
.expected = SDL_UDEV_DEVICE_TOUCHPAD,
|
||||
/* SYN, KEY, ABS */
|
||||
.ev = { 0x0b },
|
||||
/* X, Y, pressure, multitouch */
|
||||
@@ -756,7 +753,8 @@ static const GuessTest guess_tests[] =
|
||||
},
|
||||
{
|
||||
.name = "Thinkpad ACPI buttons",
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
/* SDL treats this as a keyboard because it has a power button */
|
||||
.expected = SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY, MSC, SW */
|
||||
.ev = { 0x33 },
|
||||
.keys = {
|
||||
@@ -815,7 +813,8 @@ static const GuessTest guess_tests[] =
|
||||
.vendor_id = 0x0000,
|
||||
.product_id = 0x0003,
|
||||
.version = 0x0000,
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
/* SDL treats KEY_SLEEP as indicating a keyboard */
|
||||
.expected = SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY */
|
||||
.ev = { 0x03 },
|
||||
.keys = {
|
||||
@@ -841,7 +840,8 @@ static const GuessTest guess_tests[] =
|
||||
.vendor_id = 0x0000,
|
||||
.product_id = 0x0001,
|
||||
.version = 0x0000,
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
/* SDL treats KEY_POWER as indicating a keyboard */
|
||||
.expected = SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY */
|
||||
.ev = { 0x03 },
|
||||
.keys = {
|
||||
@@ -856,7 +856,8 @@ static const GuessTest guess_tests[] =
|
||||
.vendor_id = 0x0000,
|
||||
.product_id = 0x0006,
|
||||
.version = 0x0000,
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
/* SDL treats brightness control, etc. as keyboard keys */
|
||||
.expected = SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY */
|
||||
.ev = { 0x03 },
|
||||
.keys = {
|
||||
@@ -873,7 +874,7 @@ static const GuessTest guess_tests[] =
|
||||
.vendor_id = 0x17aa,
|
||||
.product_id = 0x5054,
|
||||
.version = 0x4101,
|
||||
.expected = SDL_UDEV_DEVICE_UNKNOWN,
|
||||
.expected = SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY */
|
||||
.ev = { 0x03 },
|
||||
.keys = {
|
||||
@@ -911,9 +912,8 @@ static const GuessTest guess_tests[] =
|
||||
.product_id = 0x6009,
|
||||
/* For some reason the special keys like mute and wlan toggle
|
||||
* show up here instead of, or in addition to, as part of
|
||||
* the keyboard - so udev reports this as having keys too.
|
||||
* SDL currently doesn't. */
|
||||
.expected = SDL_UDEV_DEVICE_MOUSE,
|
||||
* the keyboard - so both udev and SDL report this as having keys too. */
|
||||
.expected = SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD,
|
||||
/* SYN, KEY, REL, MSC, LED */
|
||||
.ev = { 0x17, 0x00, 0x02 },
|
||||
/* X, Y */
|
||||
@@ -1019,7 +1019,7 @@ static int
|
||||
run_test(void)
|
||||
{
|
||||
printf("SDL compiled without evdev capability check.\n");
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
2
externals/SDL/test/testfile.c
vendored
2
externals/SDL/test/testfile.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testfilesystem.c
vendored
2
externals/SDL/test/testfilesystem.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
344
externals/SDL/test/testgamecontroller.c
vendored
344
externals/SDL/test/testgamecontroller.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
@@ -27,6 +28,10 @@
|
||||
#define SCREEN_WIDTH 512
|
||||
#define SCREEN_HEIGHT 320
|
||||
|
||||
#define BUTTON_SIZE 50
|
||||
#define AXIS_SIZE 50
|
||||
|
||||
|
||||
/* This is indexed by SDL_GameControllerButton. */
|
||||
static const struct { int x; int y; } button_positions[] = {
|
||||
{387, 167}, /* SDL_CONTROLLER_BUTTON_A */
|
||||
@@ -49,7 +54,9 @@ static const struct { int x; int y; } button_positions[] = {
|
||||
{330, 135}, /* SDL_CONTROLLER_BUTTON_PADDLE2 */
|
||||
{132, 175}, /* SDL_CONTROLLER_BUTTON_PADDLE3 */
|
||||
{330, 175}, /* SDL_CONTROLLER_BUTTON_PADDLE4 */
|
||||
{0, 0}, /* SDL_CONTROLLER_BUTTON_TOUCHPAD */
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(button_positions, SDL_arraysize(button_positions) == SDL_CONTROLLER_BUTTON_MAX);
|
||||
|
||||
/* This is indexed by SDL_GameControllerAxis. */
|
||||
static const struct { int x; int y; double angle; } axis_positions[] = {
|
||||
@@ -60,6 +67,7 @@ static const struct { int x; int y; double angle; } axis_positions[] = {
|
||||
{91, -20, 0.0}, /* TRIGGERLEFT */
|
||||
{375, -20, 0.0}, /* TRIGGERRIGHT */
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(axis_positions, SDL_arraysize(axis_positions) == SDL_CONTROLLER_AXIS_MAX);
|
||||
|
||||
static SDL_Window *window = NULL;
|
||||
static SDL_Renderer *screen = NULL;
|
||||
@@ -71,6 +79,11 @@ static SDL_Texture *background_front, *background_back, *button, *axis;
|
||||
static SDL_GameController *gamecontroller;
|
||||
static SDL_GameController **gamecontrollers;
|
||||
static int num_controllers = 0;
|
||||
static SDL_Joystick *virtual_joystick = NULL;
|
||||
static SDL_GameControllerAxis virtual_axis_active = SDL_CONTROLLER_AXIS_INVALID;
|
||||
static int virtual_axis_start_x;
|
||||
static int virtual_axis_start_y;
|
||||
static SDL_GameControllerButton virtual_button_active = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
|
||||
static void UpdateWindowTitle()
|
||||
{
|
||||
@@ -120,6 +133,7 @@ static void AddController(int device_index, SDL_bool verbose)
|
||||
SDL_JoystickID controller_id = SDL_JoystickGetDeviceInstanceID(device_index);
|
||||
SDL_GameController *controller;
|
||||
SDL_GameController **controllers;
|
||||
Uint16 firmware_version;
|
||||
|
||||
controller_id = SDL_JoystickGetDeviceInstanceID(device_index);
|
||||
if (controller_id < 0) {
|
||||
@@ -151,7 +165,15 @@ static void AddController(int device_index, SDL_bool verbose)
|
||||
|
||||
if (verbose) {
|
||||
const char *name = SDL_GameControllerName(gamecontroller);
|
||||
SDL_Log("Opened game controller %s\n", name);
|
||||
const char *path = SDL_GameControllerPath(gamecontroller);
|
||||
SDL_Log("Opened game controller %s%s%s\n", name, path ? ", " : "", path ? path : "");
|
||||
}
|
||||
|
||||
firmware_version = SDL_GameControllerGetFirmwareVersion(gamecontroller);
|
||||
if (firmware_version) {
|
||||
if (verbose) {
|
||||
SDL_Log("Firmware version: 0x%x (%d)\n", firmware_version, firmware_version);
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_GameControllerHasSensor(gamecontroller, SDL_SENSOR_ACCEL)) {
|
||||
@@ -216,34 +238,6 @@ static void DelController(SDL_JoystickID controller)
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
static SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
{
|
||||
SDL_Surface *temp = NULL;
|
||||
SDL_Texture *texture = NULL;
|
||||
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
|
||||
} else {
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
if (temp->format->BytesPerPixel == 1) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *)temp->pixels);
|
||||
}
|
||||
}
|
||||
|
||||
texture = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
}
|
||||
}
|
||||
if (temp) {
|
||||
SDL_FreeSurface(temp);
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
static Uint16 ConvertAxisToRumble(Sint16 axisval)
|
||||
{
|
||||
/* Only start rumbling if the axis is past the halfway point */
|
||||
@@ -306,12 +300,223 @@ static void CyclePS5TriggerEffect()
|
||||
SDL_GameControllerSendEffect(gamecontroller, &state, sizeof(state));
|
||||
}
|
||||
|
||||
static SDL_bool ShowingFront()
|
||||
{
|
||||
SDL_bool showing_front = SDL_TRUE;
|
||||
int i;
|
||||
|
||||
if (gamecontroller) {
|
||||
/* Show the back of the controller if the paddles are being held */
|
||||
for (i = SDL_CONTROLLER_BUTTON_PADDLE1; i <= SDL_CONTROLLER_BUTTON_PADDLE4; ++i) {
|
||||
if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) {
|
||||
showing_front = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((SDL_GetModState() & KMOD_SHIFT) != 0) {
|
||||
showing_front = SDL_FALSE;
|
||||
}
|
||||
return showing_front;
|
||||
}
|
||||
|
||||
static void SDLCALL VirtualControllerSetPlayerIndex(void *userdata, int player_index)
|
||||
{
|
||||
SDL_Log("Virtual Controller: player index set to %d\n", player_index);
|
||||
}
|
||||
|
||||
static int SDLCALL VirtualControllerRumble(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
|
||||
{
|
||||
SDL_Log("Virtual Controller: rumble set to %d/%d\n", low_frequency_rumble, high_frequency_rumble);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SDLCALL VirtualControllerRumbleTriggers(void *userdata, Uint16 left_rumble, Uint16 right_rumble)
|
||||
{
|
||||
SDL_Log("Virtual Controller: trigger rumble set to %d/%d\n", left_rumble, right_rumble);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SDLCALL VirtualControllerSetLED(void *userdata, Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
SDL_Log("Virtual Controller: LED set to RGB %d,%d,%d\n", red, green, blue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void OpenVirtualController()
|
||||
{
|
||||
SDL_VirtualJoystickDesc desc;
|
||||
int virtual_index;
|
||||
|
||||
SDL_zero(desc);
|
||||
desc.version = SDL_VIRTUAL_JOYSTICK_DESC_VERSION;
|
||||
desc.type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
|
||||
desc.naxes = SDL_CONTROLLER_AXIS_MAX;
|
||||
desc.nbuttons = SDL_CONTROLLER_BUTTON_MAX;
|
||||
desc.SetPlayerIndex = VirtualControllerSetPlayerIndex;
|
||||
desc.Rumble = VirtualControllerRumble;
|
||||
desc.RumbleTriggers = VirtualControllerRumbleTriggers;
|
||||
desc.SetLED = VirtualControllerSetLED;
|
||||
|
||||
virtual_index = SDL_JoystickAttachVirtualEx(&desc);
|
||||
if (virtual_index < 0) {
|
||||
SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError());
|
||||
} else {
|
||||
virtual_joystick = SDL_JoystickOpen(virtual_index);
|
||||
if (!virtual_joystick) {
|
||||
SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CloseVirtualController()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = SDL_NumJoysticks(); i--; ) {
|
||||
if (SDL_JoystickIsVirtual(i)) {
|
||||
SDL_JoystickDetachVirtual(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (virtual_joystick) {
|
||||
SDL_JoystickClose(virtual_joystick);
|
||||
virtual_joystick = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_GameControllerButton FindButtonAtPosition(int x, int y)
|
||||
{
|
||||
SDL_Point point;
|
||||
int i;
|
||||
SDL_bool showing_front = ShowingFront();
|
||||
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
for (i = 0; i < SDL_CONTROLLER_BUTTON_TOUCHPAD; ++i) {
|
||||
SDL_bool on_front = (i < SDL_CONTROLLER_BUTTON_PADDLE1 || i > SDL_CONTROLLER_BUTTON_PADDLE4);
|
||||
if (on_front == showing_front) {
|
||||
SDL_Rect rect;
|
||||
rect.x = button_positions[i].x;
|
||||
rect.y = button_positions[i].y;
|
||||
rect.w = BUTTON_SIZE;
|
||||
rect.h = BUTTON_SIZE;
|
||||
if (SDL_PointInRect(&point, &rect)) {
|
||||
return (SDL_GameControllerButton)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SDL_CONTROLLER_BUTTON_INVALID;
|
||||
}
|
||||
|
||||
static SDL_GameControllerAxis FindAxisAtPosition(int x, int y)
|
||||
{
|
||||
SDL_Point point;
|
||||
int i;
|
||||
SDL_bool showing_front = ShowingFront();
|
||||
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) {
|
||||
if (showing_front) {
|
||||
SDL_Rect rect;
|
||||
rect.x = axis_positions[i].x;
|
||||
rect.y = axis_positions[i].y;
|
||||
rect.w = AXIS_SIZE;
|
||||
rect.h = AXIS_SIZE;
|
||||
if (SDL_PointInRect(&point, &rect)) {
|
||||
return (SDL_GameControllerAxis)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SDL_CONTROLLER_AXIS_INVALID;
|
||||
}
|
||||
|
||||
static void VirtualControllerMouseMotion(int x, int y)
|
||||
{
|
||||
if (virtual_button_active != SDL_CONTROLLER_BUTTON_INVALID) {
|
||||
if (virtual_axis_active != SDL_CONTROLLER_AXIS_INVALID) {
|
||||
const int MOVING_DISTANCE = 2;
|
||||
if (SDL_abs(x - virtual_axis_start_x) >= MOVING_DISTANCE ||
|
||||
SDL_abs(y - virtual_axis_start_y) >= MOVING_DISTANCE) {
|
||||
SDL_JoystickSetVirtualButton(virtual_joystick, virtual_button_active, SDL_RELEASED);
|
||||
virtual_button_active = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (virtual_axis_active != SDL_CONTROLLER_AXIS_INVALID) {
|
||||
if (virtual_axis_active == SDL_CONTROLLER_AXIS_TRIGGERLEFT ||
|
||||
virtual_axis_active == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) {
|
||||
int range = (SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN);
|
||||
float distance = SDL_clamp(((float)y - virtual_axis_start_y) / AXIS_SIZE, 0.0f, 1.0f);
|
||||
Sint16 value = (Sint16)(SDL_JOYSTICK_AXIS_MIN + (distance * range));
|
||||
SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active, value);
|
||||
} else {
|
||||
float distanceX = SDL_clamp(((float)x - virtual_axis_start_x) / AXIS_SIZE, -1.0f, 1.0f);
|
||||
float distanceY = SDL_clamp(((float)y - virtual_axis_start_y) / AXIS_SIZE, -1.0f, 1.0f);
|
||||
Sint16 valueX, valueY;
|
||||
|
||||
if (distanceX >= 0) {
|
||||
valueX = (Sint16)(distanceX * SDL_JOYSTICK_AXIS_MAX);
|
||||
} else {
|
||||
valueX = (Sint16)(distanceX * -SDL_JOYSTICK_AXIS_MIN);
|
||||
}
|
||||
if (distanceY >= 0) {
|
||||
valueY = (Sint16)(distanceY * SDL_JOYSTICK_AXIS_MAX);
|
||||
} else {
|
||||
valueY = (Sint16)(distanceY * -SDL_JOYSTICK_AXIS_MIN);
|
||||
}
|
||||
SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active, valueX);
|
||||
SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active+1, valueY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void VirtualControllerMouseDown(int x, int y)
|
||||
{
|
||||
SDL_GameControllerButton button;
|
||||
SDL_GameControllerAxis axis;
|
||||
|
||||
button = FindButtonAtPosition(x, y);
|
||||
if (button != SDL_CONTROLLER_BUTTON_INVALID) {
|
||||
virtual_button_active = button;
|
||||
SDL_JoystickSetVirtualButton(virtual_joystick, virtual_button_active, SDL_PRESSED);
|
||||
}
|
||||
|
||||
axis = FindAxisAtPosition(x, y);
|
||||
if (axis != SDL_CONTROLLER_AXIS_INVALID) {
|
||||
virtual_axis_active = axis;
|
||||
virtual_axis_start_x = x;
|
||||
virtual_axis_start_y = y;
|
||||
}
|
||||
}
|
||||
|
||||
static void VirtualControllerMouseUp(int x, int y)
|
||||
{
|
||||
if (virtual_button_active != SDL_CONTROLLER_BUTTON_INVALID) {
|
||||
SDL_JoystickSetVirtualButton(virtual_joystick, virtual_button_active, SDL_RELEASED);
|
||||
virtual_button_active = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
}
|
||||
|
||||
if (virtual_axis_active != SDL_CONTROLLER_AXIS_INVALID) {
|
||||
if (virtual_axis_active == SDL_CONTROLLER_AXIS_TRIGGERLEFT ||
|
||||
virtual_axis_active == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) {
|
||||
SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active, SDL_JOYSTICK_AXIS_MIN);
|
||||
} else {
|
||||
SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active, 0);
|
||||
SDL_JoystickSetVirtualAxis(virtual_joystick, virtual_axis_active+1, 0);
|
||||
}
|
||||
virtual_axis_active = SDL_CONTROLLER_AXIS_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
loop(void *arg)
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
SDL_bool showing_front = SDL_TRUE;
|
||||
SDL_bool showing_front;
|
||||
|
||||
/* Update to get the current event state */
|
||||
SDL_PumpEvents();
|
||||
@@ -382,6 +587,24 @@ loop(void *arg)
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (virtual_joystick) {
|
||||
VirtualControllerMouseDown(event.button.x, event.button.y);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (virtual_joystick) {
|
||||
VirtualControllerMouseUp(event.button.x, event.button.y);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
if (virtual_joystick) {
|
||||
VirtualControllerMouseMotion(event.motion.x, event.motion.y);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
if (event.key.keysym.sym >= SDLK_0 && event.key.keysym.sym <= SDLK_9) {
|
||||
if (gamecontroller) {
|
||||
@@ -391,6 +614,14 @@ loop(void *arg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_a) {
|
||||
OpenVirtualController();
|
||||
break;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_d) {
|
||||
CloseVirtualController();
|
||||
break;
|
||||
}
|
||||
if (event.key.keysym.sym != SDLK_ESCAPE) {
|
||||
break;
|
||||
}
|
||||
@@ -403,15 +634,7 @@ loop(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
if (gamecontroller) {
|
||||
/* Show the back of the controller if the paddles are being held */
|
||||
for (i = SDL_CONTROLLER_BUTTON_PADDLE1; i <= SDL_CONTROLLER_BUTTON_PADDLE4; ++i) {
|
||||
if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) {
|
||||
showing_front = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
showing_front = ShowingFront();
|
||||
|
||||
/* blank screen, set up for drawing this frame. */
|
||||
SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE);
|
||||
@@ -427,8 +650,8 @@ loop(void *arg)
|
||||
SDL_Rect dst;
|
||||
dst.x = button_positions[i].x;
|
||||
dst.y = button_positions[i].y;
|
||||
dst.w = 50;
|
||||
dst.h = 50;
|
||||
dst.w = BUTTON_SIZE;
|
||||
dst.h = BUTTON_SIZE;
|
||||
SDL_RenderCopyEx(screen, button, NULL, &dst, 0, NULL, SDL_FLIP_NONE);
|
||||
}
|
||||
}
|
||||
@@ -443,16 +666,16 @@ loop(void *arg)
|
||||
SDL_Rect dst;
|
||||
dst.x = axis_positions[i].x;
|
||||
dst.y = axis_positions[i].y;
|
||||
dst.w = 50;
|
||||
dst.h = 50;
|
||||
dst.w = AXIS_SIZE;
|
||||
dst.h = AXIS_SIZE;
|
||||
SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE);
|
||||
} else if (value > deadzone) {
|
||||
const double angle = axis_positions[i].angle + 180.0;
|
||||
SDL_Rect dst;
|
||||
dst.x = axis_positions[i].x;
|
||||
dst.y = axis_positions[i].y;
|
||||
dst.w = 50;
|
||||
dst.h = 50;
|
||||
dst.w = AXIS_SIZE;
|
||||
dst.h = AXIS_SIZE;
|
||||
SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, SDL_FLIP_NONE);
|
||||
}
|
||||
}
|
||||
@@ -507,7 +730,7 @@ loop(void *arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Delay(16);
|
||||
SDL_RenderPresent(screen);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
@@ -529,6 +752,7 @@ main(int argc, char *argv[])
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ROG_CHAKRAM, "1");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
SDL_SetHint(SDL_HINT_LINUX_JOYSTICK_DEADZONES, "1");
|
||||
|
||||
@@ -559,6 +783,7 @@ main(int argc, char *argv[])
|
||||
/* Print information about the controller */
|
||||
for (i = 0; i < SDL_NumJoysticks(); ++i) {
|
||||
const char *name;
|
||||
const char *path;
|
||||
const char *description;
|
||||
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i),
|
||||
@@ -567,6 +792,7 @@ main(int argc, char *argv[])
|
||||
if (SDL_IsGameController(i)) {
|
||||
controller_count++;
|
||||
name = SDL_GameControllerNameForIndex(i);
|
||||
path = SDL_GameControllerPathForIndex(i);
|
||||
switch (SDL_GameControllerTypeForIndex(i)) {
|
||||
case SDL_CONTROLLER_TYPE_AMAZON_LUNA:
|
||||
description = "Amazon Luna Controller";
|
||||
@@ -602,10 +828,11 @@ main(int argc, char *argv[])
|
||||
AddController(i, SDL_FALSE);
|
||||
} else {
|
||||
name = SDL_JoystickNameForIndex(i);
|
||||
path = SDL_JoystickPathForIndex(i);
|
||||
description = "Joystick";
|
||||
}
|
||||
SDL_Log("%s %d: %s (guid %s, VID 0x%.4x, PID 0x%.4x, player index = %d)\n",
|
||||
description, i, name ? name : "Unknown", guid,
|
||||
SDL_Log("%s %d: %s%s%s (guid %s, VID 0x%.4x, PID 0x%.4x, player index = %d)\n",
|
||||
description, i, name ? name : "Unknown", path ? ", " : "", path ? path : "", guid,
|
||||
SDL_JoystickGetDeviceVendor(i), SDL_JoystickGetDeviceProduct(i), SDL_JoystickGetDevicePlayerIndex(i));
|
||||
}
|
||||
SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", controller_count, SDL_NumJoysticks());
|
||||
@@ -633,10 +860,10 @@ main(int argc, char *argv[])
|
||||
/* scale for platforms that don't give you the window size you asked for. */
|
||||
SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
|
||||
background_front = LoadTexture(screen, "controllermap.bmp", SDL_FALSE);
|
||||
background_back = LoadTexture(screen, "controllermap_back.bmp", SDL_FALSE);
|
||||
button = LoadTexture(screen, "button.bmp", SDL_TRUE);
|
||||
axis = LoadTexture(screen, "axis.bmp", SDL_TRUE);
|
||||
background_front = LoadTexture(screen, "controllermap.bmp", SDL_FALSE, NULL, NULL);
|
||||
background_back = LoadTexture(screen, "controllermap_back.bmp", SDL_FALSE, NULL, NULL);
|
||||
button = LoadTexture(screen, "button.bmp", SDL_TRUE, NULL, NULL);
|
||||
axis = LoadTexture(screen, "axis.bmp", SDL_TRUE, NULL, NULL);
|
||||
|
||||
if (!background_front || !background_back || !button || !axis) {
|
||||
SDL_DestroyRenderer(screen);
|
||||
@@ -649,8 +876,14 @@ main(int argc, char *argv[])
|
||||
/* !!! FIXME: */
|
||||
/*SDL_RenderSetLogicalSize(screen, background->w, background->h);*/
|
||||
|
||||
if (argv[1] && *argv[1] != '-') {
|
||||
controller_index = SDL_atoi(argv[1]);
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (SDL_strcmp(argv[i], "--virtual") == 0) {
|
||||
OpenVirtualController();
|
||||
}
|
||||
if (argv[i] && *argv[i] != '-') {
|
||||
controller_index = SDL_atoi(argv[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (controller_index < num_controllers) {
|
||||
gamecontroller = gamecontrollers[controller_index];
|
||||
@@ -674,6 +907,7 @@ main(int argc, char *argv[])
|
||||
CyclePS5TriggerEffect();
|
||||
}
|
||||
|
||||
CloseVirtualController();
|
||||
SDL_DestroyRenderer(screen);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
|
||||
|
42
externals/SDL/test/testgeometry.c
vendored
42
externals/SDL/test/testgeometry.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -21,6 +21,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL_test_common.h"
|
||||
#include "testutils.h"
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
static SDL_bool use_texture = SDL_FALSE;
|
||||
@@ -44,54 +45,19 @@ 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);
|
||||
/* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */
|
||||
sprites[i] = LoadTexture(state->renderers[i], file, SDL_TRUE, &sprite_w, &sprite_h);
|
||||
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);
|
||||
|
5
externals/SDL/test/testgesture.c
vendored
5
externals/SDL/test/testgesture.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -190,7 +190,8 @@ loop(void)
|
||||
case SDLK_i: {
|
||||
for (i = 0; i < SDL_GetNumTouchDevices(); ++i) {
|
||||
const SDL_TouchID id = SDL_GetTouchDevice(i);
|
||||
SDL_Log("Fingers Down on device %"SDL_PRIs64": %d", id, SDL_GetNumTouchFingers(id));
|
||||
const char *name = SDL_GetTouchName(i);
|
||||
SDL_Log("Fingers Down on device %"SDL_PRIs64" (%s): %d", id, name, SDL_GetNumTouchFingers(id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
2
externals/SDL/test/testgl2.c
vendored
2
externals/SDL/test/testgl2.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testgles.c
vendored
2
externals/SDL/test/testgles.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
75
externals/SDL/test/testgles2.c
vendored
75
externals/SDL/test/testgles2.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -38,6 +38,18 @@ typedef struct GLES2_Context
|
||||
#undef SDL_PROC
|
||||
} GLES2_Context;
|
||||
|
||||
typedef struct shader_data
|
||||
{
|
||||
GLuint shader_program, shader_frag, shader_vert;
|
||||
|
||||
GLint attr_position;
|
||||
GLint attr_color, attr_mvp;
|
||||
|
||||
int angle_x, angle_y, angle_z;
|
||||
|
||||
GLuint position_buffer;
|
||||
GLuint color_buffer;
|
||||
} shader_data;
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
static SDL_GLContext *context = NULL;
|
||||
@@ -197,13 +209,13 @@ multiply_matrix(float *lhs, float *rhs, float *r)
|
||||
* source: Passed-in shader source code.
|
||||
* shader_type: Passed to GL, e.g. GL_VERTEX_SHADER.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
process_shader(GLuint *shader, const char * source, GLint shader_type)
|
||||
{
|
||||
GLint status = GL_FALSE;
|
||||
const char *shaders[1] = { NULL };
|
||||
char buffer[1024];
|
||||
GLsizei length;
|
||||
GLsizei length = 0;
|
||||
|
||||
/* Create shader and load into GL. */
|
||||
*shader = GL_CHECK(ctx.glCreateShader(shader_type));
|
||||
@@ -221,13 +233,35 @@ process_shader(GLuint *shader, const char * source, GLint shader_type)
|
||||
|
||||
/* Dump debug info (source and log) if compilation failed. */
|
||||
if(status != GL_TRUE) {
|
||||
ctx.glGetProgramInfoLog(*shader, sizeof(buffer), &length, &buffer[0]);
|
||||
ctx.glGetShaderInfoLog(*shader, sizeof(buffer), &length, &buffer[0]);
|
||||
buffer[length] = '\0';
|
||||
SDL_Log("Shader compilation failed: %s", buffer);fflush(stderr);
|
||||
SDL_Log("Shader compilation failed: %s", buffer);
|
||||
fflush(stderr);
|
||||
quit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
link_program(struct shader_data *data)
|
||||
{
|
||||
GLint status = GL_FALSE;
|
||||
char buffer[1024];
|
||||
GLsizei length = 0;
|
||||
|
||||
GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_vert));
|
||||
GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_frag));
|
||||
GL_CHECK(ctx.glLinkProgram(data->shader_program));
|
||||
GL_CHECK(ctx.glGetProgramiv(data->shader_program, GL_LINK_STATUS, &status));
|
||||
|
||||
if(status != GL_TRUE) {
|
||||
ctx.glGetProgramInfoLog(data->shader_program, sizeof(buffer), &length, &buffer[0]);
|
||||
buffer[length] = '\0';
|
||||
SDL_Log("Program linking failed: %s", buffer);
|
||||
fflush(stderr);
|
||||
quit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* 3D data. Vertex range -0.5..0.5 in all axes.
|
||||
* Z -0.5 is near, 0.5 is far. */
|
||||
const float _vertices[] =
|
||||
@@ -363,17 +397,6 @@ const char* _shader_frag_src =
|
||||
" gl_FragColor = vec4(vv3color, 1.0); "
|
||||
" } ";
|
||||
|
||||
typedef struct shader_data
|
||||
{
|
||||
GLuint shader_program, shader_frag, shader_vert;
|
||||
|
||||
GLint attr_position;
|
||||
GLint attr_color, attr_mvp;
|
||||
|
||||
int angle_x, angle_y, angle_z;
|
||||
|
||||
} shader_data;
|
||||
|
||||
static void
|
||||
Render(unsigned int width, unsigned int height, shader_data* data)
|
||||
{
|
||||
@@ -431,7 +454,7 @@ void loop()
|
||||
switch (event.type) {
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (event.window.event) {
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
|
||||
int w, h;
|
||||
@@ -670,9 +693,7 @@ main(int argc, char *argv[])
|
||||
data->shader_program = GL_CHECK(ctx.glCreateProgram());
|
||||
|
||||
/* Attach shaders and link shader_program */
|
||||
GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_vert));
|
||||
GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_frag));
|
||||
GL_CHECK(ctx.glLinkProgram(data->shader_program));
|
||||
link_program(data);
|
||||
|
||||
/* Get attribute locations of non-fixed attributes like color and texture coordinates. */
|
||||
data->attr_position = GL_CHECK(ctx.glGetAttribLocation(data->shader_program, "av4position"));
|
||||
@@ -688,8 +709,18 @@ main(int argc, char *argv[])
|
||||
GL_CHECK(ctx.glEnableVertexAttribArray(data->attr_color));
|
||||
|
||||
/* Populate attributes for position, color and texture coordinates etc. */
|
||||
GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, _vertices));
|
||||
GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, _colors));
|
||||
|
||||
GL_CHECK(ctx.glGenBuffers(1, &data->position_buffer));
|
||||
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->position_buffer));
|
||||
GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(_vertices), _vertices, GL_STATIC_DRAW));
|
||||
GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, 0));
|
||||
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
|
||||
GL_CHECK(ctx.glGenBuffers(1, &data->color_buffer));
|
||||
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->color_buffer));
|
||||
GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(_colors), _colors, GL_STATIC_DRAW));
|
||||
GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, 0));
|
||||
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
|
||||
GL_CHECK(ctx.glEnable(GL_CULL_FACE));
|
||||
GL_CHECK(ctx.glEnable(GL_DEPTH_TEST));
|
||||
|
24
externals/SDL/test/testgles2_sdf.c
vendored
24
externals/SDL/test/testgles2_sdf.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -458,6 +458,7 @@ main(int argc, char *argv[])
|
||||
Uint32 then, now;
|
||||
int status;
|
||||
shader_data *data;
|
||||
char *path = NULL;
|
||||
|
||||
/* Initialize parameters */
|
||||
fsaa = 0;
|
||||
@@ -561,14 +562,25 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Load SDF BMP image */
|
||||
#if 1
|
||||
tmp = SDL_LoadBMP(f);
|
||||
if (tmp == NULL) {
|
||||
SDL_Log("missing image file: %s", f);
|
||||
path = GetNearbyFilename(f);
|
||||
|
||||
if (path == NULL)
|
||||
path = SDL_strdup(f);
|
||||
|
||||
if (path == NULL) {
|
||||
SDL_Log("out of memory\n");
|
||||
exit(-1);
|
||||
} else {
|
||||
SDL_Log("Load image file: %s", f);
|
||||
}
|
||||
|
||||
tmp = SDL_LoadBMP(path);
|
||||
if (tmp == NULL) {
|
||||
SDL_Log("missing image file: %s", path);
|
||||
exit(-1);
|
||||
} else {
|
||||
SDL_Log("Load image file: %s", path);
|
||||
}
|
||||
|
||||
SDL_free(path);
|
||||
#else
|
||||
/* Generate SDF image using SDL_ttf */
|
||||
|
||||
|
169
externals/SDL/test/testguid.c
vendored
Executable file
169
externals/SDL/test/testguid.c
vendored
Executable file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
Copyright (C) 1997-2022 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Automated tests for GUID processing
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
/* Helpers */
|
||||
|
||||
static int _error_count = 0;
|
||||
|
||||
static int
|
||||
_require_eq(Uint64 expected, Uint64 actual, int line, char *msg)
|
||||
{
|
||||
if (expected != actual) {
|
||||
_error_count += 1;
|
||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "[%s, L%d] %s: Actual %ld (0x%lx) != expected %ld (0x%lx)",
|
||||
__FILE__, line, msg, actual, actual, expected, expected);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define ASSERT_EQ(MSG, EXPECTED, ACTUAL) _require_eq((EXPECTED), (ACTUAL), __LINE__, (MSG))
|
||||
|
||||
/* Helpers */
|
||||
|
||||
#define NUM_TEST_GUIDS 5
|
||||
|
||||
static struct {
|
||||
char *str;
|
||||
Uint64 upper, lower;
|
||||
} test_guids[NUM_TEST_GUIDS] = {
|
||||
{ "0000000000000000" "ffffffffffffffff",
|
||||
0x0000000000000000, 0xfffffffffffffffflu },
|
||||
{ "0011223344556677" "8091a2b3c4d5e6f0",
|
||||
0x0011223344556677lu, 0x8091a2b3c4d5e6f0lu },
|
||||
{ "a011223344556677" "8091a2b3c4d5e6f0",
|
||||
0xa011223344556677lu, 0x8091a2b3c4d5e6f0lu },
|
||||
{ "a011223344556677" "8091a2b3c4d5e6f1",
|
||||
0xa011223344556677lu, 0x8091a2b3c4d5e6f1lu },
|
||||
{ "a011223344556677" "8191a2b3c4d5e6f0",
|
||||
0xa011223344556677lu, 0x8191a2b3c4d5e6f0lu },
|
||||
};
|
||||
|
||||
static void
|
||||
upper_lower_to_bytestring(Uint8* out, Uint64 upper, Uint64 lower)
|
||||
{
|
||||
Uint64 values[2];
|
||||
int i, k;
|
||||
|
||||
values[0] = upper;
|
||||
values [1] = lower;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
Uint64 v = values[i];
|
||||
|
||||
for (k = 0; k < 8; ++k) {
|
||||
*out++ = v >> 56;
|
||||
v <<= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ================= Test Case Implementation ================== */
|
||||
|
||||
/**
|
||||
* @brief Check String-to-GUID conversion
|
||||
*
|
||||
* @sa SDL_GUIDFromString
|
||||
*/
|
||||
static void
|
||||
TestGuidFromString(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TEST_GUIDS; ++i) {
|
||||
Uint8 expected[16];
|
||||
SDL_GUID guid;
|
||||
|
||||
upper_lower_to_bytestring(expected,
|
||||
test_guids[i].upper, test_guids[i].lower);
|
||||
|
||||
guid = SDL_GUIDFromString(test_guids[i].str);
|
||||
if (!ASSERT_EQ("GUID from string", 0, SDL_memcmp(expected, guid.data, 16))) {
|
||||
SDL_Log(" GUID was: '%s'", test_guids[i].str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check GUID-to-String conversion
|
||||
*
|
||||
* @sa SDL_GUIDToString
|
||||
*/
|
||||
static void
|
||||
TestGuidToString(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TEST_GUIDS; ++i) {
|
||||
const int guid_str_offset = 4;
|
||||
char guid_str_buf[64];
|
||||
char *guid_str = guid_str_buf + guid_str_offset;
|
||||
SDL_GUID guid;
|
||||
int size;
|
||||
|
||||
upper_lower_to_bytestring(guid.data,
|
||||
test_guids[i].upper, test_guids[i].lower);
|
||||
|
||||
/* Serialise to limited-length buffers */
|
||||
for (size = 0; size <= 36; ++size) {
|
||||
const Uint8 fill_char = size + 0xa0;
|
||||
Uint32 expected_prefix;
|
||||
Uint32 actual_prefix;
|
||||
int written_size;
|
||||
|
||||
SDL_memset(guid_str_buf, fill_char, sizeof(guid_str_buf));
|
||||
SDL_GUIDToString(guid, guid_str, size);
|
||||
|
||||
/* Check bytes before guid_str_buf */
|
||||
expected_prefix = fill_char | (fill_char << 8) | (fill_char << 16) | (fill_char << 24);
|
||||
SDL_memcpy(&actual_prefix, guid_str_buf, 4);
|
||||
if (!ASSERT_EQ("String buffer memory before output untouched: ", expected_prefix, actual_prefix)) {
|
||||
SDL_Log(" at size=%d", size);
|
||||
}
|
||||
|
||||
/* Check that we did not overwrite too much */
|
||||
written_size = 0;
|
||||
while ((guid_str[written_size] & 0xff) != fill_char && written_size < 256) {
|
||||
++written_size;
|
||||
}
|
||||
if (!ASSERT_EQ("Output length is within expected bounds", 1, written_size <= size)) {
|
||||
SDL_Log(" with length %d: wrote %d of %d permitted bytes",
|
||||
size, written_size, size);
|
||||
}
|
||||
if (size >= 33) {
|
||||
if (!ASSERT_EQ("GUID string equality", 0, SDL_strcmp(guid_str, test_guids[i].str))) {
|
||||
SDL_Log(" from string: %s", test_guids[i].str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
TestGuidFromString();
|
||||
TestGuidToString();
|
||||
|
||||
return _error_count > 0;
|
||||
}
|
2
externals/SDL/test/testhotplug.c
vendored
2
externals/SDL/test/testhotplug.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
8
externals/SDL/test/testiconv.c
vendored
8
externals/SDL/test/testiconv.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
static size_t
|
||||
widelen(char *data)
|
||||
@@ -43,7 +44,7 @@ main(int argc, char *argv[])
|
||||
"UCS-4",
|
||||
};
|
||||
|
||||
const char * fname;
|
||||
char * fname;
|
||||
char buffer[BUFSIZ];
|
||||
char *ucs4;
|
||||
char *test[2];
|
||||
@@ -54,12 +55,13 @@ main(int argc, char *argv[])
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
fname = (argc < 2) ? "utf8.txt" : argv[1];
|
||||
fname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "utf8.txt");
|
||||
file = fopen(fname, "rb");
|
||||
if (!file) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", fname);
|
||||
return (1);
|
||||
}
|
||||
SDL_free(fname);
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), file)) {
|
||||
/* Convert to UCS-4 */
|
||||
|
12
externals/SDL/test/testime.c
vendored
12
externals/SDL/test/testime.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -23,6 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL_test_common.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define DEFAULT_PTSIZE 30
|
||||
#ifdef HAVE_SDL_TTF
|
||||
@@ -108,6 +109,7 @@ static int unifont_init(const char *fontname)
|
||||
SDL_RWops *hexFile;
|
||||
const size_t unifontGlyphSize = UNIFONT_NUM_GLYPHS * sizeof(struct UnifontGlyph);
|
||||
const size_t unifontTextureSize = UNIFONT_NUM_TEXTURES * state->num_windows * sizeof(void *);
|
||||
char *filename;
|
||||
|
||||
/* Allocate memory for the glyph data so the file can be closed after initialization. */
|
||||
unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize);
|
||||
@@ -127,7 +129,13 @@ static int unifont_init(const char *fontname)
|
||||
}
|
||||
SDL_memset(unifontTexture, 0, unifontTextureSize);
|
||||
|
||||
hexFile = SDL_RWFromFile(fontname, "rb");
|
||||
filename = GetResourceFilename(NULL, fontname);
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
hexFile = SDL_RWFromFile(filename, "rb");
|
||||
SDL_free(filename);
|
||||
if (hexFile == NULL)
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname);
|
||||
|
2
externals/SDL/test/testintersections.c
vendored
2
externals/SDL/test/testintersections.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testjoystick.c
vendored
2
externals/SDL/test/testjoystick.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testkeys.c
vendored
2
externals/SDL/test/testkeys.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testloadso.c
vendored
2
externals/SDL/test/testloadso.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testlocale.c
vendored
2
externals/SDL/test/testlocale.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testlock.c
vendored
2
externals/SDL/test/testlock.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testmessage.c
vendored
2
externals/SDL/test/testmessage.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
40
externals/SDL/test/testmouse.c
vendored
40
externals/SDL/test/testmouse.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -39,6 +39,11 @@ static Line *active = NULL;
|
||||
static Line *lines = NULL;
|
||||
static int buttons = 0;
|
||||
|
||||
static SDL_bool wheel_x_active = SDL_FALSE;
|
||||
static SDL_bool wheel_y_active = SDL_FALSE;
|
||||
static float wheel_x = SCREEN_WIDTH * 0.5f;
|
||||
static float wheel_y = SCREEN_HEIGHT * 0.5f;
|
||||
|
||||
static SDL_bool done = SDL_FALSE;
|
||||
|
||||
void
|
||||
@@ -81,6 +86,25 @@ loop(void *arg)
|
||||
/* Check for events */
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEWHEEL:
|
||||
if (event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED) {
|
||||
event.wheel.preciseX *= -1.0f;
|
||||
event.wheel.preciseY *= -1.0f;
|
||||
event.wheel.x *= -1;
|
||||
event.wheel.y *= -1;
|
||||
}
|
||||
if (event.wheel.preciseX != 0.0f) {
|
||||
wheel_x_active = SDL_TRUE;
|
||||
/* "positive to the right and negative to the left" */
|
||||
wheel_x += event.wheel.preciseX * 10.0f;
|
||||
}
|
||||
if (event.wheel.preciseY != 0.0f) {
|
||||
wheel_y_active = SDL_TRUE;
|
||||
/* "positive away from the user and negative towards the user" */
|
||||
wheel_y -= event.wheel.preciseY * 10.0f;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
if (!active)
|
||||
break;
|
||||
@@ -100,6 +124,8 @@ loop(void *arg)
|
||||
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;
|
||||
case SDL_BUTTON_X1: active->r = 255; active->b = 255; buttons |= SDL_BUTTON_X1MASK; break;
|
||||
case SDL_BUTTON_X2: active->g = 255; active->b = 255; buttons |= SDL_BUTTON_X2MASK; break;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
@@ -110,6 +136,8 @@ loop(void *arg)
|
||||
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;
|
||||
case SDL_BUTTON_X1: buttons &= ~SDL_BUTTON_X1MASK; break;
|
||||
case SDL_BUTTON_X2: buttons &= ~SDL_BUTTON_X2MASK; break;
|
||||
}
|
||||
|
||||
if (buttons == 0) {
|
||||
@@ -130,6 +158,16 @@ loop(void *arg)
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
/* Mouse wheel */
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 128, 255);
|
||||
if (wheel_x_active) {
|
||||
SDL_RenderDrawLine(renderer, wheel_x, 0, wheel_x, SCREEN_HEIGHT);
|
||||
}
|
||||
if (wheel_y_active) {
|
||||
SDL_RenderDrawLine(renderer, 0, wheel_y, SCREEN_WIDTH, wheel_y);
|
||||
}
|
||||
|
||||
/* Lines from mouse clicks */
|
||||
DrawLines(renderer);
|
||||
if (active)
|
||||
DrawLine(renderer, active);
|
||||
|
8
externals/SDL/test/testmultiaudio.c
vendored
8
externals/SDL/test/testmultiaudio.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -17,6 +17,8 @@
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
static SDL_AudioSpec spec;
|
||||
static Uint8 *sound = NULL; /* Pointer to wave data */
|
||||
static Uint32 soundlen = 0; /* Length of wave data */
|
||||
@@ -180,7 +182,7 @@ main(int argc, char **argv)
|
||||
if (devcount < 1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
|
||||
} else {
|
||||
const char *file = (argc < 2) ? "sample.wav" : argv[1];
|
||||
char *file = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(file, &spec, &sound, &soundlen) == NULL) {
|
||||
@@ -190,6 +192,8 @@ main(int argc, char **argv)
|
||||
test_multi_audio(devcount);
|
||||
SDL_FreeWAV(sound);
|
||||
}
|
||||
|
||||
SDL_free(file);
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
|
36
externals/SDL/test/testnative.c
vendored
36
externals/SDL/test/testnative.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <time.h> /* for time() */
|
||||
|
||||
#include "testnative.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define WINDOW_W 640
|
||||
#define WINDOW_H 480
|
||||
@@ -52,37 +53,6 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
SDL_Texture *
|
||||
LoadSprite(SDL_Renderer *renderer, const char *file)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *sprite;
|
||||
|
||||
/* Load the sprite image */
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, 1, *(Uint8 *) temp->pixels);
|
||||
}
|
||||
|
||||
/* Create textures from the image */
|
||||
sprite = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!sprite) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
return 0;
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return sprite;
|
||||
}
|
||||
|
||||
void
|
||||
MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite)
|
||||
{
|
||||
@@ -180,7 +150,7 @@ main(int argc, char *argv[])
|
||||
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
sprite = LoadSprite(renderer, "icon.bmp");
|
||||
sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, NULL, NULL);
|
||||
if (!sprite) {
|
||||
quit(6);
|
||||
}
|
||||
|
2
externals/SDL/test/testnative.h
vendored
2
externals/SDL/test/testnative.h
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testnativeos2.c
vendored
2
externals/SDL/test/testnativeos2.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testnativew32.c
vendored
2
externals/SDL/test/testnativew32.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testnativex11.c
vendored
2
externals/SDL/test/testnativex11.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testoffscreen.c
vendored
2
externals/SDL/test/testoffscreen.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
12
externals/SDL/test/testoverlay2.c
vendored
12
externals/SDL/test/testoverlay2.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "SDL.h"
|
||||
|
||||
#include "testyuv_cvt.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define MOOSEPIC_W 64
|
||||
#define MOOSEPIC_H 88
|
||||
@@ -243,6 +244,7 @@ main(int argc, char **argv)
|
||||
int fps = 12;
|
||||
int nodelay = 0;
|
||||
int scale = 5;
|
||||
char *filename = NULL;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -315,7 +317,13 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* load the trojan moose images */
|
||||
handle = SDL_RWFromFile("moose.dat", "rb");
|
||||
filename = GetResourceFilename(NULL, "moose.dat");
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
handle = SDL_RWFromFile(filename, "rb");
|
||||
SDL_free(filename);
|
||||
if (handle == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
|
||||
SDL_free(RawMooseData);
|
||||
|
65
externals/SDL/test/testplatform.c
vendored
65
externals/SDL/test/testplatform.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -25,31 +25,31 @@ badsize(size_t sizeoftype, size_t hardcodetype)
|
||||
return sizeoftype != hardcodetype;
|
||||
}
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT8, SDL_MAX_SINT8 == 127);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT8, SDL_MIN_SINT8 == -128);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT8, SDL_MAX_UINT8 == 255);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT8, SDL_MIN_UINT8 == 0);
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT16, SDL_MAX_SINT16 == 32767);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT16, SDL_MIN_SINT16 == -32768);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT16, SDL_MAX_UINT16 == 65535);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT16, SDL_MIN_UINT16 == 0);
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT32, SDL_MAX_SINT32 == 2147483647);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT32, SDL_MIN_SINT32 == ~0x7fffffff); /* Instead of -2147483648, which is treated as unsigned by some compilers */
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT32, SDL_MAX_UINT32 == 4294967295u);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT32, SDL_MIN_UINT32 == 0);
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT64, SDL_MAX_SINT64 == 9223372036854775807ll);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT64, SDL_MIN_SINT64 == ~0x7fffffffffffffffll); /* Instead of -9223372036854775808, which is treated as unsigned by compilers */
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT64, SDL_MAX_UINT64 == 18446744073709551615ull);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT64, SDL_MIN_UINT64 == 0);
|
||||
|
||||
int
|
||||
TestTypes(SDL_bool verbose)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT8, SDL_MAX_SINT8 == 127);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT8, SDL_MIN_SINT8 == -128);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT8, SDL_MAX_UINT8 == 255);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT8, SDL_MIN_UINT8 == 0);
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT16, SDL_MAX_SINT16 == 32767);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT16, SDL_MIN_SINT16 == -32768);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT16, SDL_MAX_UINT16 == 65535);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT16, SDL_MIN_UINT16 == 0);
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT32, SDL_MAX_SINT32 == 2147483647);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT32, SDL_MIN_SINT32 == ~0x7fffffff); /* Instead of -2147483648, which is treated as unsigned by some compilers */
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT32, SDL_MAX_UINT32 == 4294967295u);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT32, SDL_MIN_UINT32 == 0);
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_SINT64, SDL_MAX_SINT64 == 9223372036854775807ll);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_SINT64, SDL_MIN_SINT64 == ~0x7fffffffffffffffll); /* Instead of -9223372036854775808, which is treated as unsigned by compilers */
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MAX_UINT64, SDL_MAX_UINT64 == 18446744073709551615ull);
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_MIN_UINT64, SDL_MIN_UINT64 == 0);
|
||||
|
||||
if (badsize(sizeof(Uint8), 1)) {
|
||||
if (verbose)
|
||||
SDL_Log("sizeof(Uint8) != 1, instead = %u\n",
|
||||
@@ -86,18 +86,25 @@ TestEndian(SDL_bool verbose)
|
||||
int error = 0;
|
||||
Uint16 value = 0x1234;
|
||||
int real_byteorder;
|
||||
int real_floatwordorder = 0;
|
||||
Uint16 value16 = 0xCDAB;
|
||||
Uint16 swapped16 = 0xABCD;
|
||||
Uint32 value32 = 0xEFBEADDE;
|
||||
Uint32 swapped32 = 0xDEADBEEF;
|
||||
Uint64 value64, swapped64;
|
||||
|
||||
union {
|
||||
double d;
|
||||
Uint32 ui32[2];
|
||||
} value_double;
|
||||
|
||||
value64 = 0xEFBEADDE;
|
||||
value64 <<= 32;
|
||||
value64 |= 0xCDAB3412;
|
||||
swapped64 = 0x1234ABCD;
|
||||
swapped64 <<= 32;
|
||||
swapped64 |= 0xDEADBEEF;
|
||||
value_double.d = 3.141593;
|
||||
|
||||
if (verbose) {
|
||||
SDL_Log("Detected a %s endian machine.\n",
|
||||
@@ -115,6 +122,22 @@ TestEndian(SDL_bool verbose)
|
||||
}
|
||||
++error;
|
||||
}
|
||||
if (verbose) {
|
||||
SDL_Log("Detected a %s endian float word order machine.\n",
|
||||
(SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big");
|
||||
}
|
||||
if (value_double.ui32[0] == 0x82c2bd7f && value_double.ui32[1] == 0x400921fb) {
|
||||
real_floatwordorder = SDL_LIL_ENDIAN;
|
||||
} else if (value_double.ui32[0] == 0x400921fb && value_double.ui32[1] == 0x82c2bd7f) {
|
||||
real_floatwordorder = SDL_BIG_ENDIAN;
|
||||
}
|
||||
if (real_floatwordorder != SDL_FLOATWORDORDER) {
|
||||
if (verbose) {
|
||||
SDL_Log("Actually a %s endian float word order machine!\n",
|
||||
(real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" : "unknown" );
|
||||
}
|
||||
++error;
|
||||
}
|
||||
if (verbose) {
|
||||
SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16,
|
||||
SDL_Swap16(value16));
|
||||
|
2
externals/SDL/test/testpower.c
vendored
2
externals/SDL/test/testpower.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
4
externals/SDL/test/testqsort.c
vendored
4
externals/SDL/test/testqsort.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "SDL_test.h"
|
||||
|
||||
static int
|
||||
static int SDLCALL
|
||||
num_compare(const void *_a, const void *_b)
|
||||
{
|
||||
const int a = *((const int *) _a);
|
||||
|
2
externals/SDL/test/testrelative.c
vendored
2
externals/SDL/test/testrelative.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
58
externals/SDL/test/testrendercopyex.c
vendored
58
externals/SDL/test/testrendercopyex.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -20,7 +20,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL_test_common.h"
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
@@ -44,56 +44,6 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *texture;
|
||||
|
||||
/* Load the sprite image */
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels);
|
||||
} else {
|
||||
switch (temp->format->BitsPerPixel) {
|
||||
case 15:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *) temp->pixels) & 0x00007FFF);
|
||||
break;
|
||||
case 16:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels);
|
||||
break;
|
||||
case 24:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
break;
|
||||
case 32:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create textures from the image */
|
||||
texture = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
return NULL;
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return texture;
|
||||
}
|
||||
|
||||
void
|
||||
Draw(DrawState *s)
|
||||
{
|
||||
@@ -186,8 +136,8 @@ main(int argc, char *argv[])
|
||||
|
||||
drawstate->window = state->windows[i];
|
||||
drawstate->renderer = state->renderers[i];
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE);
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE);
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE, NULL, NULL);
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE, NULL, NULL);
|
||||
if (!drawstate->sprite || !drawstate->background) {
|
||||
quit(2);
|
||||
}
|
||||
|
60
externals/SDL/test/testrendertarget.c
vendored
60
externals/SDL/test/testrendertarget.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -20,7 +20,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL_test_common.h"
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
@@ -45,56 +45,6 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *texture;
|
||||
|
||||
/* Load the sprite image */
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels);
|
||||
} else {
|
||||
switch (temp->format->BitsPerPixel) {
|
||||
case 15:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *) temp->pixels) & 0x00007FFF);
|
||||
break;
|
||||
case 16:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels);
|
||||
break;
|
||||
case 24:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
break;
|
||||
case 32:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create textures from the image */
|
||||
texture = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
return NULL;
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return texture;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
DrawComposite(DrawState *s)
|
||||
{
|
||||
@@ -292,11 +242,11 @@ main(int argc, char *argv[])
|
||||
drawstate->window = state->windows[i];
|
||||
drawstate->renderer = state->renderers[i];
|
||||
if (test_composite) {
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon-alpha.bmp", SDL_TRUE);
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon-alpha.bmp", SDL_TRUE, NULL, NULL);
|
||||
} else {
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE);
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE, NULL, NULL);
|
||||
}
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE);
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE, NULL, NULL);
|
||||
if (!drawstate->sprite || !drawstate->background) {
|
||||
quit(2);
|
||||
}
|
||||
|
2
externals/SDL/test/testresample.c
vendored
2
externals/SDL/test/testresample.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testrumble.c
vendored
2
externals/SDL/test/testrumble.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
57
externals/SDL/test/testscale.c
vendored
57
externals/SDL/test/testscale.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL_test_common.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define WINDOW_WIDTH 640
|
||||
#define WINDOW_HEIGHT 480
|
||||
@@ -46,56 +47,6 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
SDL_Texture *texture;
|
||||
|
||||
/* Load the sprite image */
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels);
|
||||
} else {
|
||||
switch (temp->format->BitsPerPixel) {
|
||||
case 15:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *) temp->pixels) & 0x00007FFF);
|
||||
break;
|
||||
case 16:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels);
|
||||
break;
|
||||
case 24:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
break;
|
||||
case 32:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create textures from the image */
|
||||
texture = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
return NULL;
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return texture;
|
||||
}
|
||||
|
||||
void
|
||||
Draw(DrawState *s)
|
||||
{
|
||||
@@ -176,8 +127,8 @@ main(int argc, char *argv[])
|
||||
|
||||
drawstate->window = state->windows[i];
|
||||
drawstate->renderer = state->renderers[i];
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE);
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE);
|
||||
drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE, NULL, NULL);
|
||||
drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE, NULL, NULL);
|
||||
if (!drawstate->sprite || !drawstate->background) {
|
||||
quit(2);
|
||||
}
|
||||
|
2
externals/SDL/test/testsem.c
vendored
2
externals/SDL/test/testsem.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testsensor.c
vendored
2
externals/SDL/test/testsensor.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
51
externals/SDL/test/testshader.c
vendored
51
externals/SDL/test/testshader.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -126,21 +126,52 @@ static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
|
||||
|
||||
static SDL_bool CompileShader(GLhandleARB shader, const char *source)
|
||||
{
|
||||
GLint status;
|
||||
GLint status = 0;
|
||||
|
||||
glShaderSourceARB(shader, 1, &source, NULL);
|
||||
glCompileShaderARB(shader);
|
||||
glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
|
||||
if (status == 0) {
|
||||
GLint length;
|
||||
GLint length = 0;
|
||||
char *info;
|
||||
|
||||
glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = SDL_stack_alloc(char, length+1);
|
||||
glGetInfoLogARB(shader, length, NULL, info);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
|
||||
SDL_stack_free(info);
|
||||
info = (char *) SDL_malloc(length + 1);
|
||||
if (!info) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
|
||||
} else {
|
||||
glGetInfoLogARB(shader, length, NULL, info);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
|
||||
SDL_free(info);
|
||||
}
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool LinkProgram(ShaderData *data)
|
||||
{
|
||||
GLint status = 0;
|
||||
|
||||
glAttachObjectARB(data->program, data->vert_shader);
|
||||
glAttachObjectARB(data->program, data->frag_shader);
|
||||
glLinkProgramARB(data->program);
|
||||
|
||||
glGetObjectParameterivARB(data->program, GL_OBJECT_LINK_STATUS_ARB, &status);
|
||||
if (status == 0) {
|
||||
GLint length = 0;
|
||||
char *info;
|
||||
|
||||
glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = (char *) SDL_malloc(length + 1);
|
||||
if (!info) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
|
||||
} else {
|
||||
glGetInfoLogARB(data->program, length, NULL, info);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to link program:\n%s", info);
|
||||
SDL_free(info);
|
||||
}
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
@@ -171,9 +202,9 @@ static SDL_bool CompileShaderProgram(ShaderData *data)
|
||||
}
|
||||
|
||||
/* ... and in the darkness bind them */
|
||||
glAttachObjectARB(data->program, data->vert_shader);
|
||||
glAttachObjectARB(data->program, data->frag_shader);
|
||||
glLinkProgramARB(data->program);
|
||||
if (!LinkProgram(data)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Set up some uniform variables */
|
||||
glUseProgramObjectARB(data->program);
|
||||
|
2
externals/SDL/test/testshape.c
vendored
2
externals/SDL/test/testshape.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
42
externals/SDL/test/testsprite2.c
vendored
42
externals/SDL/test/testsprite2.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "SDL_test.h"
|
||||
#include "SDL_test_common.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define NUM_SPRITES 100
|
||||
#define MAX_SPEED 1
|
||||
@@ -62,54 +63,19 @@ 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);
|
||||
/* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */
|
||||
sprites[i] = LoadTexture(state->renderers[i], file, SDL_TRUE, &sprite_w, &sprite_h);
|
||||
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);
|
||||
|
56
externals/SDL/test/testspriteminimal.c
vendored
56
externals/SDL/test/testspriteminimal.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define WINDOW_WIDTH 640
|
||||
#define WINDOW_HEIGHT 480
|
||||
@@ -42,55 +43,6 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
int
|
||||
LoadSprite(const char *file)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
|
||||
/* Load the sprite image */
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError());
|
||||
return (-1);
|
||||
}
|
||||
sprite_w = temp->w;
|
||||
sprite_h = temp->h;
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels);
|
||||
} else {
|
||||
switch (temp->format->BitsPerPixel) {
|
||||
case 15:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *) temp->pixels) & 0x00007FFF);
|
||||
break;
|
||||
case 16:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels);
|
||||
break;
|
||||
case 24:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
break;
|
||||
case 32:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create textures from the image */
|
||||
sprite = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!sprite) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
return (-1);
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
MoveSprites()
|
||||
{
|
||||
@@ -158,7 +110,9 @@ main(int argc, char *argv[])
|
||||
quit(2);
|
||||
}
|
||||
|
||||
if (LoadSprite("icon.bmp") < 0) {
|
||||
sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h);
|
||||
|
||||
if (sprite == NULL) {
|
||||
quit(2);
|
||||
}
|
||||
|
||||
|
12
externals/SDL/test/teststreaming.c
vendored
12
externals/SDL/test/teststreaming.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -23,6 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "testutils.h"
|
||||
|
||||
#define MOOSEPIC_W 64
|
||||
#define MOOSEPIC_H 88
|
||||
@@ -128,6 +129,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
SDL_Window *window;
|
||||
SDL_RWops *handle;
|
||||
char *filename = NULL;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -138,7 +140,13 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* load the moose images */
|
||||
handle = SDL_RWFromFile("moose.dat", "rb");
|
||||
filename = GetResourceFilename(NULL, "moose.dat");
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
handle = SDL_RWFromFile(filename, "rb");
|
||||
SDL_free(filename);
|
||||
if (handle == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
|
||||
quit(2);
|
||||
|
9
externals/SDL/test/testsurround.c
vendored
9
externals/SDL/test/testsurround.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -19,6 +19,7 @@ static int total_channels;
|
||||
static int active_channel;
|
||||
|
||||
#define SAMPLE_RATE_HZ 48000
|
||||
#define QUICK_TEST_TIME_MSEC 100
|
||||
#define CHANNEL_TEST_TIME_SEC 5
|
||||
#define MAX_AMPLITUDE SDL_MAX_SINT16
|
||||
|
||||
@@ -188,7 +189,11 @@ main(int argc, char *argv[])
|
||||
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);
|
||||
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
|
||||
SDL_Delay(QUICK_TEST_TIME_MSEC);
|
||||
} else {
|
||||
SDL_Delay(CHANNEL_TEST_TIME_SEC * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_CloseAudioDevice(dev);
|
||||
|
8
externals/SDL/test/testthread.c
vendored
8
externals/SDL/test/testthread.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -91,6 +91,12 @@ main(int argc, char *argv[])
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
|
||||
SDL_Log("Not running slower tests");
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (argv[arg] && *argv[arg] == '-') {
|
||||
if (SDL_strcmp(argv[arg], "--prio") == 0) {
|
||||
testprio = 1;
|
||||
|
8
externals/SDL/test/testtimer.c
vendored
8
externals/SDL/test/testtimer.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -54,6 +54,12 @@ main(int argc, char *argv[])
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
|
||||
SDL_Log("Not running slower tests");
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Verify SDL_GetTicks* acts monotonically increasing, and not erratic. */
|
||||
SDL_Log("Sanity-checking GetTicks\n");
|
||||
for (i = 0; i < 1000; ++i) {
|
||||
|
2
externals/SDL/test/testurl.c
vendored
2
externals/SDL/test/testurl.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
153
externals/SDL/test/testutils.c
vendored
Executable file
153
externals/SDL/test/testutils.c
vendored
Executable file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
Copyright 1997-2022 Sam Lantinga
|
||||
Copyright 2022 Collabora Ltd.
|
||||
SPDX-License-Identifier: Zlib
|
||||
*/
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
/*
|
||||
* Return the absolute path to def in the SDL_GetBasePath() if possible, or
|
||||
* the relative path to def on platforms that don't have a working
|
||||
* SDL_GetBasePath(). Free the result with SDL_free.
|
||||
*
|
||||
* Fails and returns NULL if out of memory.
|
||||
*/
|
||||
char *
|
||||
GetNearbyFilename(const char *file)
|
||||
{
|
||||
char *base;
|
||||
char *path;
|
||||
|
||||
base = SDL_GetBasePath();
|
||||
|
||||
if (base != NULL) {
|
||||
SDL_RWops *rw;
|
||||
size_t len = SDL_strlen(base) + SDL_strlen(file) + 1;
|
||||
|
||||
path = SDL_malloc(len);
|
||||
|
||||
if (path == NULL) {
|
||||
SDL_free(base);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_snprintf(path, len, "%s%s", base, file);
|
||||
SDL_free(base);
|
||||
|
||||
rw = SDL_RWFromFile(path, "rb");
|
||||
if (rw) {
|
||||
SDL_RWclose(rw);
|
||||
return path;
|
||||
}
|
||||
|
||||
/* Couldn't find the file in the base path */
|
||||
SDL_free(path);
|
||||
}
|
||||
|
||||
path = SDL_strdup(file);
|
||||
if (path == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* If user_specified is non-NULL, return a copy of it. Free with SDL_free.
|
||||
*
|
||||
* Otherwise, return the absolute path to def in the SDL_GetBasePath() if
|
||||
* possible, or the relative path to def on platforms that don't have a
|
||||
* working SDL_GetBasePath(). Free the result with SDL_free.
|
||||
*
|
||||
* Fails and returns NULL if out of memory.
|
||||
*/
|
||||
char *
|
||||
GetResourceFilename(const char *user_specified, const char *def)
|
||||
{
|
||||
if (user_specified != NULL) {
|
||||
char *ret = SDL_strdup(user_specified);
|
||||
|
||||
if (ret == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
return GetNearbyFilename(def);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the .bmp file whose name is file, from the SDL_GetBasePath() if
|
||||
* possible or the current working directory if not.
|
||||
*
|
||||
* If transparent is true, set the transparent colour from the top left pixel.
|
||||
*
|
||||
* If width_out is non-NULL, set it to the texture width.
|
||||
*
|
||||
* If height_out is non-NULL, set it to the texture height.
|
||||
*/
|
||||
SDL_Texture *
|
||||
LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent,
|
||||
int *width_out, int *height_out)
|
||||
{
|
||||
SDL_Surface *temp = NULL;
|
||||
SDL_Texture *texture = NULL;
|
||||
char *path;
|
||||
|
||||
path = GetNearbyFilename(file);
|
||||
|
||||
if (path != NULL) {
|
||||
file = path;
|
||||
}
|
||||
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
|
||||
} else {
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (transparent) {
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *)temp->pixels);
|
||||
} else {
|
||||
switch (temp->format->BitsPerPixel) {
|
||||
case 15:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *) temp->pixels) & 0x00007FFF);
|
||||
break;
|
||||
case 16:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels);
|
||||
break;
|
||||
case 24:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
break;
|
||||
case 32:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (width_out != NULL) {
|
||||
*width_out = temp->w;
|
||||
}
|
||||
|
||||
if (height_out != NULL) {
|
||||
*height_out = temp->h;
|
||||
}
|
||||
|
||||
texture = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
}
|
||||
}
|
||||
if (temp) {
|
||||
SDL_FreeSurface(temp);
|
||||
}
|
||||
if (path) {
|
||||
SDL_free(path);
|
||||
}
|
||||
return texture;
|
||||
}
|
17
externals/SDL/test/testutils.h
vendored
Executable file
17
externals/SDL/test/testutils.h
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright 1997-2022 Sam Lantinga
|
||||
Copyright 2022 Collabora Ltd.
|
||||
SPDX-License-Identifier: Zlib
|
||||
*/
|
||||
|
||||
#ifndef TESTUTILS_H
|
||||
#define TESTUTILS_H
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent,
|
||||
int *width_out, int *height_out);
|
||||
char *GetNearbyFilename(const char *file);
|
||||
char *GetResourceFilename(const char *user_specified, const char *def);
|
||||
|
||||
#endif
|
2
externals/SDL/test/testver.c
vendored
2
externals/SDL/test/testver.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
57
externals/SDL/test/testviewport.c
vendored
57
externals/SDL/test/testviewport.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "SDL_test.h"
|
||||
#include "SDL_test_common.h"
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
@@ -42,55 +42,6 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
int
|
||||
LoadSprite(const char *file, SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
|
||||
/* Load the sprite image */
|
||||
temp = SDL_LoadBMP(file);
|
||||
if (temp == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError());
|
||||
return (-1);
|
||||
}
|
||||
sprite_w = temp->w;
|
||||
sprite_h = temp->h;
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels);
|
||||
} else {
|
||||
switch (temp->format->BitsPerPixel) {
|
||||
case 15:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *) temp->pixels) & 0x00007FFF);
|
||||
break;
|
||||
case 16:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels);
|
||||
break;
|
||||
case 24:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
break;
|
||||
case 32:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create textures from the image */
|
||||
sprite = SDL_CreateTextureFromSurface(renderer, temp);
|
||||
if (!sprite) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
|
||||
SDL_FreeSurface(temp);
|
||||
return (-1);
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
DrawOnViewport(SDL_Renderer * renderer)
|
||||
{
|
||||
@@ -229,7 +180,9 @@ main(int argc, char *argv[])
|
||||
quit(2);
|
||||
}
|
||||
|
||||
if (LoadSprite("icon.bmp", state->renderers[0]) < 0) {
|
||||
sprite = LoadTexture(state->renderers[0], "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h);
|
||||
|
||||
if (sprite == NULL) {
|
||||
quit(2);
|
||||
}
|
||||
|
||||
|
2
externals/SDL/test/testvulkan.c
vendored
2
externals/SDL/test/testvulkan.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testwm2.c
vendored
2
externals/SDL/test/testwm2.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testyuv.c
vendored
2
externals/SDL/test/testyuv.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testyuv_cvt.c
vendored
2
externals/SDL/test/testyuv_cvt.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/testyuv_cvt.h
vendored
2
externals/SDL/test/testyuv_cvt.h
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
2
externals/SDL/test/torturethread.c
vendored
2
externals/SDL/test/torturethread.c
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
|
||||
|
162
externals/SDL/test/versioning.sh
vendored
Executable file
162
externals/SDL/test/versioning.sh
vendored
Executable file
@@ -0,0 +1,162 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2022 Collabora Ltd.
|
||||
# SPDX-License-Identifier: Zlib
|
||||
|
||||
set -eu
|
||||
|
||||
ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
|
||||
ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
|
||||
ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
|
||||
ref_version="${ref_major}.${ref_minor}.${ref_micro}"
|
||||
|
||||
tests=0
|
||||
failed=0
|
||||
|
||||
ok () {
|
||||
tests=$(( tests + 1 ))
|
||||
echo "ok - $*"
|
||||
}
|
||||
|
||||
not_ok () {
|
||||
tests=$(( tests + 1 ))
|
||||
echo "not ok - $*"
|
||||
failed=1
|
||||
}
|
||||
|
||||
major=$(sed -ne 's/^SDL_MAJOR_VERSION=//p' configure.ac)
|
||||
minor=$(sed -ne 's/^SDL_MINOR_VERSION=//p' configure.ac)
|
||||
micro=$(sed -ne 's/^SDL_MICRO_VERSION=//p' configure.ac)
|
||||
version="${major}.${minor}.${micro}"
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "configure.ac $version"
|
||||
else
|
||||
not_ok "configure.ac $version disagrees with SDL_version.h $ref_version"
|
||||
fi
|
||||
|
||||
major=$(sed -ne 's/^set(SDL_MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
|
||||
minor=$(sed -ne 's/^set(SDL_MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
|
||||
micro=$(sed -ne 's/^set(SDL_MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
|
||||
version="${major}.${minor}.${micro}"
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "CMakeLists.txt $version"
|
||||
else
|
||||
not_ok "CMakeLists.txt $version disagrees with SDL_version.h $ref_version"
|
||||
fi
|
||||
|
||||
major=$(sed -ne 's/^MAJOR_VERSION *= *//p' Makefile.os2)
|
||||
minor=$(sed -ne 's/^MINOR_VERSION *= *//p' Makefile.os2)
|
||||
micro=$(sed -ne 's/^MICRO_VERSION *= *//p' Makefile.os2)
|
||||
version="${major}.${minor}.${micro}"
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "Makefile.os2 $version"
|
||||
else
|
||||
not_ok "Makefile.os2 $version disagrees with SDL_version.h $ref_version"
|
||||
fi
|
||||
|
||||
major=$(sed -ne 's/^MAJOR_VERSION *= *//p' Makefile.w32)
|
||||
minor=$(sed -ne 's/^MINOR_VERSION *= *//p' Makefile.w32)
|
||||
micro=$(sed -ne 's/^MICRO_VERSION *= *//p' Makefile.w32)
|
||||
version="${major}.${minor}.${micro}"
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "Makefile.w32 $version"
|
||||
else
|
||||
not_ok "Makefile.w32 $version disagrees with SDL_version.h $ref_version"
|
||||
fi
|
||||
|
||||
version=$(sed -Ene 's/^[$]SDLVersion = "([0-9.]*)"\r?$/\1/p' build-scripts/winrtbuild.ps1)
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "winrtbuild.ps1 $version"
|
||||
else
|
||||
not_ok "winrtbuild.ps1 $version disagrees with SDL_version.h $ref_version"
|
||||
fi
|
||||
|
||||
tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/main/windows/version.rc | tr -d '\r')
|
||||
ref_tuple="${ref_major},${ref_minor},${ref_micro},0"
|
||||
|
||||
if [ "$ref_tuple" = "$tuple" ]; then
|
||||
ok "version.rc FILEVERSION $tuple"
|
||||
else
|
||||
not_ok "version.rc FILEVERSION $tuple disagrees with SDL_version.h $ref_tuple"
|
||||
fi
|
||||
|
||||
tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/main/windows/version.rc | tr -d '\r')
|
||||
|
||||
if [ "$ref_tuple" = "$tuple" ]; then
|
||||
ok "version.rc PRODUCTVERSION $tuple"
|
||||
else
|
||||
not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL_version.h $ref_tuple"
|
||||
fi
|
||||
|
||||
tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/main/windows/version.rc | tr -d '\r')
|
||||
ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0"
|
||||
|
||||
if [ "$ref_tuple" = "$tuple" ]; then
|
||||
ok "version.rc FileVersion $tuple"
|
||||
else
|
||||
not_ok "version.rc FileVersion $tuple disagrees with SDL_version.h $ref_tuple"
|
||||
fi
|
||||
|
||||
tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/main/windows/version.rc | tr -d '\r')
|
||||
|
||||
if [ "$ref_tuple" = "$tuple" ]; then
|
||||
ok "version.rc ProductVersion $tuple"
|
||||
else
|
||||
not_ok "version.rc ProductVersion $tuple disagrees with SDL_version.h $ref_tuple"
|
||||
fi
|
||||
|
||||
version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "Info-Framework.plist CFBundleShortVersionString $version"
|
||||
else
|
||||
not_ok "Info-Framework.plist CFBundleShortVersionString $version disagrees with SDL_version.h $ref_version"
|
||||
fi
|
||||
|
||||
version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "Info-Framework.plist CFBundleVersion $version"
|
||||
else
|
||||
not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version"
|
||||
fi
|
||||
|
||||
# For simplicity this assumes we'll never break ABI before SDL 3.
|
||||
dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
|
||||
ref='1.0.0
|
||||
1.0.0'
|
||||
|
||||
if [ "$ref" = "$dylib_compat" ]; then
|
||||
ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is consistent"
|
||||
else
|
||||
not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent"
|
||||
fi
|
||||
|
||||
dylib_cur=$(sed -Ene 's/.*DYLIB_CURRENT_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
|
||||
|
||||
case "$ref_minor" in
|
||||
(*[02468])
|
||||
major="$(( ref_minor * 100 + 1 ))"
|
||||
minor="$ref_micro"
|
||||
;;
|
||||
(*)
|
||||
major="$(( ref_minor * 100 + ref_micro + 1 ))"
|
||||
minor="0"
|
||||
;;
|
||||
esac
|
||||
|
||||
ref="${major}.${minor}.0
|
||||
${major}.${minor}.0"
|
||||
|
||||
if [ "$ref" = "$dylib_cur" ]; then
|
||||
ok "project.pbxproj DYLIB_CURRENT_VERSION is consistent"
|
||||
else
|
||||
not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent"
|
||||
fi
|
||||
|
||||
echo "1..$tests"
|
||||
exit "$failed"
|
116
externals/SDL/test/watcom.mif
vendored
Executable file
116
externals/SDL/test/watcom.mif
vendored
Executable file
@@ -0,0 +1,116 @@
|
||||
INCPATH+= -I"../include"
|
||||
LIBPATH = ..
|
||||
LIBS = SDL2.lib SDL2test.lib testutils.lib
|
||||
|
||||
#CFLAGS+= -DHAVE_SDL_TTF
|
||||
#TTFLIBS = SDL2ttf.lib
|
||||
|
||||
CFLAGS+= $(INCPATH)
|
||||
|
||||
TARGETS = testatomic.exe testdisplayinfo.exe testbounds.exe testdraw2.exe &
|
||||
testdrawchessboard.exe testdropfile.exe testerror.exe testfile.exe &
|
||||
testfilesystem.exe testgamecontroller.exe testgeometry.exe testgesture.exe &
|
||||
testhittesting.exe testhotplug.exe testiconv.exe testime.exe testlocale.exe &
|
||||
testguid.exe testintersections.exe testjoystick.exe testkeys.exe testloadso.exe &
|
||||
testlock.exe testmessage.exe testoverlay2.exe testplatform.exe &
|
||||
testpower.exe testsensor.exe testrelative.exe testrendercopyex.exe &
|
||||
testrendertarget.exe testrumble.exe testscale.exe testsem.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 testmouse.exe testgles.exe testgles2.exe &
|
||||
controllermap.exe testhaptic.exe testqsort.exe testresample.exe &
|
||||
testaudioinfo.exe testaudiocapture.exe loopwave.exe loopwavequeue.exe &
|
||||
testsurround.exe testyuv.exe testgl2.exe testvulkan.exe testnative.exe &
|
||||
testautomation.exe testaudiohotplug.exe testcustomcursor.exe testmultiaudio.exe &
|
||||
testoffscreen.exe testurl.exe
|
||||
|
||||
noninteractive = &
|
||||
testatomic.exe &
|
||||
testerror.exe &
|
||||
testfilesystem.exe &
|
||||
testkeys.exe &
|
||||
testlocale.exe &
|
||||
testplatform.exe &
|
||||
testpower.exe &
|
||||
testqsort.exe &
|
||||
testthread.exe &
|
||||
testtimer.exe &
|
||||
testver.exe
|
||||
|
||||
needs_audio = &
|
||||
testaudioinfo.exe &
|
||||
testsurround.exe
|
||||
|
||||
needs_display = &
|
||||
testbounds.exe &
|
||||
testdisplayinfo.exe
|
||||
|
||||
TESTS = $(noninteractive) $(needs_audio) $(needs_display)
|
||||
|
||||
# testautomation sources
|
||||
TASRCS = testautomation.c testautomation_audio.c testautomation_clipboard.c &
|
||||
testautomation_events.c testautomation_hints.c &
|
||||
testautomation_keyboard.c testautomation_main.c &
|
||||
testautomation_mouse.c testautomation_pixels.c &
|
||||
testautomation_platform.c testautomation_rect.c &
|
||||
testautomation_render.c testautomation_rwops.c &
|
||||
testautomation_sdltest.c testautomation_stdlib.c &
|
||||
testautomation_surface.c testautomation_syswm.c &
|
||||
testautomation_timer.c testautomation_video.c &
|
||||
testautomation_math.c
|
||||
|
||||
OBJS = $(TARGETS:.exe=.obj)
|
||||
COBJS = $(CSRCS:.c=.obj)
|
||||
TAOBJS = $(TASRCS:.c=.obj)
|
||||
TNOBJS = $(TNSRCS:.c=.obj)
|
||||
|
||||
all: testutils.lib $(TARGETS)
|
||||
|
||||
.c: ../src/test
|
||||
|
||||
.obj.exe:
|
||||
wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
.c.obj:
|
||||
wcc386 $(CFLAGS) -fo=$^@ $<
|
||||
|
||||
# specials
|
||||
testautomation.exe: $(TAOBJS)
|
||||
wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testnative.exe: $(TNOBJS)
|
||||
wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testoverlay2.exe: testoverlay2.obj testyuv_cvt.obj
|
||||
wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testyuv.exe: testyuv.obj testyuv_cvt.obj
|
||||
wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testshader.exe: testshader.obj
|
||||
wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS) $(GLLIBS)} op q op el file {$<} name $@
|
||||
|
||||
testime.exe: testime.obj
|
||||
wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS) $(TTFLIBS)} op q op el file {$<} name $@
|
||||
|
||||
testutils.lib: testutils.obj
|
||||
wlib -q -b -n -c -pa -s -t -zld -ii -io $@ $<
|
||||
|
||||
check: .SYMBOLIC $(TESTS)
|
||||
@set SDL_AUDIODRIVER=dummy
|
||||
@set SDL_VIDEODRIVER=dummy
|
||||
@copy "../SDL2.dll" .
|
||||
@for %exe in ($(TESTS)) do %exe
|
||||
|
||||
check-quick: .SYMBOLIC $(TESTS)
|
||||
@set SDL_TESTS_QUICK=1
|
||||
@set SDL_AUDIODRIVER=dummy
|
||||
@set SDL_VIDEODRIVER=dummy
|
||||
@copy "../SDL2.dll" .
|
||||
@for %exe in ($(TESTS)) do %exe
|
||||
|
||||
clean: .SYMBOLIC
|
||||
rm -f *.obj *.err
|
||||
distclean: .SYMBOLIC clean
|
||||
rm -f *.exe *.lib
|
Reference in New Issue
Block a user