mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-30 13:28:13 +08:00
testprograms: parse arguments using SDLTest_CommonState
This commit is contained in:
committed by
Anonymous Maarten
parent
8bea41f737
commit
4a6528e3f0
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\..\..\test\axis.bmp">
|
||||
|
||||
@@ -194,6 +194,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\Test\loopwave.c" />
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\testatomic.c" />
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\Test\testfile.c" />
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\..\..\test\axis.bmp">
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\testjoystick.c" />
|
||||
|
||||
@@ -216,6 +216,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\Test\testplatform.c" />
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\testpower.c" />
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\testrumble.c" />
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\testsensor.c" />
|
||||
|
||||
@@ -188,6 +188,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\testshape.c" />
|
||||
|
||||
@@ -194,6 +194,12 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDL_test\SDL_test.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\Test\testsurround.c" />
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\test\testyuv.c" />
|
||||
<ClCompile Include="..\..\..\test\testyuv_cvt.c" />
|
||||
<ClCompile Include="..\..\..\test\testutils.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\test\testyuv_cvt.h" />
|
||||
|
||||
+34
-24
@@ -136,9 +136,39 @@ add_sdl_test_executable(testdropfile testdropfile.c)
|
||||
add_sdl_test_executable(testerror NONINTERACTIVE testerror.c)
|
||||
|
||||
if(LINUX AND TARGET sdl-build-options)
|
||||
set(build_options_dependent_tests )
|
||||
|
||||
add_sdl_test_executable(testevdev NONINTERACTIVE testevdev.c)
|
||||
target_include_directories(testevdev BEFORE PRIVATE $<TARGET_PROPERTY:sdl-build-options,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
target_include_directories(testevdev BEFORE PRIVATE ${SDL3_SOURCE_DIR}/src)
|
||||
list(APPEND build_options_dependent_tests testevdev)
|
||||
|
||||
if(APPLE)
|
||||
add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS
|
||||
testnative.c
|
||||
testnativecocoa.m
|
||||
testnativex11.c
|
||||
)
|
||||
target_compile_definitions(testnative PRIVATE TEST_NATIVE_COCOA)
|
||||
|
||||
cmake_push_check_state()
|
||||
check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
|
||||
cmake_pop_check_state()
|
||||
if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
|
||||
set_property(SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations")
|
||||
endif()
|
||||
list(APPEND build_options_dependent_tests testnative)
|
||||
elseif(WINDOWS)
|
||||
add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativew32.c)
|
||||
list(APPEND build_options_dependent_tests testnative)
|
||||
elseif(HAVE_X11)
|
||||
add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativex11.c)
|
||||
target_link_libraries(testnative PRIVATE X11)
|
||||
list(APPEND build_options_dependent_tests testnative)
|
||||
endif()
|
||||
|
||||
foreach(t ${build_options_dependent_tests})
|
||||
target_include_directories(${t} BEFORE PRIVATE $<TARGET_PROPERTY:sdl-build-options,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
target_include_directories(${t} BEFORE PRIVATE ${SDL3_SOURCE_DIR}/src)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
add_sdl_test_executable(testfile testfile.c)
|
||||
@@ -161,26 +191,6 @@ add_sdl_test_executable(testlocale NONINTERACTIVE testlocale.c)
|
||||
add_sdl_test_executable(testlock testlock.c)
|
||||
add_sdl_test_executable(testmouse testmouse.c)
|
||||
|
||||
if(APPLE)
|
||||
add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS
|
||||
testnative.c
|
||||
testnativecocoa.m
|
||||
testnativex11.c
|
||||
)
|
||||
|
||||
cmake_push_check_state()
|
||||
check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
|
||||
cmake_pop_check_state()
|
||||
if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS)
|
||||
set_property(SOURCE "testnativecocoa.m" APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-error=deprecated-declarations")
|
||||
endif()
|
||||
elseif(WINDOWS)
|
||||
add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativew32.c)
|
||||
elseif(HAVE_X11)
|
||||
add_sdl_test_executable(testnative NEEDS_RESOURCES TESTUTILS testnative.c testnativex11.c)
|
||||
target_link_libraries(testnative PRIVATE X11)
|
||||
endif()
|
||||
|
||||
add_sdl_test_executable(testoverlay NEEDS_RESOURCES TESTUTILS testoverlay.c)
|
||||
add_sdl_test_executable(testplatform NONINTERACTIVE testplatform.c)
|
||||
add_sdl_test_executable(testpower NONINTERACTIVE testpower.c)
|
||||
@@ -189,7 +199,7 @@ add_sdl_test_executable(testrendertarget NEEDS_RESOURCES TESTUTILS testrendertar
|
||||
add_sdl_test_executable(testscale NEEDS_RESOURCES TESTUTILS testscale.c)
|
||||
add_sdl_test_executable(testsem testsem.c)
|
||||
add_sdl_test_executable(testsensor testsensor.c)
|
||||
add_sdl_test_executable(testshader NEEDS_RESOURCES testshader.c)
|
||||
add_sdl_test_executable(testshader NEEDS_RESOURCES TESTUTILS testshader.c)
|
||||
add_sdl_test_executable(testshape NEEDS_RESOURCES testshape.c)
|
||||
add_sdl_test_executable(testsprite NEEDS_RESOURCES TESTUTILS testsprite.c)
|
||||
add_sdl_test_executable(testspriteminimal NEEDS_RESOURCES TESTUTILS testspriteminimal.c)
|
||||
@@ -199,7 +209,7 @@ add_sdl_test_executable(testurl testurl.c)
|
||||
add_sdl_test_executable(testver NONINTERACTIVE testver.c)
|
||||
add_sdl_test_executable(testviewport NEEDS_RESOURCES TESTUTILS testviewport.c)
|
||||
add_sdl_test_executable(testwm testwm.c)
|
||||
add_sdl_test_executable(testyuv NEEDS_RESOURCES testyuv.c testyuv_cvt.c)
|
||||
add_sdl_test_executable(testyuv NEEDS_RESOURCES TESTUTILS testyuv.c testyuv_cvt.c)
|
||||
add_sdl_test_executable(torturethread torturethread.c)
|
||||
add_sdl_test_executable(testrendercopyex NEEDS_RESOURCES TESTUTILS testrendercopyex.c)
|
||||
add_sdl_test_executable(testmessage testmessage.c)
|
||||
|
||||
+15
-1
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test_font.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static SDL_Window *window;
|
||||
static SDL_Renderer *renderer;
|
||||
@@ -249,9 +249,22 @@ static void loop(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Disable mouse emulation */
|
||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||
|
||||
@@ -304,5 +317,6 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static int done;
|
||||
|
||||
@@ -240,10 +241,22 @@ int main(int argc, char *argv[])
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Thread *thread;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize SDL */
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -290,5 +303,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
SDL_WaitThread(thread, NULL);
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+30
-4
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testutils.h"
|
||||
|
||||
/* Define this for verbose output while mapping gamepads */
|
||||
@@ -729,22 +730,45 @@ int main(int argc, char *argv[])
|
||||
SDL_JoystickID *joysticks;
|
||||
int joystick_index;
|
||||
SDL_Joystick *joystick = NULL;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcmp(argv[i], "--bind-touchpad") == 0) {
|
||||
bind_touchpad = SDL_TRUE;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[--bind-touchpad]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Initialize SDL (Note: video is required to start event loop) */
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argv[1] && SDL_strcmp(argv[1], "--bind-touchpad") == 0) {
|
||||
bind_touchpad = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Create a window to display joystick axis position */
|
||||
window = SDL_CreateWindow("Game Controller Map", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
|
||||
if (window == NULL) {
|
||||
@@ -830,5 +854,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
|
||||
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+30
-1
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testutils.h"
|
||||
|
||||
static struct
|
||||
@@ -113,17 +114,44 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *filename = NULL;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (!filename) {
|
||||
filename = argv[i];
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[sample.wav]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
filename = GetResourceFilename(filename, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
@@ -174,5 +202,6 @@ int main(int argc, char *argv[])
|
||||
SDL_free(wave.sound);
|
||||
SDL_free(filename);
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+32
-2
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#if HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
@@ -73,18 +74,46 @@ static void loop(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *filename = NULL;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (!filename) {
|
||||
filename = argv[i];
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[sample.wav]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
filename = GetResourceFilename(filename, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
@@ -137,7 +166,7 @@ int main(int argc, char *argv[])
|
||||
while (!done && (SDL_GetAudioDeviceStatus(g_audio_id) == SDL_AUDIO_PLAYING)) {
|
||||
loop();
|
||||
|
||||
SDL_Delay(100); /* let it play for awhile. */
|
||||
SDL_Delay(100); /* let it play for a while. */
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -146,5 +175,6 @@ int main(int argc, char *argv[])
|
||||
SDL_free(wave.sound);
|
||||
SDL_free(filename);
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
/*
|
||||
Absolutely basic tests just to see if we get the expected value
|
||||
@@ -695,9 +696,22 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
RunBasicTest();
|
||||
|
||||
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
|
||||
@@ -711,5 +725,6 @@ int main(int argc, char *argv[])
|
||||
RunFIFOTest(SDL_FALSE);
|
||||
#endif
|
||||
RunFIFOTest(SDL_TRUE);
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+39
-5
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
@@ -89,23 +90,52 @@ static void loop(void)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* (argv[1] == NULL means "open default device.") */
|
||||
const char *devname = argv[1];
|
||||
/* (NULL means "open default device.") */
|
||||
const char *devname = NULL;
|
||||
SDL_AudioSpec wanted;
|
||||
int devcount;
|
||||
int i;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (!devname) {
|
||||
devname = argv[i];
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[driver_name]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
window = SDL_CreateWindow("testaudiocapture", 320, 240, 0);
|
||||
renderer = SDL_CreateRenderer(window, NULL, 0);
|
||||
if (SDL_CreateWindowAndRenderer(320, 240, 0, &window, &renderer) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window and renderer: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
@@ -145,7 +175,7 @@ int main(int argc, char **argv)
|
||||
devname ? devname : "[[default]]",
|
||||
devname ? "'" : "");
|
||||
|
||||
devid_in = SDL_OpenAudioDevice(argv[1], SDL_TRUE, &spec, &spec, 0);
|
||||
devid_in = SDL_OpenAudioDevice(devname, SDL_TRUE, &spec, &spec, 0);
|
||||
if (!devid_in) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for capture: %s!\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
@@ -162,6 +192,10 @@ int main(int argc, char **argv)
|
||||
SDL_Delay(16);
|
||||
}
|
||||
#endif
|
||||
/* SDL_DestroyRenderer(renderer); */
|
||||
/* SDL_DestroyWindow(window); */
|
||||
|
||||
/* SDL_Quit(); */
|
||||
/* SDLTest_CommonDestroyState(state); */
|
||||
/* return 0; */
|
||||
}
|
||||
|
||||
+39
-3
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testutils.h"
|
||||
|
||||
static SDL_AudioSpec spec;
|
||||
@@ -33,11 +34,14 @@ static Uint32 soundlen = 0; /* Length of wave data */
|
||||
static int posindex = 0;
|
||||
static Uint32 positions[64];
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
quit(int rc)
|
||||
{
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
@@ -134,10 +138,37 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *filename = NULL;
|
||||
SDL_Window *window;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (!filename) {
|
||||
filename = argv[i];
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[sample.wav]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -145,9 +176,14 @@ int 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", 640, 480, 0));
|
||||
window = SDL_CreateWindow("testaudiohotplug", 640, 480, 0);
|
||||
if (window == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateWindow failed: %s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
SDL_MinimizeWindow(window);
|
||||
|
||||
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
filename = GetResourceFilename(filename, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
@@ -195,6 +231,6 @@ int main(int argc, char *argv[])
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
SDL_free(sound);
|
||||
SDL_free(filename);
|
||||
SDL_Quit();
|
||||
quit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+15
-1
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static void
|
||||
print_devices(int iscapture)
|
||||
@@ -49,11 +50,24 @@ int main(int argc, char **argv)
|
||||
{
|
||||
char *deviceName = NULL;
|
||||
SDL_AudioSpec spec;
|
||||
int i;
|
||||
int n;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -65,7 +79,6 @@ int main(int argc, char **argv)
|
||||
if (n == 0) {
|
||||
SDL_Log("No built-in audio drivers\n\n");
|
||||
} else {
|
||||
int i;
|
||||
SDL_Log("Built-in audio drivers:\n");
|
||||
for (i = 0; i < n; ++i) {
|
||||
SDL_Log(" %d: %s\n", i, SDL_GetAudioDriver(i));
|
||||
@@ -99,5 +112,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,24 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
SDL_DisplayID *displays;
|
||||
int i;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError());
|
||||
@@ -38,5 +51,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static void
|
||||
print_mode(const char *prefix, const SDL_DisplayMode *mode)
|
||||
@@ -35,10 +36,22 @@ int main(int argc, char *argv[])
|
||||
const SDL_DisplayMode **modes;
|
||||
const SDL_DisplayMode *mode;
|
||||
int num_displays, i;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -85,5 +98,6 @@ int main(int argc, char *argv[])
|
||||
SDL_free(displays);
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static SDL_Window *window;
|
||||
static SDL_Renderer *renderer;
|
||||
@@ -101,9 +102,22 @@ static void loop(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize SDL */
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
|
||||
@@ -138,5 +152,6 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-3
@@ -33,15 +33,15 @@ int main(int argc, char *argv[])
|
||||
float x = 0.0f, y = 0.0f;
|
||||
unsigned int windowID = 0;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static int alive = 0;
|
||||
|
||||
@@ -44,10 +45,22 @@ ThreadFunc(void *data)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Thread *thread;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(0) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -77,5 +90,6 @@ int main(int argc, char *argv[])
|
||||
SDL_Log("Main thread error string: %s\n", SDL_GetError());
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+19
-1
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include "../src/SDL_internal.h"
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -1038,5 +1039,22 @@ run_test(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return run_test() ? 0 : 1;
|
||||
int result;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
result = run_test() ? 0 : 1;
|
||||
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
/* WARNING ! those 2 files will be destroyed by this test program */
|
||||
|
||||
@@ -40,6 +41,8 @@
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
@@ -55,6 +58,7 @@ rwops_error_quit(unsigned line, SDL_RWops *rwops)
|
||||
rwops->close(rwops); /* This calls SDL_DestroyRW(rwops); */
|
||||
}
|
||||
cleanup();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
exit(1); /* quit with rwops error (test failed) */
|
||||
}
|
||||
|
||||
@@ -65,9 +69,20 @@ int main(int argc, char *argv[])
|
||||
SDL_RWops *rwops = NULL;
|
||||
char test_buf[30];
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
cleanup();
|
||||
|
||||
/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
|
||||
@@ -354,5 +369,6 @@ int main(int argc, char *argv[])
|
||||
rwops->close(rwops);
|
||||
SDL_Log("test5 OK\n");
|
||||
cleanup();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0; /* all ok */
|
||||
}
|
||||
|
||||
@@ -13,15 +13,28 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDLTest_CommonState *state;
|
||||
char *base_path;
|
||||
char *pref_path;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_Init(0) == -1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
@@ -55,5 +68,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+51
-23
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testutils.h"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
@@ -862,7 +863,14 @@ static void loop(void *arg)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int gamepad_index = 0;
|
||||
int gamepad_index = -1;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
|
||||
@@ -875,6 +883,47 @@ int main(int argc, char *argv[])
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcmp(argv[i], "--mappings") == 0) {
|
||||
int map_i;
|
||||
SDL_Log("Supported mappings:\n");
|
||||
for (map_i = 0; map_i < SDL_GetNumGamepadMappings(); ++map_i) {
|
||||
char *mapping = SDL_GetGamepadMappingForIndex(map_i);
|
||||
if (mapping) {
|
||||
SDL_Log("\t%s\n", mapping);
|
||||
SDL_free(mapping);
|
||||
}
|
||||
}
|
||||
SDL_Log("\n");
|
||||
consumed = 1;
|
||||
} else if (SDL_strcmp(argv[i], "--virtual") == 0) {
|
||||
OpenVirtualGamepad();
|
||||
consumed = 1;
|
||||
} else if (gamepad_index < 0) {
|
||||
char *endptr = NULL;
|
||||
gamepad_index = (int)SDL_strtol(argv[i], &endptr, 0);
|
||||
if (endptr != argv[i] && *endptr == '\0' && gamepad_index >= 0) {
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[--mappings]", "[--virtual]", "[index]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
if (gamepad_index < 0) {
|
||||
gamepad_index = 0;
|
||||
}
|
||||
|
||||
/* Initialize SDL (Note: video is required to start event loop) */
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -883,19 +932,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
SDL_AddGamepadMappingsFromFile("gamecontrollerdb.txt");
|
||||
|
||||
/* Print information about the mappings */
|
||||
if (argv[1] && SDL_strcmp(argv[1], "--mappings") == 0) {
|
||||
SDL_Log("Supported mappings:\n");
|
||||
for (i = 0; i < SDL_GetNumGamepadMappings(); ++i) {
|
||||
char *mapping = SDL_GetGamepadMappingForIndex(i);
|
||||
if (mapping) {
|
||||
SDL_Log("\t%s\n", mapping);
|
||||
SDL_free(mapping);
|
||||
}
|
||||
}
|
||||
SDL_Log("\n");
|
||||
}
|
||||
|
||||
/* Create a window to display gamepad state */
|
||||
window = SDL_CreateWindow("Gamepad Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
|
||||
if (window == NULL) {
|
||||
@@ -935,15 +971,6 @@ int main(int argc, char *argv[])
|
||||
/* Process the initial gamepad list */
|
||||
loop(NULL);
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (SDL_strcmp(argv[i], "--virtual") == 0) {
|
||||
OpenVirtualGamepad();
|
||||
}
|
||||
if (argv[i] && *argv[i] != '-') {
|
||||
gamepad_index = SDL_atoi(argv[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gamepad_index < num_gamepads) {
|
||||
gamepad = gamepads[gamepad_index];
|
||||
} else {
|
||||
@@ -970,6 +997,7 @@ int main(int argc, char *argv[])
|
||||
SDL_DestroyRenderer(screen);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD);
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+4
-3
@@ -168,14 +168,15 @@ int main(int argc, char *argv[])
|
||||
Uint64 then, now;
|
||||
Uint32 frames;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
|
||||
+5
-4
@@ -45,7 +45,7 @@ static int LoadContext(GL_Context *data)
|
||||
#else
|
||||
#define SDL_PROC(ret, func, params) \
|
||||
do { \
|
||||
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
|
||||
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
|
||||
if (!data->func) { \
|
||||
return SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \
|
||||
} \
|
||||
@@ -210,9 +210,6 @@ int main(int argc, char *argv[])
|
||||
int interval = 0;
|
||||
int ret_interval = 0;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Initialize parameters */
|
||||
fsaa = 0;
|
||||
accel = -1;
|
||||
@@ -222,6 +219,10 @@ int main(int argc, char *argv[])
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
|
||||
+11
-5
@@ -103,9 +103,6 @@ int main(int argc, char *argv[])
|
||||
Uint32 then, now, frames;
|
||||
int status;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Initialize parameters */
|
||||
fsaa = 0;
|
||||
accel = 0;
|
||||
@@ -115,6 +112,10 @@ int main(int argc, char *argv[])
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
@@ -131,8 +132,13 @@ int main(int argc, char *argv[])
|
||||
if (!argv[i]) {
|
||||
consumed = -1;
|
||||
} else {
|
||||
depth = SDL_atoi(argv[i]);
|
||||
consumed = 1;
|
||||
char *endptr = NULL;
|
||||
depth = (int)SDL_strtol(argv[i], &endptr, 0);
|
||||
if (endptr != argv[i] && *endptr == '\0') {
|
||||
consumed = 1;
|
||||
} else {
|
||||
consumed = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
consumed = -1;
|
||||
|
||||
+7
-2
@@ -651,8 +651,13 @@ int main(int argc, char *argv[])
|
||||
if (!argv[i]) {
|
||||
consumed = -1;
|
||||
} else {
|
||||
depth = SDL_atoi(argv[i]);
|
||||
consumed = 1;
|
||||
char *endptr = NULL;
|
||||
depth = (int)SDL_strtol(argv[i], &endptr, 0);
|
||||
if (endptr != argv[i] && *endptr == '\0') {
|
||||
consumed = 1;
|
||||
} else {
|
||||
consumed = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
consumed = -1;
|
||||
|
||||
@@ -465,8 +465,13 @@ int main(int argc, char *argv[])
|
||||
if (!argv[i]) {
|
||||
consumed = -1;
|
||||
} else {
|
||||
depth = SDL_atoi(argv[i]);
|
||||
consumed = 1;
|
||||
char *endptr = NULL;
|
||||
depth = (int)SDL_strtol(argv[i], &endptr, 0);
|
||||
if (endptr != argv[i] && *endptr == '\0') {
|
||||
consumed = 1;
|
||||
} else {
|
||||
consumed = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
consumed = -1;
|
||||
|
||||
+36
-17
@@ -13,10 +13,12 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static SDL_Haptic *haptic;
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
@@ -32,33 +34,48 @@ static void HapticPrintSupported(SDL_Haptic *);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *name;
|
||||
int index;
|
||||
char *name = NULL;
|
||||
int index = -1;
|
||||
SDL_HapticEffect efx[9];
|
||||
int id[9];
|
||||
int nefx;
|
||||
unsigned int supported;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
name = NULL;
|
||||
index = -1;
|
||||
if (argc > 1) {
|
||||
name = argv[1];
|
||||
if ((SDL_strcmp(name, "--help") == 0) || (SDL_strcmp(name, "-h") == 0)) {
|
||||
SDL_Log("USAGE: %s [device]\n"
|
||||
"If device is a two-digit number it'll use it as an index, otherwise\n"
|
||||
"it'll use it as if it were part of the device's name.\n",
|
||||
argv[0]);
|
||||
return 0;
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (!name && index < 0) {
|
||||
size_t len;
|
||||
name = argv[i];
|
||||
len = SDL_strlen(name);
|
||||
if (len < 3 && SDL_isdigit(name[0]) && (len == 1 || SDL_isdigit(name[1]))) {
|
||||
index = SDL_atoi(name);
|
||||
name = NULL;
|
||||
}
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[device]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
SDL_Log("\n");
|
||||
SDL_Log("If device is a two-digit number it'll use it as an index, otherwise\n"
|
||||
"it'll use it as if it were part of the device's name.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
i = (int)SDL_strlen(name);
|
||||
if ((i < 3) && SDL_isdigit(name[0]) && ((i == 1) || SDL_isdigit(name[1]))) {
|
||||
index = SDL_atoi(name);
|
||||
name = NULL;
|
||||
}
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Initialize the force feedbackness */
|
||||
@@ -281,6 +298,7 @@ int main(int argc, char **argv)
|
||||
SDL_HapticClose(haptic);
|
||||
}
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -295,6 +313,7 @@ abort_execution(void)
|
||||
|
||||
SDL_HapticClose(haptic);
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+29
-3
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -27,11 +28,35 @@ int main(int argc, char *argv[])
|
||||
int i;
|
||||
SDL_bool enable_haptic = SDL_TRUE;
|
||||
Uint32 init_subsystems = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (SDL_strcasecmp(argv[i], "--nohaptic") == 0) {
|
||||
enable_haptic = SDL_FALSE;
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcasecmp(argv[i], "--nohaptic") == 0) {
|
||||
enable_haptic = SDL_FALSE;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[--nohaptic]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
if (enable_haptic) {
|
||||
@@ -132,6 +157,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+31
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testutils.h"
|
||||
|
||||
static size_t
|
||||
@@ -49,18 +50,45 @@ int main(int argc, char *argv[])
|
||||
"UCS-4",
|
||||
};
|
||||
|
||||
char *fname;
|
||||
char *fname = NULL;
|
||||
char buffer[BUFSIZ];
|
||||
char *ucs4;
|
||||
char *test[2];
|
||||
int i;
|
||||
FILE *file;
|
||||
int errors = 0;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
fname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "utf8.txt");
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (!fname) {
|
||||
fname = argv[i];
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[utf8.txt]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
fname = GetResourceFilename(fname, "utf8.txt");
|
||||
file = fopen(fname, "rb");
|
||||
if (file == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", fname);
|
||||
@@ -93,5 +121,6 @@ int main(int argc, char *argv[])
|
||||
(void)fclose(file);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Total errors: %d\n", errors);
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return errors ? errors + 1 : 0;
|
||||
}
|
||||
|
||||
+22
-25
@@ -445,11 +445,6 @@ static Uint32 utf8_decode(char *p, size_t len)
|
||||
return codepoint;
|
||||
}
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
SDL_Log("usage: testime [--font fontfile]\n");
|
||||
}
|
||||
|
||||
static void InitInput(void)
|
||||
{
|
||||
/* Prepare a rect for text input */
|
||||
@@ -647,42 +642,43 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int i, done;
|
||||
SDL_Event event;
|
||||
const char *fontname = DEFAULT_FONT;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
char *fontname = NULL;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 1; i < argc; i++) {
|
||||
SDLTest_CommonArg(state, i);
|
||||
}
|
||||
for (argc--, argv++; argc > 0; argc--, argv++) {
|
||||
if (SDL_strcmp(argv[0], "--help") == 0) {
|
||||
usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (SDL_strcmp(argv[0], "--font") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
if (argc > 0) {
|
||||
fontname = argv[0];
|
||||
} else {
|
||||
usage();
|
||||
return 0;
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (SDL_strcmp(argv[i], "--font") == 0) {
|
||||
if (*argv[i+1]) {
|
||||
fontname = argv[i+1];
|
||||
consumed = 2;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[--font fontfile]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
if (!SDLTest_CommonInit(state)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
fontname = GetResourceFilename(fontname, DEFAULT_FONT);
|
||||
|
||||
#ifdef HAVE_SDL_TTF
|
||||
/* Initialize fonts */
|
||||
TTF_Init();
|
||||
@@ -794,6 +790,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_free(fontname);
|
||||
CleanupVideo();
|
||||
SDLTest_CommonQuit(state);
|
||||
return 0;
|
||||
|
||||
+23
-5
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
@@ -32,7 +33,6 @@
|
||||
static SDL_Window *window = NULL;
|
||||
static SDL_Renderer *screen = NULL;
|
||||
static SDL_Joystick *joystick = NULL;
|
||||
static SDL_bool done = SDL_FALSE;
|
||||
|
||||
static void
|
||||
PrintJoystick(SDL_Joystick *joy)
|
||||
@@ -103,6 +103,7 @@ static void loop(void *arg)
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
SDL_bool *done = (SDL_bool*)arg;
|
||||
|
||||
/* blank screen, set up for drawing this frame. */
|
||||
SDL_SetRenderDrawColor(screen, 0x0, 0x0, 0x0, SDL_ALPHA_OPAQUE);
|
||||
@@ -200,7 +201,7 @@ static void loop(void *arg)
|
||||
case SDL_EVENT_FINGER_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case SDL_EVENT_QUIT:
|
||||
done = SDL_TRUE;
|
||||
*done = SDL_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -279,7 +280,7 @@ static void loop(void *arg)
|
||||
SDL_RenderPresent(screen);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done) {
|
||||
if (*done == SDL_TRUE) {
|
||||
emscripten_cancel_main_loop();
|
||||
}
|
||||
#endif
|
||||
@@ -287,11 +288,25 @@ static void loop(void *arg)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_bool done;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize SDL (Note: video is required to start event loop) */
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -316,12 +331,14 @@ int main(int argc, char *argv[])
|
||||
SDL_RenderClear(screen);
|
||||
SDL_RenderPresent(screen);
|
||||
|
||||
done = SDL_FALSE;
|
||||
|
||||
/* Loop, getting joystick events! */
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop_arg(loop, NULL, 0, 1);
|
||||
emscripten_set_main_loop_arg(loop, &done, 0, 1);
|
||||
#else
|
||||
while (!done) {
|
||||
loop(NULL);
|
||||
loop(&done);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -329,6 +346,7 @@ int main(int argc, char *argv[])
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,27 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Scancode scancode;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
@@ -33,5 +46,6 @@ int main(int argc, char *argv[])
|
||||
SDL_GetScancodeName(scancode));
|
||||
}
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+50
-13
@@ -17,22 +17,67 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
typedef int (*fntype)(const char *);
|
||||
|
||||
static void log_usage(char *progname, SDLTest_CommonState *state) {
|
||||
static const char *options[] = { "library", "functionname|--hello", NULL };
|
||||
SDLTest_CommonLogUsage(state, progname, options);
|
||||
SDL_Log("USAGE: %s <library> <functionname>\n", progname);
|
||||
SDL_Log(" %s <lib with puts()> --hello\n", progname);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int retval = 0;
|
||||
int hello = 0;
|
||||
const char *libname = NULL;
|
||||
const char *symname = NULL;
|
||||
void *lib = NULL;
|
||||
fntype fn = NULL;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
if (argc != 3) {
|
||||
const char *app = argv[0];
|
||||
SDL_Log("USAGE: %s <library> <functionname>\n", app);
|
||||
SDL_Log(" %s --hello <lib with puts()>\n", app);
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcmp(argv[i], "--hello") == 0) {
|
||||
if (!symname || SDL_strcmp(symname, "puts") == 0) {
|
||||
symname = "puts";
|
||||
consumed = 1;
|
||||
hello = 1;
|
||||
}
|
||||
} else if (!libname) {
|
||||
libname = argv[i];
|
||||
consumed = 1;
|
||||
} else if (!symname) {
|
||||
symname = argv[i];
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
log_usage(argv[0], state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
if (!libname || !symname) {
|
||||
log_usage(argv[0], state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -42,15 +87,6 @@ int main(int argc, char *argv[])
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (SDL_strcmp(argv[1], "--hello") == 0) {
|
||||
hello = 1;
|
||||
libname = argv[2];
|
||||
symname = "puts";
|
||||
} else {
|
||||
libname = argv[1];
|
||||
symname = argv[2];
|
||||
}
|
||||
|
||||
lib = SDL_LoadObject(libname);
|
||||
if (lib == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
|
||||
@@ -74,5 +110,6 @@ int main(int argc, char *argv[])
|
||||
SDL_UnloadObject(lib);
|
||||
}
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return retval;
|
||||
}
|
||||
|
||||
+56
-19
@@ -11,8 +11,7 @@
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
/* !!! FIXME: move this to the test framework */
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static void log_locales(void)
|
||||
{
|
||||
@@ -35,31 +34,69 @@ static void log_locales(void)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int listen = 0;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Print locales and languages */
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != -1) {
|
||||
log_locales();
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
if ((argc == 2) && (SDL_strcmp(argv[1], "--listen") == 0)) {
|
||||
SDL_bool keep_going = SDL_TRUE;
|
||||
while (keep_going) {
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e)) {
|
||||
if (e.type == SDL_EVENT_QUIT) {
|
||||
keep_going = SDL_FALSE;
|
||||
} else if (e.type == SDL_EVENT_LOCALE_CHANGED) {
|
||||
SDL_Log("Saw SDL_EVENT_LOCALE_CHANGED event!");
|
||||
log_locales();
|
||||
}
|
||||
}
|
||||
SDL_Delay(10);
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcmp(argv[1], "--listen") == 0) {
|
||||
listen = 1;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[--listen]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Print locales and languages */
|
||||
if (SDLTest_CommonInit(state) == SDL_FALSE) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
log_locales();
|
||||
|
||||
if (listen) {
|
||||
int done = 0;
|
||||
while (!done) {
|
||||
SDL_Event e;
|
||||
SDLTest_CommonEvent(state, &e, &done);
|
||||
while (SDL_PollEvent(&e)) {
|
||||
if (e.type == SDL_EVENT_QUIT) {
|
||||
done = 1;
|
||||
} else if (e.type == SDL_EVENT_LOCALE_CHANGED) {
|
||||
SDL_Log("Saw SDL_EVENT_LOCALE_CHANGED event!");
|
||||
log_locales();
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < state->num_windows; i++) {
|
||||
SDL_RenderPresent(state->renderers[i]);
|
||||
}
|
||||
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
SDLTest_CommonQuit(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
@@ -81,10 +82,22 @@ button_messagebox(void *eventNumber)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int success;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
|
||||
"Simple MessageBox",
|
||||
"This is a simple error MessageBox",
|
||||
@@ -208,5 +221,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+34
-14
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
@@ -49,7 +50,10 @@ static SDL_bool wheel_y_active = SDL_FALSE;
|
||||
static float wheel_x = SCREEN_WIDTH * 0.5f;
|
||||
static float wheel_y = SCREEN_HEIGHT * 0.5f;
|
||||
|
||||
static SDL_bool done = SDL_FALSE;
|
||||
struct mouse_loop_data {
|
||||
SDL_bool done;
|
||||
SDL_Renderer *renderer;
|
||||
};
|
||||
|
||||
static void DrawObject(SDL_Renderer *renderer, Object *object)
|
||||
{
|
||||
@@ -104,8 +108,9 @@ static void AppendObject(Object *object)
|
||||
|
||||
static void loop(void *arg)
|
||||
{
|
||||
SDL_Renderer *renderer = (SDL_Renderer *)arg;
|
||||
struct mouse_loop_data *loop_data = (struct mouse_loop_data *)arg;
|
||||
SDL_Event event;
|
||||
SDL_Renderer *renderer = loop_data->renderer;
|
||||
|
||||
/* Check for events */
|
||||
while (SDL_PollEvent(&event)) {
|
||||
@@ -212,7 +217,7 @@ static void loop(void *arg)
|
||||
break;
|
||||
|
||||
case SDL_EVENT_QUIT:
|
||||
done = SDL_TRUE;
|
||||
loop_data->done = SDL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -241,7 +246,7 @@ static void loop(void *arg)
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done) {
|
||||
if (loop_data->done) {
|
||||
emscripten_cancel_main_loop();
|
||||
}
|
||||
#endif
|
||||
@@ -249,11 +254,23 @@ static void loop(void *arg)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
struct mouse_loop_data loop_data;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize SDL (Note: video is required to start event loop) */
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -262,31 +279,34 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Create a window to display joystick axis position */
|
||||
window = SDL_CreateWindow("Mouse Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
|
||||
if (window == NULL) {
|
||||
if (!window) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, NULL, 0);
|
||||
if (renderer == NULL) {
|
||||
loop_data.done = SDL_FALSE;
|
||||
|
||||
loop_data.renderer = SDL_CreateRenderer(window, NULL, 0);
|
||||
if (!loop_data.renderer) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
|
||||
SDL_DestroyWindow(window);
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Main render loop */
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop_arg(loop, renderer, 0, 1);
|
||||
emscripten_set_main_loop_arg(loop, &loop_data, 0, 1);
|
||||
#else
|
||||
while (!done) {
|
||||
loop(renderer);
|
||||
while (loop_data.done == SDL_FALSE) {
|
||||
loop(&loop_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyRenderer(loop_data.renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+40
-6
@@ -11,6 +11,9 @@
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
#include <stdio.h> /* for fflush() and stdout */
|
||||
|
||||
@@ -166,10 +169,39 @@ test_multi_audio(int devcount)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int devcount = 0;
|
||||
int i;
|
||||
char *filename = NULL;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (!filename) {
|
||||
filename = argv[i];
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[sample.wav]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -178,24 +210,26 @@ int main(int argc, char **argv)
|
||||
|
||||
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
|
||||
|
||||
filename = GetResourceFilename(filename, "sample.wav");
|
||||
|
||||
devcount = SDL_GetNumAudioDevices(0);
|
||||
if (devcount < 1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
|
||||
} else {
|
||||
char *file = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(file, &spec, &sound, &soundlen) == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file,
|
||||
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename,
|
||||
SDL_GetError());
|
||||
} else {
|
||||
test_multi_audio(devcount);
|
||||
SDL_free(sound);
|
||||
}
|
||||
|
||||
SDL_free(file);
|
||||
}
|
||||
|
||||
SDL_free(filename);
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "testutils.h"
|
||||
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#define WINDOW_W 640
|
||||
#define WINDOW_H 480
|
||||
@@ -39,6 +40,7 @@ static NativeWindowFactory *factories[] = {
|
||||
static NativeWindowFactory *factory = NULL;
|
||||
static void *native_window;
|
||||
static SDL_FRect *positions, *velocities;
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
@@ -48,6 +50,7 @@ quit(int rc)
|
||||
if (native_window != NULL && factory != NULL) {
|
||||
factory->DestroyNativeWindow(native_window);
|
||||
}
|
||||
SDLTest_CommonDestroyState(state);
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
@@ -100,9 +103,20 @@ int main(int argc, char *argv[])
|
||||
int sprite_w, sprite_h;
|
||||
SDL_Event event;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
|
||||
SDL_GetError());
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
/* Hack to avoid dynapi renaming */
|
||||
#include "../src/dynapi/SDL_dynapi.h"
|
||||
#ifdef SDL_DYNAMIC_API
|
||||
#undef SDL_DYNAMIC_API
|
||||
#endif
|
||||
|
||||
#include "../src/SDL_internal.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *tag;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user