zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_test_common.c File Reference
#include "SDL_config.h"
#include "SDL_test.h"
#include <stdio.h>

Go to the source code of this file.

Macros

#define AUDIO_USAGE   "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
 
#define VIDEO_USAGE   "[--video driver] [--renderer driver] [--gldebug] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --fullscreen-desktop | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--min-geometry WxH] [--max-geometry WxH] [--logical WxH] [--scale N] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--allow-hidpi]"
 

Functions

static void FullscreenTo (int index, int windowId)
 
int SDLTest_CommonArg (SDLTest_CommonState *state, int index)
 Process one common argument. More...
 
SDLTest_CommonStateSDLTest_CommonCreateState (char **argv, Uint32 flags)
 Parse command line parameters and create common state. More...
 
void SDLTest_CommonEvent (SDLTest_CommonState *state, SDL_Event *event, int *done)
 Common event handler for test windows. More...
 
SDL_bool SDLTest_CommonInit (SDLTest_CommonState *state)
 Open test window. More...
 
void SDLTest_CommonQuit (SDLTest_CommonState *state)
 Close test window. More...
 
const char * SDLTest_CommonUsage (SDLTest_CommonState *state)
 Returns common usage information. More...
 
static SDL_SurfaceSDLTest_LoadIcon (const char *file)
 
static void SDLTest_PrintEvent (SDL_Event *event)
 
static void SDLTest_PrintPixelFormat (Uint32 format)
 
static void SDLTest_PrintRenderer (SDL_RendererInfo *info)
 
static void SDLTest_PrintRendererFlag (Uint32 flag)
 
static void SDLTest_ScreenShot (SDL_Renderer *renderer)
 

Macro Definition Documentation

#define AUDIO_USAGE   "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"

Definition at line 32 of file SDL_test_common.c.

Referenced by SDLTest_CommonUsage().

#define VIDEO_USAGE   "[--video driver] [--renderer driver] [--gldebug] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --fullscreen-desktop | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--min-geometry WxH] [--max-geometry WxH] [--logical WxH] [--scale N] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--allow-hidpi]"

Definition at line 29 of file SDL_test_common.c.

Referenced by SDLTest_CommonUsage().

Function Documentation

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.

Definition at line 83 of file SDL_test_common.c.

References SDLTest_CommonState::argv, AUDIO_S16, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S8, AUDIO_U16, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, SDLTest_CommonState::audiospec, SDL_AudioSpec::channels, SDLTest_CommonState::depth, SDLTest_CommonState::display, SDL_AudioSpec::format, SDL_AudioSpec::freq, SDLTest_CommonState::gl_debug, SDLTest_CommonState::logical_h, SDLTest_CommonState::logical_w, SDLTest_CommonState::num_windows, SDLTest_CommonState::refresh_rate, SDLTest_CommonState::render_flags, SDLTest_CommonState::renderdriver, SDL_AudioSpec::samples, SDLTest_CommonState::scale, SDL_atof(), SDL_atoi(), SDL_isdigit(), SDL_LOG_CATEGORY_AUDIO, SDL_LOG_CATEGORY_ERROR, SDL_LOG_CATEGORY_INPUT, SDL_LOG_CATEGORY_RENDER, SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_CATEGORY_VIDEO, SDL_LOG_PRIORITY_VERBOSE, SDL_LogSetAllPriority(), SDL_LogSetPriority(), SDL_RENDERER_PRESENTVSYNC, SDL_strcasecmp(), SDL_strcmp(), SDL_WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_BORDERLESS, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP, SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_RESIZABLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED_DISPLAY, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_WINDOWPOS_UNDEFINED_DISPLAY, SDLTest_CommonState::verbose, VERBOSE_EVENT, VERBOSE_MODES, VERBOSE_RENDER, VERBOSE_VIDEO, SDLTest_CommonState::videodriver, SDLTest_CommonState::window_flags, SDLTest_CommonState::window_h, SDLTest_CommonState::window_icon, SDLTest_CommonState::window_maxH, SDLTest_CommonState::window_maxW, SDLTest_CommonState::window_minH, SDLTest_CommonState::window_minW, SDLTest_CommonState::window_title, SDLTest_CommonState::window_w, SDLTest_CommonState::window_x, and SDLTest_CommonState::window_y.

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
Returns a newly allocated common state object.

Definition at line 36 of file SDL_test_common.c.

