SDL 3.0
SDL_test_common.h File Reference
#include <SDL3/SDL.h>
#include <SDL3/SDL_begin_code.h>
#include <SDL3/SDL_close_code.h>
+ Include dependency graph for SDL_test_common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDLTest_CommonState
 

Macros

#define DEFAULT_WINDOW_WIDTH   640
 
#define DEFAULT_WINDOW_HEIGHT   480
 
#define VERBOSE_VIDEO   0x00000001
 
#define VERBOSE_MODES   0x00000002
 
#define VERBOSE_RENDER   0x00000004
 
#define VERBOSE_EVENT   0x00000008
 
#define VERBOSE_AUDIO   0x00000010
 
#define VERBOSE_MOTION   0x00000020
 

Functions

SDLTest_CommonStateSDLTest_CommonCreateState (char **argv, Uint32 flags)
 
void SDLTest_CommonDestroyState (SDLTest_CommonState *state)
 
int SDLTest_CommonArg (SDLTest_CommonState *state, int index)
 
void SDLTest_CommonLogUsage (SDLTest_CommonState *state, const char *argv0, const char **options)
 
SDL_bool SDLTest_CommonInit (SDLTest_CommonState *state)
 
SDL_bool SDLTest_CommonDefaultArgs (SDLTest_CommonState *state, const int argc, char **argv)
 
void SDLTest_CommonEvent (SDLTest_CommonState *state, SDL_Event *event, int *done)
 
int SDLTest_CommonEventMainCallbacks (SDLTest_CommonState *state, const SDL_Event *event)
 
void SDLTest_CommonQuit (SDLTest_CommonState *state)
 
void SDLTest_CommonDrawWindowInfo (SDL_Renderer *renderer, SDL_Window *window, float *usedHeight)
 

Detailed Description

Common functions of SDL test framework.

This code is a part of the SDL test library, not the main SDL library.

Definition in file SDL_test_common.h.

Macro Definition Documentation

◆ DEFAULT_WINDOW_HEIGHT

#define DEFAULT_WINDOW_HEIGHT   480

Definition at line 45 of file SDL_test_common.h.

◆ DEFAULT_WINDOW_WIDTH

#define DEFAULT_WINDOW_WIDTH   640

Definition at line 44 of file SDL_test_common.h.

◆ VERBOSE_AUDIO

#define VERBOSE_AUDIO   0x00000010

Definition at line 52 of file SDL_test_common.h.

◆ VERBOSE_EVENT

#define VERBOSE_EVENT   0x00000008

Definition at line 51 of file SDL_test_common.h.

◆ VERBOSE_MODES

#define VERBOSE_MODES   0x00000002

Definition at line 49 of file SDL_test_common.h.

◆ VERBOSE_MOTION

#define VERBOSE_MOTION   0x00000020

Definition at line 53 of file SDL_test_common.h.

◆ VERBOSE_RENDER

#define VERBOSE_RENDER   0x00000004

Definition at line 50 of file SDL_test_common.h.

◆ VERBOSE_VIDEO

#define VERBOSE_VIDEO   0x00000001

Definition at line 48 of file SDL_test_common.h.

Function Documentation

◆ SDLTest_CommonArg()

int SDLTest_CommonArg ( SDLTest_CommonState state,
int  index 
)

Process one common argument.

Parameters
stateThe common state describing the test window to create.
indexThe index of the argument to process in argv[].
Returns
the number of arguments processed (i.e. 1 for –fullscreen, 2 for –video [videodriver], or -1 on error.

◆ SDLTest_CommonCreateState()

SDLTest_CommonState * SDLTest_CommonCreateState ( char **  argv,
Uint32  flags 
)

Parse command line parameters and create common state.

Parameters
argvArray of command line parameters
flagsFlags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
Returns
a newly allocated common state object.

◆ SDLTest_CommonDefaultArgs()

SDL_bool SDLTest_CommonDefaultArgs ( SDLTest_CommonState state,
const int  argc,
char **  argv 
)

Easy argument handling when test app doesn't need any custom args.

Parameters
stateThe common state describing the test window to create.
argcargc, as supplied to SDL_main
argvargv, as supplied to SDL_main
Returns
SDL_FALSE if app should quit, true otherwise.

◆ SDLTest_CommonDestroyState()

void SDLTest_CommonDestroyState ( SDLTest_CommonState state)

Free the common state object.

Parameters
stateThe common state object to destroy

◆ SDLTest_CommonDrawWindowInfo()

void SDLTest_CommonDrawWindowInfo ( SDL_Renderer renderer,
SDL_Window window,
float *  usedHeight 
)

Draws various window information (position, size, etc.) to the renderer.

Parameters
rendererThe renderer to draw to.
windowThe window whose information should be displayed.
usedHeightReturns the height used, so the caller can draw more below.

◆ SDLTest_CommonEvent()

void SDLTest_CommonEvent ( SDLTest_CommonState state,
SDL_Event event,
int *  done 
)

Common event handler for test windows if you use a standard SDL_main.

This will free data from the event, like the string in a drop event!

Parameters
stateThe common state used to create test window.
eventThe event to handle.
doneFlag indicating we are done.

◆ SDLTest_CommonEventMainCallbacks()

int SDLTest_CommonEventMainCallbacks ( SDLTest_CommonState state,
const SDL_Event event 
)

Common event handler for test windows if you use SDL_AppEvent.

This does not free anything in event.

Parameters
stateThe common state used to create test window.
eventThe event to handle.
Returns
Value suitable for returning from SDL_AppEvent().

◆ SDLTest_CommonInit()

SDL_bool SDLTest_CommonInit ( SDLTest_CommonState state)

Open test window.

Parameters
stateThe common state describing the test window to create.
Returns
SDL_TRUE if initialization succeeded, false otherwise

◆ SDLTest_CommonLogUsage()

void SDLTest_CommonLogUsage ( SDLTest_CommonState state,
const char *  argv0,
const char **  options 
)

Logs command line usage info.

This logs the appropriate command line options for the subsystems in use plus other common options, and then any application-specific options. This uses the SDL_Log() function and splits up output to be friendly to 80-character-wide terminals.

Parameters
stateThe common state describing the test window for the app.
argv0argv[0], as passed to main/SDL_main.
optionsan array of strings for application specific options. The last element of the array should be NULL.

◆ SDLTest_CommonQuit()

void SDLTest_CommonQuit ( SDLTest_CommonState state)

Close test window.

Parameters
stateThe common state used to create test window.