include/SDL_test_common.h
changeset 6727 1b5280cd5885
child 6788 036f53f2f5aa
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/SDL_test_common.h	Sun Dec 09 17:56:19 2012 -0800
     1.3 @@ -0,0 +1,182 @@
     1.4 +/*
     1.5 +  Simple DirectMedia Layer
     1.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     1.7 +
     1.8 +  This software is provided 'as-is', without any express or implied
     1.9 +  warranty.  In no event will the authors be held liable for any damages
    1.10 +  arising from the use of this software.
    1.11 +
    1.12 +  Permission is granted to anyone to use this software for any purpose,
    1.13 +  including commercial applications, and to alter it and redistribute it
    1.14 +  freely, subject to the following restrictions:
    1.15 +
    1.16 +  1. The origin of this software must not be misrepresented; you must not
    1.17 +     claim that you wrote the original software. If you use this software
    1.18 +     in a product, an acknowledgment in the product documentation would be
    1.19 +     appreciated but is not required.
    1.20 +  2. Altered source versions must be plainly marked as such, and must not be
    1.21 +     misrepresented as being the original software.
    1.22 +  3. This notice may not be removed or altered from any source distribution.
    1.23 +*/
    1.24 +
    1.25 +/**
    1.26 + *  \file SDL_test_common.h
    1.27 + *  
    1.28 + *  Include file for SDL test framework.
    1.29 + *
    1.30 + *  This code is a part of the SDL2_test library, not the main SDL library.
    1.31 + */
    1.32 +
    1.33 +/* Ported from original test\common.h file. */
    1.34 +
    1.35 +#ifndef _SDL_test_common_h
    1.36 +#define _SDL_test_common_h
    1.37 +
    1.38 +#include "SDL.h"
    1.39 +
    1.40 +#ifdef __NDS__
    1.41 +#define DEFAULT_WINDOW_WIDTH  256
    1.42 +#define DEFAULT_WINDOW_HEIGHT (2*192)
    1.43 +#else
    1.44 +#define DEFAULT_WINDOW_WIDTH  640
    1.45 +#define DEFAULT_WINDOW_HEIGHT 480
    1.46 +#endif
    1.47 +
    1.48 +#define VERBOSE_VIDEO   0x00000001
    1.49 +#define VERBOSE_MODES   0x00000002
    1.50 +#define VERBOSE_RENDER  0x00000004
    1.51 +#define VERBOSE_EVENT   0x00000008
    1.52 +#define VERBOSE_AUDIO   0x00000010
    1.53 +
    1.54 +typedef struct
    1.55 +{
    1.56 +    /* SDL init flags */
    1.57 +    char **argv;
    1.58 +    Uint32 flags;
    1.59 +    Uint32 verbose;
    1.60 +
    1.61 +    /* Video info */
    1.62 +    const char *videodriver;
    1.63 +    int display;
    1.64 +    const char *window_title;
    1.65 +    const char *window_icon;
    1.66 +    Uint32 window_flags;
    1.67 +    int window_x;
    1.68 +    int window_y;
    1.69 +    int window_w;
    1.70 +    int window_h;
    1.71 +    int depth;
    1.72 +    int refresh_rate;
    1.73 +    int num_windows;
    1.74 +    SDL_Window **windows;
    1.75 +
    1.76 +    /* Renderer info */
    1.77 +    const char *renderdriver;
    1.78 +    Uint32 render_flags;
    1.79 +    SDL_bool skip_renderer;
    1.80 +    SDL_Renderer **renderers;
    1.81 +
    1.82 +    /* Audio info */
    1.83 +    const char *audiodriver;
    1.84 +    SDL_AudioSpec audiospec;
    1.85 +
    1.86 +    /* GL settings */
    1.87 +    int gl_red_size;
    1.88 +    int gl_green_size;
    1.89 +    int gl_blue_size;
    1.90 +    int gl_alpha_size;
    1.91 +    int gl_buffer_size;
    1.92 +    int gl_depth_size;
    1.93 +    int gl_stencil_size;
    1.94 +    int gl_double_buffer;
    1.95 +    int gl_accum_red_size;
    1.96 +    int gl_accum_green_size;
    1.97 +    int gl_accum_blue_size;
    1.98 +    int gl_accum_alpha_size;
    1.99 +    int gl_stereo;
   1.100 +    int gl_multisamplebuffers;
   1.101 +    int gl_multisamplesamples;
   1.102 +    int gl_retained_backing;
   1.103 +    int gl_accelerated;
   1.104 +    int gl_major_version;
   1.105 +    int gl_minor_version;
   1.106 +} SDLTest_CommonState;
   1.107 +
   1.108 +#include "begin_code.h"
   1.109 +/* Set up for C function definitions, even when using C++ */
   1.110 +#ifdef __cplusplus
   1.111 +/* *INDENT-OFF* */
   1.112 +extern "C" {
   1.113 +/* *INDENT-ON* */
   1.114 +#endif
   1.115 +
   1.116 +/* Function prototypes */
   1.117 +
   1.118 +/**
   1.119 + * \brief Parse command line parameters and create common state.
   1.120 + *
   1.121 + * \param argv Array of command line parameters
   1.122 + * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
   1.123 + *
   1.124 + * \returns Returns a newly allocated common state object.
   1.125 + */
   1.126 +SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
   1.127 +
   1.128 +/**
   1.129 + * \brief Process one common argument.
   1.130 + *
   1.131 + * \param state The common state describing the test window to create.
   1.132 + * \param index The index of the argument to process in argv[].
   1.133 + *
   1.134 + * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
   1.135 + */
   1.136 +int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
   1.137 +
   1.138 +/**
   1.139 + * \brief Returns common usage information
   1.140 + *
   1.141 + * \param state The common state describing the test window to create.
   1.142 + *
   1.143 + * \returns String with usage information
   1.144 + */
   1.145 +const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
   1.146 +
   1.147 +/**
   1.148 + * \brief Open test window.
   1.149 + *
   1.150 + * \param state The common state describing the test window to create.
   1.151 + *
   1.152 + * \returns True if initialization succeeded, false otherwise
   1.153 + */
   1.154 +SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
   1.155 +
   1.156 +/**
   1.157 + * \brief Common event handler for test windows.
   1.158 + *
   1.159 + * \param state The common state used to create test window.
   1.160 + * \param event The event to handle.
   1.161 + * \param done Flag indicating we are done.
   1.162 + *
   1.163 + */
   1.164 +void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
   1.165 +
   1.166 +/**
   1.167 + * \brief Close test window.
   1.168 + *
   1.169 + * \param state The common state used to create test window.
   1.170 + *
   1.171 + */
   1.172 +void SDLTest_CommonQuit(SDLTest_CommonState * state);
   1.173 +
   1.174 +
   1.175 +/* Ends C function definitions when using C++ */
   1.176 +#ifdef __cplusplus
   1.177 +/* *INDENT-OFF* */
   1.178 +}
   1.179 +/* *INDENT-ON* */
   1.180 +#endif
   1.181 +#include "close_code.h"
   1.182 +
   1.183 +#endif /* _SDL_test_common_h */
   1.184 +
   1.185 +/* vi: set ts=4 sw=4 expandtab: */