SDL standard library

Dependents:   H261_encoder

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SDL_test_common.h Source File

SDL_test_common.h

Go to the documentation of this file.
00001 /*
00002   Simple DirectMedia Layer
00003   Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
00004 
00005   This software is provided 'as-is', without any express or implied
00006   warranty.  In no event will the authors be held liable for any damages
00007   arising from the use of this software.
00008 
00009   Permission is granted to anyone to use this software for any purpose,
00010   including commercial applications, and to alter it and redistribute it
00011   freely, subject to the following restrictions:
00012 
00013   1. The origin of this software must not be misrepresented; you must not
00014      claim that you wrote the original software. If you use this software
00015      in a product, an acknowledgment in the product documentation would be
00016      appreciated but is not required.
00017   2. Altered source versions must be plainly marked as such, and must not be
00018      misrepresented as being the original software.
00019   3. This notice may not be removed or altered from any source distribution.
00020 */
00021 
00022 /**
00023  *  \file SDL_test_common.h
00024  *
00025  *  Include file for SDL test framework.
00026  *
00027  *  This code is a part of the SDL2_test library, not the main SDL library.
00028  */
00029 
00030 /* Ported from original test\common.h file. */
00031 
00032 #ifndef _SDL_test_common_h
00033 #define _SDL_test_common_h
00034 
00035 #include "SDL.h"
00036 
00037 #if defined(__PSP__)
00038 #define DEFAULT_WINDOW_WIDTH  480
00039 #define DEFAULT_WINDOW_HEIGHT 272
00040 #else
00041 #define DEFAULT_WINDOW_WIDTH  640
00042 #define DEFAULT_WINDOW_HEIGHT 480
00043 #endif
00044 
00045 #define VERBOSE_VIDEO   0x00000001
00046 #define VERBOSE_MODES   0x00000002
00047 #define VERBOSE_RENDER  0x00000004
00048 #define VERBOSE_EVENT   0x00000008
00049 #define VERBOSE_AUDIO   0x00000010
00050 
00051 typedef struct
00052 {
00053     /* SDL init flags */
00054     char **argv;
00055     Uint32 flags;
00056     Uint32 verbose;
00057 
00058     /* Video info */
00059     const char *videodriver;
00060     int display;
00061     const char *window_title;
00062     const char *window_icon;
00063     Uint32 window_flags;
00064     int window_x;
00065     int window_y;
00066     int window_w;
00067     int window_h;
00068     int window_minW;
00069     int window_minH;
00070     int window_maxW;
00071     int window_maxH;
00072     int logical_w;
00073     int logical_h;
00074     float scale;
00075     int depth;
00076     int refresh_rate;
00077     int num_windows;
00078     SDL_Window **windows;
00079 
00080     /* Renderer info */
00081     const char *renderdriver;
00082     Uint32 render_flags;
00083     SDL_bool skip_renderer;
00084     SDL_Renderer **renderers;
00085     SDL_Texture **targets;
00086 
00087     /* Audio info */
00088     const char *audiodriver;
00089     SDL_AudioSpec audiospec;
00090 
00091     /* GL settings */
00092     int gl_red_size;
00093     int gl_green_size;
00094     int gl_blue_size;
00095     int gl_alpha_size;
00096     int gl_buffer_size;
00097     int gl_depth_size;
00098     int gl_stencil_size;
00099     int gl_double_buffer;
00100     int gl_accum_red_size;
00101     int gl_accum_green_size;
00102     int gl_accum_blue_size;
00103     int gl_accum_alpha_size;
00104     int gl_stereo;
00105     int gl_multisamplebuffers;
00106     int gl_multisamplesamples;
00107     int gl_retained_backing;
00108     int gl_accelerated;
00109     int gl_major_version;
00110     int gl_minor_version;
00111     int gl_debug;
00112     int gl_profile_mask;
00113 } SDLTest_CommonState;
00114 
00115 #include "begin_code.h"
00116 /* Set up for C function definitions, even when using C++ */
00117 #ifdef __cplusplus
00118 extern "C" {
00119 #endif
00120 
00121 /* Function prototypes */
00122 
00123 /**
00124  * \brief Parse command line parameters and create common state.
00125  *
00126  * \param argv Array of command line parameters
00127  * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
00128  *
00129  * \returns Returns a newly allocated common state object.
00130  */
00131 SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
00132 
00133 /**
00134  * \brief Process one common argument.
00135  *
00136  * \param state The common state describing the test window to create.
00137  * \param index The index of the argument to process in argv[].
00138  *
00139  * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
00140  */
00141 int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
00142 
00143 /**
00144  * \brief Returns common usage information
00145  *
00146  * \param state The common state describing the test window to create.
00147  *
00148  * \returns String with usage information
00149  */
00150 const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
00151 
00152 /**
00153  * \brief Open test window.
00154  *
00155  * \param state The common state describing the test window to create.
00156  *
00157  * \returns True if initialization succeeded, false otherwise
00158  */
00159 SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
00160 
00161 /**
00162  * \brief Common event handler for test windows.
00163  *
00164  * \param state The common state used to create test window.
00165  * \param event The event to handle.
00166  * \param done Flag indicating we are done.
00167  *
00168  */
00169 void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
00170 
00171 /**
00172  * \brief Close test window.
00173  *
00174  * \param state The common state used to create test window.
00175  *
00176  */
00177 void SDLTest_CommonQuit(SDLTest_CommonState * state);
00178 
00179 
00180 /* Ends C function definitions when using C++ */
00181 #ifdef __cplusplus
00182 }
00183 #endif
00184 #include "close_code.h"
00185 
00186 #endif /* _SDL_test_common_h */
00187 
00188 /* vi: set ts=4 sw=4 expandtab: */