SDL Library
SDL_test_common.h@0:7fb6877b5d7c, 2016-09-22 (annotated)
- Committer:
- miruga27
- Date:
- Thu Sep 22 00:03:09 2016 +0000
- Revision:
- 0:7fb6877b5d7c
SDL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:7fb6877b5d7c | 1 | /* |
miruga27 | 0:7fb6877b5d7c | 2 | Simple DirectMedia Layer |
miruga27 | 0:7fb6877b5d7c | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:7fb6877b5d7c | 4 | |
miruga27 | 0:7fb6877b5d7c | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:7fb6877b5d7c | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:7fb6877b5d7c | 7 | arising from the use of this software. |
miruga27 | 0:7fb6877b5d7c | 8 | |
miruga27 | 0:7fb6877b5d7c | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:7fb6877b5d7c | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:7fb6877b5d7c | 11 | freely, subject to the following restrictions: |
miruga27 | 0:7fb6877b5d7c | 12 | |
miruga27 | 0:7fb6877b5d7c | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:7fb6877b5d7c | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:7fb6877b5d7c | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:7fb6877b5d7c | 16 | appreciated but is not required. |
miruga27 | 0:7fb6877b5d7c | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:7fb6877b5d7c | 18 | misrepresented as being the original software. |
miruga27 | 0:7fb6877b5d7c | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:7fb6877b5d7c | 20 | */ |
miruga27 | 0:7fb6877b5d7c | 21 | |
miruga27 | 0:7fb6877b5d7c | 22 | /** |
miruga27 | 0:7fb6877b5d7c | 23 | * \file SDL_test_common.h |
miruga27 | 0:7fb6877b5d7c | 24 | * |
miruga27 | 0:7fb6877b5d7c | 25 | * Include file for SDL test framework. |
miruga27 | 0:7fb6877b5d7c | 26 | * |
miruga27 | 0:7fb6877b5d7c | 27 | * This code is a part of the SDL2_test library, not the main SDL library. |
miruga27 | 0:7fb6877b5d7c | 28 | */ |
miruga27 | 0:7fb6877b5d7c | 29 | |
miruga27 | 0:7fb6877b5d7c | 30 | /* Ported from original test\common.h file. */ |
miruga27 | 0:7fb6877b5d7c | 31 | |
miruga27 | 0:7fb6877b5d7c | 32 | #ifndef _SDL_test_common_h |
miruga27 | 0:7fb6877b5d7c | 33 | #define _SDL_test_common_h |
miruga27 | 0:7fb6877b5d7c | 34 | |
miruga27 | 0:7fb6877b5d7c | 35 | #include "SDL.h" |
miruga27 | 0:7fb6877b5d7c | 36 | |
miruga27 | 0:7fb6877b5d7c | 37 | #if defined(__PSP__) |
miruga27 | 0:7fb6877b5d7c | 38 | #define DEFAULT_WINDOW_WIDTH 480 |
miruga27 | 0:7fb6877b5d7c | 39 | #define DEFAULT_WINDOW_HEIGHT 272 |
miruga27 | 0:7fb6877b5d7c | 40 | #else |
miruga27 | 0:7fb6877b5d7c | 41 | #define DEFAULT_WINDOW_WIDTH 640 |
miruga27 | 0:7fb6877b5d7c | 42 | #define DEFAULT_WINDOW_HEIGHT 480 |
miruga27 | 0:7fb6877b5d7c | 43 | #endif |
miruga27 | 0:7fb6877b5d7c | 44 | |
miruga27 | 0:7fb6877b5d7c | 45 | #define VERBOSE_VIDEO 0x00000001 |
miruga27 | 0:7fb6877b5d7c | 46 | #define VERBOSE_MODES 0x00000002 |
miruga27 | 0:7fb6877b5d7c | 47 | #define VERBOSE_RENDER 0x00000004 |
miruga27 | 0:7fb6877b5d7c | 48 | #define VERBOSE_EVENT 0x00000008 |
miruga27 | 0:7fb6877b5d7c | 49 | #define VERBOSE_AUDIO 0x00000010 |
miruga27 | 0:7fb6877b5d7c | 50 | |
miruga27 | 0:7fb6877b5d7c | 51 | typedef struct |
miruga27 | 0:7fb6877b5d7c | 52 | { |
miruga27 | 0:7fb6877b5d7c | 53 | /* SDL init flags */ |
miruga27 | 0:7fb6877b5d7c | 54 | char **argv; |
miruga27 | 0:7fb6877b5d7c | 55 | Uint32 flags; |
miruga27 | 0:7fb6877b5d7c | 56 | Uint32 verbose; |
miruga27 | 0:7fb6877b5d7c | 57 | |
miruga27 | 0:7fb6877b5d7c | 58 | /* Video info */ |
miruga27 | 0:7fb6877b5d7c | 59 | const char *videodriver; |
miruga27 | 0:7fb6877b5d7c | 60 | int display; |
miruga27 | 0:7fb6877b5d7c | 61 | const char *window_title; |
miruga27 | 0:7fb6877b5d7c | 62 | const char *window_icon; |
miruga27 | 0:7fb6877b5d7c | 63 | Uint32 window_flags; |
miruga27 | 0:7fb6877b5d7c | 64 | int window_x; |
miruga27 | 0:7fb6877b5d7c | 65 | int window_y; |
miruga27 | 0:7fb6877b5d7c | 66 | int window_w; |
miruga27 | 0:7fb6877b5d7c | 67 | int window_h; |
miruga27 | 0:7fb6877b5d7c | 68 | int window_minW; |
miruga27 | 0:7fb6877b5d7c | 69 | int window_minH; |
miruga27 | 0:7fb6877b5d7c | 70 | int window_maxW; |
miruga27 | 0:7fb6877b5d7c | 71 | int window_maxH; |
miruga27 | 0:7fb6877b5d7c | 72 | int logical_w; |
miruga27 | 0:7fb6877b5d7c | 73 | int logical_h; |
miruga27 | 0:7fb6877b5d7c | 74 | float scale; |
miruga27 | 0:7fb6877b5d7c | 75 | int depth; |
miruga27 | 0:7fb6877b5d7c | 76 | int refresh_rate; |
miruga27 | 0:7fb6877b5d7c | 77 | int num_windows; |
miruga27 | 0:7fb6877b5d7c | 78 | SDL_Window **windows; |
miruga27 | 0:7fb6877b5d7c | 79 | |
miruga27 | 0:7fb6877b5d7c | 80 | /* Renderer info */ |
miruga27 | 0:7fb6877b5d7c | 81 | const char *renderdriver; |
miruga27 | 0:7fb6877b5d7c | 82 | Uint32 render_flags; |
miruga27 | 0:7fb6877b5d7c | 83 | SDL_bool skip_renderer; |
miruga27 | 0:7fb6877b5d7c | 84 | SDL_Renderer **renderers; |
miruga27 | 0:7fb6877b5d7c | 85 | SDL_Texture **targets; |
miruga27 | 0:7fb6877b5d7c | 86 | |
miruga27 | 0:7fb6877b5d7c | 87 | /* Audio info */ |
miruga27 | 0:7fb6877b5d7c | 88 | const char *audiodriver; |
miruga27 | 0:7fb6877b5d7c | 89 | SDL_AudioSpec audiospec; |
miruga27 | 0:7fb6877b5d7c | 90 | |
miruga27 | 0:7fb6877b5d7c | 91 | /* GL settings */ |
miruga27 | 0:7fb6877b5d7c | 92 | int gl_red_size; |
miruga27 | 0:7fb6877b5d7c | 93 | int gl_green_size; |
miruga27 | 0:7fb6877b5d7c | 94 | int gl_blue_size; |
miruga27 | 0:7fb6877b5d7c | 95 | int gl_alpha_size; |
miruga27 | 0:7fb6877b5d7c | 96 | int gl_buffer_size; |
miruga27 | 0:7fb6877b5d7c | 97 | int gl_depth_size; |
miruga27 | 0:7fb6877b5d7c | 98 | int gl_stencil_size; |
miruga27 | 0:7fb6877b5d7c | 99 | int gl_double_buffer; |
miruga27 | 0:7fb6877b5d7c | 100 | int gl_accum_red_size; |
miruga27 | 0:7fb6877b5d7c | 101 | int gl_accum_green_size; |
miruga27 | 0:7fb6877b5d7c | 102 | int gl_accum_blue_size; |
miruga27 | 0:7fb6877b5d7c | 103 | int gl_accum_alpha_size; |
miruga27 | 0:7fb6877b5d7c | 104 | int gl_stereo; |
miruga27 | 0:7fb6877b5d7c | 105 | int gl_multisamplebuffers; |
miruga27 | 0:7fb6877b5d7c | 106 | int gl_multisamplesamples; |
miruga27 | 0:7fb6877b5d7c | 107 | int gl_retained_backing; |
miruga27 | 0:7fb6877b5d7c | 108 | int gl_accelerated; |
miruga27 | 0:7fb6877b5d7c | 109 | int gl_major_version; |
miruga27 | 0:7fb6877b5d7c | 110 | int gl_minor_version; |
miruga27 | 0:7fb6877b5d7c | 111 | int gl_debug; |
miruga27 | 0:7fb6877b5d7c | 112 | int gl_profile_mask; |
miruga27 | 0:7fb6877b5d7c | 113 | } SDLTest_CommonState; |
miruga27 | 0:7fb6877b5d7c | 114 | |
miruga27 | 0:7fb6877b5d7c | 115 | #include "begin_code.h" |
miruga27 | 0:7fb6877b5d7c | 116 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 117 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 118 | extern "C" { |
miruga27 | 0:7fb6877b5d7c | 119 | #endif |
miruga27 | 0:7fb6877b5d7c | 120 | |
miruga27 | 0:7fb6877b5d7c | 121 | /* Function prototypes */ |
miruga27 | 0:7fb6877b5d7c | 122 | |
miruga27 | 0:7fb6877b5d7c | 123 | /** |
miruga27 | 0:7fb6877b5d7c | 124 | * \brief Parse command line parameters and create common state. |
miruga27 | 0:7fb6877b5d7c | 125 | * |
miruga27 | 0:7fb6877b5d7c | 126 | * \param argv Array of command line parameters |
miruga27 | 0:7fb6877b5d7c | 127 | * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
miruga27 | 0:7fb6877b5d7c | 128 | * |
miruga27 | 0:7fb6877b5d7c | 129 | * \returns Returns a newly allocated common state object. |
miruga27 | 0:7fb6877b5d7c | 130 | */ |
miruga27 | 0:7fb6877b5d7c | 131 | SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); |
miruga27 | 0:7fb6877b5d7c | 132 | |
miruga27 | 0:7fb6877b5d7c | 133 | /** |
miruga27 | 0:7fb6877b5d7c | 134 | * \brief Process one common argument. |
miruga27 | 0:7fb6877b5d7c | 135 | * |
miruga27 | 0:7fb6877b5d7c | 136 | * \param state The common state describing the test window to create. |
miruga27 | 0:7fb6877b5d7c | 137 | * \param index The index of the argument to process in argv[]. |
miruga27 | 0:7fb6877b5d7c | 138 | * |
miruga27 | 0:7fb6877b5d7c | 139 | * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. |
miruga27 | 0:7fb6877b5d7c | 140 | */ |
miruga27 | 0:7fb6877b5d7c | 141 | int SDLTest_CommonArg(SDLTest_CommonState * state, int index); |
miruga27 | 0:7fb6877b5d7c | 142 | |
miruga27 | 0:7fb6877b5d7c | 143 | /** |
miruga27 | 0:7fb6877b5d7c | 144 | * \brief Returns common usage information |
miruga27 | 0:7fb6877b5d7c | 145 | * |
miruga27 | 0:7fb6877b5d7c | 146 | * \param state The common state describing the test window to create. |
miruga27 | 0:7fb6877b5d7c | 147 | * |
miruga27 | 0:7fb6877b5d7c | 148 | * \returns String with usage information |
miruga27 | 0:7fb6877b5d7c | 149 | */ |
miruga27 | 0:7fb6877b5d7c | 150 | const char *SDLTest_CommonUsage(SDLTest_CommonState * state); |
miruga27 | 0:7fb6877b5d7c | 151 | |
miruga27 | 0:7fb6877b5d7c | 152 | /** |
miruga27 | 0:7fb6877b5d7c | 153 | * \brief Open test window. |
miruga27 | 0:7fb6877b5d7c | 154 | * |
miruga27 | 0:7fb6877b5d7c | 155 | * \param state The common state describing the test window to create. |
miruga27 | 0:7fb6877b5d7c | 156 | * |
miruga27 | 0:7fb6877b5d7c | 157 | * \returns True if initialization succeeded, false otherwise |
miruga27 | 0:7fb6877b5d7c | 158 | */ |
miruga27 | 0:7fb6877b5d7c | 159 | SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); |
miruga27 | 0:7fb6877b5d7c | 160 | |
miruga27 | 0:7fb6877b5d7c | 161 | /** |
miruga27 | 0:7fb6877b5d7c | 162 | * \brief Common event handler for test windows. |
miruga27 | 0:7fb6877b5d7c | 163 | * |
miruga27 | 0:7fb6877b5d7c | 164 | * \param state The common state used to create test window. |
miruga27 | 0:7fb6877b5d7c | 165 | * \param event The event to handle. |
miruga27 | 0:7fb6877b5d7c | 166 | * \param done Flag indicating we are done. |
miruga27 | 0:7fb6877b5d7c | 167 | * |
miruga27 | 0:7fb6877b5d7c | 168 | */ |
miruga27 | 0:7fb6877b5d7c | 169 | void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); |
miruga27 | 0:7fb6877b5d7c | 170 | |
miruga27 | 0:7fb6877b5d7c | 171 | /** |
miruga27 | 0:7fb6877b5d7c | 172 | * \brief Close test window. |
miruga27 | 0:7fb6877b5d7c | 173 | * |
miruga27 | 0:7fb6877b5d7c | 174 | * \param state The common state used to create test window. |
miruga27 | 0:7fb6877b5d7c | 175 | * |
miruga27 | 0:7fb6877b5d7c | 176 | */ |
miruga27 | 0:7fb6877b5d7c | 177 | void SDLTest_CommonQuit(SDLTest_CommonState * state); |
miruga27 | 0:7fb6877b5d7c | 178 | |
miruga27 | 0:7fb6877b5d7c | 179 | |
miruga27 | 0:7fb6877b5d7c | 180 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 181 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 182 | } |
miruga27 | 0:7fb6877b5d7c | 183 | #endif |
miruga27 | 0:7fb6877b5d7c | 184 | #include "close_code.h" |
miruga27 | 0:7fb6877b5d7c | 185 | |
miruga27 | 0:7fb6877b5d7c | 186 | #endif /* _SDL_test_common_h */ |
miruga27 | 0:7fb6877b5d7c | 187 | |
miruga27 | 0:7fb6877b5d7c | 188 | /* vi: set ts=4 sw=4 expandtab: */ |