mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
* Adjustment: Update libsdl to address a bug in compilation on MacOS devices.
This commit is contained in:
parent
516163fd5d
commit
eab544c8f3
270 changed files with 9531 additions and 3704 deletions
|
|
@ -1,5 +1,10 @@
|
|||
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?
|
||||
|
|
@ -48,8 +53,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)
|
||||
|
|
@ -57,8 +62,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)
|
||||
|
|
@ -68,9 +73,14 @@ 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)
|
||||
|
|
@ -79,52 +89,164 @@ 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
|
||||
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
|
||||
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)
|
||||
|
|
@ -177,12 +299,14 @@ else()
|
|||
testaudiohotplug
|
||||
testmultiaudio
|
||||
testime
|
||||
testnative
|
||||
testiconv
|
||||
testoverlay2
|
||||
teststreaming
|
||||
testviewport
|
||||
)
|
||||
if(WINDOWS OR APPLE OR SDL_X11)
|
||||
list(APPEND NEEDS_RESOURCES testnative)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PSP)
|
||||
|
|
@ -262,6 +386,20 @@ if(PSP)
|
|||
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})
|
||||
if(PSP)
|
||||
|
|
@ -298,3 +436,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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -79,7 +88,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 +118,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
|
||||
|
|
@ -126,10 +154,10 @@ testautomation$(EXE): $(srcdir)/testautomation.c \
|
|||
$(srcdir)/testautomation_hints.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,10 +193,10 @@ 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
|
||||
|
|
@ -183,7 +211,7 @@ 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@
|
||||
|
||||
testhaptic$(EXE): $(srcdir)/testhaptic.c
|
||||
|
|
@ -198,10 +226,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 +247,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 +283,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 +295,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 +313,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 +331,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 +343,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 +361,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 +375,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 \
|
||||
|
|
|
|||
|
|
@ -1,77 +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 SDL2test.lib
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
.obj.exe:
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
.c.obj:
|
||||
wcc386 $(CFLAGS) -fo=$^@ $<
|
||||
|
||||
# specials
|
||||
testautomation.exe: $(TAOBJS)
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testnative.exe: testnative.obj testnativeos2.obj
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testoverlay2.exe: testoverlay2.obj testyuv_cvt.obj
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testyuv.exe: testyuv.obj testyuv_cvt.obj
|
||||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
testime.exe: testime.obj
|
||||
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
|
||||
!include watcom.mif
|
||||
|
|
|
|||
16
Engine/lib/sdl/test/Makefile.w32
Normal file
16
Engine/lib/sdl/test/Makefile.w32
Normal 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
|
||||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
Engine/lib/sdl/test/template.test.in
Normal file
3
Engine/lib/sdl/test/template.test.in
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[Test]
|
||||
Type=session
|
||||
Exec=@installedtestsdir@/@exe@
|
||||
|
|
@ -709,6 +709,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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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) */
|
||||
|
|
|
|||
|
|
@ -160,7 +160,28 @@ loop()
|
|||
if (current_cursor == SDL_arraysize(cursors)) {
|
||||
current_cursor = 0;
|
||||
}
|
||||
|
||||
SDL_SetCursor(cursors[current_cursor]);
|
||||
|
||||
if (current_cursor == 0) {
|
||||
SDL_Log("Custom cursor");
|
||||
} else {
|
||||
switch ((SDL_SystemCursor) (current_cursor-1)) {
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1019,7 +1019,7 @@ static int
|
|||
run_test(void)
|
||||
{
|
||||
printf("SDL compiled without evdev capability check.\n");
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
@ -151,7 +164,8 @@ 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 : "");
|
||||
}
|
||||
|
||||
if (SDL_GameControllerHasSensor(gamecontroller, SDL_SENSOR_ACCEL)) {
|
||||
|
|
@ -216,34 +230,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 +292,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 +579,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 +606,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 +626,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 +642,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 +658,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 +722,7 @@ loop(void *arg)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Delay(16);
|
||||
SDL_RenderPresent(screen);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
|
@ -560,6 +775,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),
|
||||
|
|
@ -568,6 +784,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";
|
||||
|
|
@ -603,10 +820,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());
|
||||
|
|
@ -634,10 +852,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);
|
||||
|
|
@ -650,8 +868,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];
|
||||
|
|
@ -675,6 +899,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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
153
Engine/lib/sdl/test/testutils.c
Normal file
153
Engine/lib/sdl/test/testutils.c
Normal 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
Engine/lib/sdl/test/testutils.h
Normal file
17
Engine/lib/sdl/test/testutils.h
Normal 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
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
162
Engine/lib/sdl/test/versioning.sh
Executable file
162
Engine/lib/sdl/test/versioning.sh
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"
|
||||
115
Engine/lib/sdl/test/watcom.mif
Normal file
115
Engine/lib/sdl/test/watcom.mif
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
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 &
|
||||
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
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue