🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

236 lines
6.7 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_test_common.h
  20. *
  21. * Include file for SDL test framework.
  22. *
  23. * This code is a part of the SDL2_test library, not the main SDL library.
  24. */
  25. /* Ported from original test\common.h file. */
  26. #ifndef SDL_test_common_h_
  27. #define SDL_test_common_h_
  28. #include "SDL.h"
  29. #if defined(__PSP__)
  30. #define DEFAULT_WINDOW_WIDTH 480
  31. #define DEFAULT_WINDOW_HEIGHT 272
  32. #elif defined(__VITA__)
  33. #define DEFAULT_WINDOW_WIDTH 960
  34. #define DEFAULT_WINDOW_HEIGHT 544
  35. #else
  36. #define DEFAULT_WINDOW_WIDTH 640
  37. #define DEFAULT_WINDOW_HEIGHT 480
  38. #endif
  39. #define VERBOSE_VIDEO 0x00000001
  40. #define VERBOSE_MODES 0x00000002
  41. #define VERBOSE_RENDER 0x00000004
  42. #define VERBOSE_EVENT 0x00000008
  43. #define VERBOSE_AUDIO 0x00000010
  44. #define VERBOSE_MOTION 0x00000020
  45. typedef struct
  46. {
  47. /* SDL init flags */
  48. char **argv;
  49. Uint32 flags;
  50. Uint32 verbose;
  51. /* Video info */
  52. const char *videodriver;
  53. int display;
  54. const char *window_title;
  55. const char *window_icon;
  56. Uint32 window_flags;
  57. SDL_bool flash_on_focus_loss;
  58. int window_x;
  59. int window_y;
  60. int window_w;
  61. int window_h;
  62. int window_minW;
  63. int window_minH;
  64. int window_maxW;
  65. int window_maxH;
  66. int logical_w;
  67. int logical_h;
  68. float scale;
  69. int depth;
  70. int refresh_rate;
  71. int num_windows;
  72. SDL_Window **windows;
  73. /* Renderer info */
  74. const char *renderdriver;
  75. Uint32 render_flags;
  76. SDL_bool skip_renderer;
  77. SDL_Renderer **renderers;
  78. SDL_Texture **targets;
  79. /* Audio info */
  80. const char *audiodriver;
  81. SDL_AudioSpec audiospec;
  82. /* GL settings */
  83. int gl_red_size;
  84. int gl_green_size;
  85. int gl_blue_size;
  86. int gl_alpha_size;
  87. int gl_buffer_size;
  88. int gl_depth_size;
  89. int gl_stencil_size;
  90. int gl_double_buffer;
  91. int gl_accum_red_size;
  92. int gl_accum_green_size;
  93. int gl_accum_blue_size;
  94. int gl_accum_alpha_size;
  95. int gl_stereo;
  96. int gl_multisamplebuffers;
  97. int gl_multisamplesamples;
  98. int gl_retained_backing;
  99. int gl_accelerated;
  100. int gl_major_version;
  101. int gl_minor_version;
  102. int gl_debug;
  103. int gl_profile_mask;
  104. /* Additional fields added in 2.0.18 */
  105. SDL_Rect confine;
  106. } SDLTest_CommonState;
  107. #include "begin_code.h"
  108. /* Set up for C function definitions, even when using C++ */
  109. #ifdef __cplusplus
  110. extern "C" {
  111. #endif
  112. /* Function prototypes */
  113. /**
  114. * \brief Parse command line parameters and create common state.
  115. *
  116. * \param argv Array of command line parameters
  117. * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
  118. *
  119. * \returns a newly allocated common state object.
  120. */
  121. SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
  122. /**
  123. * \brief Process one common argument.
  124. *
  125. * \param state The common state describing the test window to create.
  126. * \param index The index of the argument to process in argv[].
  127. *
  128. * \returns the number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
  129. */
  130. int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
  131. /**
  132. * \brief Logs command line usage info.
  133. *
  134. * This logs the appropriate command line options for the subsystems in use
  135. * plus other common options, and then any application-specific options.
  136. * This uses the SDL_Log() function and splits up output to be friendly to
  137. * 80-character-wide terminals.
  138. *
  139. * \param state The common state describing the test window for the app.
  140. * \param argv0 argv[0], as passed to main/SDL_main.
  141. * \param options an array of strings for application specific options. The last element of the array should be NULL.
  142. */
  143. void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options);
  144. /**
  145. * \brief Returns common usage information
  146. *
  147. * You should (probably) be using SDLTest_CommonLogUsage() instead, but this
  148. * function remains for binary compatibility. Strings returned from this
  149. * function are valid until SDLTest_CommonQuit() is called, in which case
  150. * those strings' memory is freed and can no longer be used.
  151. *
  152. * \param state The common state describing the test window to create.
  153. * \returns a string with usage information
  154. */
  155. const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
  156. /**
  157. * \brief Open test window.
  158. *
  159. * \param state The common state describing the test window to create.
  160. *
  161. * \returns SDL_TRUE if initialization succeeded, false otherwise
  162. */
  163. SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
  164. /**
  165. * \brief Easy argument handling when test app doesn't need any custom args.
  166. *
  167. * \param state The common state describing the test window to create.
  168. * \param argc argc, as supplied to SDL_main
  169. * \param argv argv, as supplied to SDL_main
  170. *
  171. * \returns SDL_FALSE if app should quit, true otherwise.
  172. */
  173. SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv);
  174. /**
  175. * \brief Common event handler for test windows.
  176. *
  177. * \param state The common state used to create test window.
  178. * \param event The event to handle.
  179. * \param done Flag indicating we are done.
  180. *
  181. */
  182. void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
  183. /**
  184. * \brief Close test window.
  185. *
  186. * \param state The common state used to create test window.
  187. *
  188. */
  189. void SDLTest_CommonQuit(SDLTest_CommonState * state);
  190. /**
  191. * \brief Draws various window information (position, size, etc.) to the renderer.
  192. *
  193. * \param renderer The renderer to draw to.
  194. * \param window The window whose information should be displayed.
  195. * \param usedHeight Returns the height used, so the caller can draw more below.
  196. *
  197. */
  198. void SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int * usedHeight);
  199. /* Ends C function definitions when using C++ */
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203. #include "close_code.h"
  204. #endif /* SDL_test_common_h_ */
  205. /* vi: set ts=4 sw=4 expandtab: */