mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-15 19:05:32 +00:00
testprograms: parse arguments using SDLTest_CommonState
This commit is contained in:
committed by
Anonymous Maarten
parent
8bea41f737
commit
4a6528e3f0
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user