References SDLTest_CommonState::argv, AUDIO_S16, SDLTest_CommonState::audiospec, SDL_AudioSpec::channels, DEFAULT_WINDOW_HEIGHT, DEFAULT_WINDOW_WIDTH, SDLTest_CommonState::flags, SDL_AudioSpec::format, SDL_AudioSpec::freq, SDLTest_CommonState::gl_accelerated, SDLTest_CommonState::gl_accum_alpha_size, SDLTest_CommonState::gl_accum_blue_size, SDLTest_CommonState::gl_accum_green_size, SDLTest_CommonState::gl_accum_red_size, SDLTest_CommonState::gl_alpha_size, SDLTest_CommonState::gl_blue_size, SDLTest_CommonState::gl_buffer_size, SDLTest_CommonState::gl_debug, SDLTest_CommonState::gl_depth_size, SDLTest_CommonState::gl_double_buffer, SDLTest_CommonState::gl_green_size, SDLTest_CommonState::gl_multisamplebuffers, SDLTest_CommonState::gl_multisamplesamples, SDLTest_CommonState::gl_red_size, SDLTest_CommonState::gl_retained_backing, SDLTest_CommonState::gl_stencil_size, SDLTest_CommonState::gl_stereo, NULL, SDLTest_CommonState::num_windows, SDL_AudioSpec::samples, SDL_calloc(), SDL_OutOfMemory, SDL_WINDOWPOS_UNDEFINED, SDLTest_CommonState::window_flags, SDLTest_CommonState::window_h, SDLTest_CommonState::window_title, SDLTest_CommonState::window_w, SDLTest_CommonState::window_x, and SDLTest_CommonState::window_y.

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

Common event handler for test windows.

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

Definition at line 1186 of file SDL_test_common.c.

References SDL_WindowEvent::event, FullscreenTo(), SDL_Rect::h, i, SDL_Event::key, SDL_KeyboardEvent::keysym, KMOD_ALT, KMOD_CTRL, SDL_Keysym::mod, NULL, SDLTest_CommonState::num_windows, SDLTest_CommonState::renderers, SDL_DestroyWindow(), SDL_FALSE, SDL_free(), SDL_GetClipboardText(), SDL_GetRelativeMouseMode(), SDL_GetWindowFlags(), SDL_GetWindowFromID(), SDL_GetWindowGrab(), SDL_GetWindowSize(), SDL_KEYDOWN, SDL_MaximizeWindow(), SDL_MESSAGEBOX_INFORMATION, SDL_MinimizeWindow(), SDL_MOUSEMOTION, SDL_QUIT, SDL_RectEmpty(), SDL_RenderGetClipRect(), SDL_RenderSetClipRect(), SDL_RestoreWindow(), SDL_SetClipboardText(), SDL_SetRelativeMouseMode(), SDL_SetWindowBordered(), SDL_SetWindowFullscreen(), SDL_SetWindowGrab(), SDL_SetWindowSize(), SDL_ShowSimpleMessageBox(), SDL_snprintf(), SDL_TRUE, SDL_WINDOW_BORDERLESS, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP, SDL_WINDOW_MAXIMIZED, SDL_WINDOWEVENT, SDL_WINDOWEVENT_CLOSE, SDLK_0, SDLK_1, SDLK_2, SDLK_b, SDLK_c, SDLK_EQUALS, SDLK_ESCAPE, SDLK_g, SDLK_m, SDLK_MINUS, SDLK_PRINTSCREEN, SDLK_r, SDLK_RETURN, SDLK_SPACE, SDLK_v, SDLK_z, SDLTest_PrintEvent(), SDLTest_ScreenShot(), SDL_Keysym::sym, SDL_Event::type, SDLTest_CommonState::verbose, VERBOSE_EVENT, SDL_Rect::w, SDL_Event::window, SDL_WindowEvent::windowID, SDL_KeyboardEvent::windowID, SDLTest_CommonState::windows, SDL_Rect::x, SDL_MouseMotionEvent::x, SDL_MouseMotionEvent::xrel, SDL_Rect::y, SDL_MouseMotionEvent::y, and SDL_MouseMotionEvent::yrel.

SDL_bool SDLTest_CommonInit ( SDLTest_CommonState state)

Open test window.

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

Definition at line 639 of file SDL_test_common.c.

References SDLTest_CommonState::audiodriver, SDLTest_CommonState::audiospec, SDLTest_CommonState::depth, SDLTest_CommonState::flags, SDL_DisplayMode::format, SDLTest_CommonState::gl_accelerated, SDLTest_CommonState::gl_accum_alpha_size, SDLTest_CommonState::gl_accum_blue_size, SDLTest_CommonState::gl_accum_green_size, SDLTest_CommonState::gl_accum_red_size, SDLTest_CommonState::gl_alpha_size, SDLTest_CommonState::gl_blue_size, SDLTest_CommonState::gl_buffer_size, SDLTest_CommonState::gl_debug, SDLTest_CommonState::gl_depth_size, SDLTest_CommonState::gl_double_buffer, SDLTest_CommonState::gl_green_size, SDLTest_CommonState::gl_major_version, SDLTest_CommonState::gl_minor_version, SDLTest_CommonState::gl_multisamplebuffers, SDLTest_CommonState::gl_multisamplesamples, SDLTest_CommonState::gl_red_size, SDLTest_CommonState::gl_retained_backing, SDLTest_CommonState::gl_stencil_size, SDLTest_CommonState::gl_stereo, SDL_DisplayMode::h, SDL_Rect::h, i, j, SDLTest_CommonState::logical_h, SDLTest_CommonState::logical_w, m, SDL_RendererInfo::name, NULL, SDLTest_CommonState::num_windows, SDL_DisplayMode::refresh_rate, SDLTest_CommonState::refresh_rate, SDLTest_CommonState::render_flags, SDLTest_CommonState::renderdriver, SDLTest_CommonState::renderers, SDLTest_CommonState::scale, SDL_arraysize, SDL_AudioInit(), SDL_CreateRenderer(), SDL_CreateWindow(), SDL_FALSE, SDL_FreeSurface(), SDL_GetAudioDriver(), SDL_GetCurrentAudioDriver(), SDL_GetCurrentVideoDriver(), SDL_GetDesktopDisplayMode(), SDL_GetDisplayBounds(), SDL_GetDisplayMode(), SDL_GetDisplayName(), SDL_GetError(), SDL_GetNumAudioDrivers(), SDL_GetNumDisplayModes(), SDL_GetNumRenderDrivers(), SDL_GetNumVideoDisplays(), SDL_GetNumVideoDrivers(), SDL_GetPixelFormatName(), SDL_GetRenderDriverInfo(), SDL_GetRendererInfo(), SDL_GetVideoDriver(), SDL_GetWindowSize(), SDL_GL_ACCELERATED_VISUAL, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_GREEN_SIZE, SDL_GL_ACCUM_RED_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_CONTEXT_DEBUG_FLAG, SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_MAJOR_VERSION, SDL_GL_CONTEXT_MINOR_VERSION, SDL_GL_DEPTH_SIZE, SDL_GL_DOUBLEBUFFER, SDL_GL_GREEN_SIZE, SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES, SDL_GL_RED_SIZE, SDL_GL_RETAINED_BACKING, SDL_GL_SetAttribute(), SDL_GL_STENCIL_SIZE, SDL_GL_STEREO, SDL_INIT_AUDIO, SDL_INIT_VIDEO, SDL_malloc(), SDL_OpenAudio(), SDL_PIXELFORMAT_INDEX8, SDL_PIXELFORMAT_RGB24, SDL_PIXELFORMAT_RGB555, SDL_PIXELFORMAT_RGB565, SDL_PIXELFORMAT_RGB888, SDL_PixelFormatEnumToMasks(), SDL_RenderSetLogicalSize(), SDL_RenderSetScale(), SDL_SetWindowDisplayMode(), SDL_SetWindowIcon(), SDL_SetWindowMaximumSize(), SDL_SetWindowMinimumSize(), SDL_ShowWindow(), SDL_snprintf(), SDL_strcasecmp(), SDL_strlcpy(), SDL_TRUE, SDL_VideoInit(), SDL_WINDOW_OPENGL, SDL_WINDOW_RESIZABLE, SDL_zero, SDLTest_LoadIcon(), SDLTest_PrintRenderer(), SDLTest_CommonState::skip_renderer, SDLTest_CommonState::verbose, VERBOSE_AUDIO, VERBOSE_MODES, VERBOSE_RENDER, VERBOSE_VIDEO, SDLTest_CommonState::videodriver, SDL_DisplayMode::w, SDL_Rect::w, SDLTest_CommonState::window_flags, SDLTest_CommonState::window_h, SDLTest_CommonState::window_icon, SDLTest_CommonState::window_maxH, SDLTest_CommonState::window_maxW, SDLTest_CommonState::window_minH, SDLTest_CommonState::window_minW, SDLTest_CommonState::window_title, SDLTest_CommonState::window_w, SDLTest_CommonState::window_x, SDLTest_CommonState::window_y, SDLTest_CommonState::windows, SDL_Rect::x, and SDL_Rect::y.

void SDLTest_CommonQuit ( SDLTest_CommonState state)
const char* SDLTest_CommonUsage ( SDLTest_CommonState state)

Returns common usage information.

Parameters
stateThe common state describing the test window to create.
Returns
String with usage information

Definition at line 451 of file SDL_test_common.c.

References AUDIO_USAGE, SDLTest_CommonState::flags, SDL_INIT_AUDIO, SDL_INIT_VIDEO, and VIDEO_USAGE.

static SDL_Surface* SDLTest_LoadIcon ( const char *  file)
static
static void SDLTest_PrintEvent ( SDL_Event event)
static

Definition at line 943 of file SDL_test_common.c.

References SDL_JoyBallEvent::ball, SDL_MouseButtonEvent::button, SDL_JoyButtonEvent::button, SDL_Event::button, SDL_UserEvent::code, SDL_WindowEvent::data1, SDL_WindowEvent::data2, SDL_TouchFingerEvent::dx, SDL_TouchFingerEvent::dy, SDL_WindowEvent::event, SDL_TouchFingerEvent::fingerId, SDL_JoyHatEvent::hat, SDL_Event::jball, SDL_Event::jbutton, SDL_Event::jhat, SDL_Event::key, SDL_KeyboardEvent::keysym, SDL_Event::motion, SDL_TouchFingerEvent::pressure, SDL_Keysym::scancode, SDL_CLIPBOARDUPDATE, SDL_FINGERDOWN, SDL_FINGERMOTION, SDL_FINGERUP, SDL_GetKeyName(), SDL_GetScancodeName(), SDL_HAT_CENTERED, SDL_HAT_DOWN, SDL_HAT_LEFT, SDL_HAT_LEFTDOWN, SDL_HAT_LEFTUP, SDL_HAT_RIGHT, SDL_HAT_RIGHTDOWN, SDL_HAT_RIGHTUP, SDL_HAT_UP, SDL_JOYBALLMOTION, SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYHATMOTION, SDL_KEYDOWN, SDL_KEYUP, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEMOTION, SDL_MOUSEWHEEL, SDL_QUIT, SDL_TEXTINPUT, SDL_USEREVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT_CLOSE, SDL_WINDOWEVENT_ENTER, SDL_WINDOWEVENT_EXPOSED, SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_HIDDEN, SDL_WINDOWEVENT_LEAVE, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_MINIMIZED, SDL_WINDOWEVENT_MOVED, SDL_WINDOWEVENT_RESIZED, SDL_WINDOWEVENT_RESTORED, SDL_WINDOWEVENT_SHOWN, SDL_WINDOWEVENT_SIZE_CHANGED, SDL_Keysym::sym, SDL_TextInputEvent::text, SDL_Event::text, SDL_Event::tfinger, SDL_TouchFingerEvent::touchId, SDL_Event::type, SDL_Event::user, SDL_JoyHatEvent::value, SDL_Event::wheel, SDL_JoyBallEvent::which, SDL_JoyHatEvent::which, SDL_JoyButtonEvent::which, SDL_Event::window, SDL_WindowEvent::windowID, SDL_KeyboardEvent::windowID, SDL_TextInputEvent::windowID, SDL_MouseMotionEvent::windowID, SDL_MouseButtonEvent::windowID, SDL_MouseWheelEvent::windowID, SDL_MouseMotionEvent::x, SDL_MouseButtonEvent::x, SDL_MouseWheelEvent::x, SDL_TouchFingerEvent::x, SDL_MouseMotionEvent::xrel, SDL_JoyBallEvent::xrel, SDL_MouseMotionEvent::y, SDL_MouseButtonEvent::y, SDL_MouseWheelEvent::y, SDL_TouchFingerEvent::y, SDL_MouseMotionEvent::yrel, and SDL_JoyBallEvent::yrel.

Referenced by SDLTest_CommonEvent().

static void SDLTest_PrintRendererFlag ( Uint32  flag)
static

Definition at line 466 of file SDL_test_common.c.

References SDL_RENDERER_ACCELERATED, and SDL_RENDERER_PRESENTVSYNC.

Referenced by SDLTest_PrintRenderer().