🛠️🐜 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.

235 lines
6.7 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 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. typedef struct
  45. {
  46. /* SDL init flags */
  47. char **argv;
  48. Uint32 flags;
  49. Uint32 verbose;
  50. /* Video info */
  51. const char *videodriver;
  52. int display;
  53. const char *window_title;
  54. const char *window_icon;
  55. Uint32 window_flags;
  56. SDL_bool flash_on_focus_loss;
  57. int window_x;
  58. int window_y;
  59. int window_w;
  60. int window_h;
  61. int window_minW;
  62. int window_minH;
  63. int window_maxW;
  64. int window_maxH;
  65. int logical_w;
  66. int logical_h;
  67. float scale;
  68. int depth;
  69. int refresh_rate;
  70. int num_windows;
  71. SDL_Window **windows;
  72. /* Renderer info */
  73. const char *renderdriver;
  74. Uint32 render_flags;
  75. SDL_bool skip_renderer;
  76. SDL_Renderer **renderers;
  77. SDL_Texture **targets;
  78. /* Audio info */
  79. const char *audiodriver;
  80. SDL_AudioSpec audiospec;
  81. /* GL settings */
  82. int gl_red_size;
  83. int gl_green_size;
  84. int gl_blue_size;
  85. int gl_alpha_size;
  86. int gl_buffer_size;
  87. int gl_depth_size;
  88. int gl_stencil_size;
  89. int gl_double_buffer;
  90. int gl_accum_red_size;
  91. int gl_accum_green_size;
  92. int gl_accum_blue_size;
  93. int gl_accum_alpha_size;
  94. int gl_stereo;
  95. int gl_multisamplebuffers;
  96. int gl_multisamplesamples;
  97. int gl_retained_backing;
  98. int gl_accelerated;
  99. int gl_major_version;
  100. int gl_minor_version;
  101. int gl_debug;
  102. int gl_profile_mask;
  103. /* Additional fields added in 2.0.18 */
  104. SDL_Rect confine;
  105. } SDLTest_CommonState;
  106. #include "begin_code.h"
  107. /* Set up for C function definitions, even when using C++ */
  108. #ifdef __cplusplus
  109. extern "C" {
  110. #endif
  111. /* Function prototypes */
  112. /**
  113. * \brief Parse command line parameters and create common state.
  114. *
  115. * \param argv Array of command line parameters
  116. * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
  117. *
  118. * \returns a newly allocated common state object.
  119. */
  120. SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
  121. /**
  122. * \brief Process one common argument.
  123. *
  124. * \param state The common state describing the test window to create.
  125. * \param index The index of the argument to process in argv[].
  126. *
  127. * \returns the number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
  128. */
  129. int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
  130. /**
  131. * \brief Logs command line usage info.
  132. *
  133. * This logs the appropriate command line options for the subsystems in use
  134. * plus other common options, and then any application-specific options.
  135. * This uses the SDL_Log() function and splits up output to be friendly to
  136. * 80-character-wide terminals.
  137. *
  138. * \param state The common state describing the test window for the app.
  139. * \param argv0 argv[0], as passed to main/SDL_main.
  140. * \param options an array of strings for application specific options. The last element of the array should be NULL.
  141. */
  142. void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options);
  143. /**
  144. * \brief Returns common usage information
  145. *
  146. * You should (probably) be using SDLTest_CommonLogUsage() instead, but this
  147. * function remains for binary compatibility. Strings returned from this
  148. * function are valid until SDLTest_CommonQuit() is called, in which case
  149. * those strings' memory is freed and can no longer be used.
  150. *
  151. * \param state The common state describing the test window to create.
  152. * \returns a string with usage information
  153. */
  154. const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
  155. /**
  156. * \brief Open test window.
  157. *
  158. * \param state The common state describing the test window to create.
  159. *
  160. * \returns SDL_TRUE if initialization succeeded, false otherwise
  161. */
  162. SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
  163. /**
  164. * \brief Easy argument handling when test app doesn't need any custom args.
  165. *
  166. * \param state The common state describing the test window to create.
  167. * \param argc argc, as supplied to SDL_main
  168. * \param argv argv, as supplied to SDL_main
  169. *
  170. * \returns SDL_FALSE if app should quit, true otherwise.
  171. */
  172. SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv);
  173. /**
  174. * \brief Common event handler for test windows.
  175. *
  176. * \param state The common state used to create test window.
  177. * \param event The event to handle.
  178. * \param done Flag indicating we are done.
  179. *
  180. */
  181. void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
  182. /**
  183. * \brief Close test window.
  184. *
  185. * \param state The common state used to create test window.
  186. *
  187. */
  188. void SDLTest_CommonQuit(SDLTest_CommonState * state);
  189. /**
  190. * \brief Draws various window information (position, size, etc.) to the renderer.
  191. *
  192. * \param renderer The renderer to draw to.
  193. * \param window The window whose information should be displayed.
  194. * \param usedHeight Returns the height used, so the caller can draw more below.
  195. *
  196. */
  197. void SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int * usedHeight);
  198. /* Ends C function definitions when using C++ */
  199. #ifdef __cplusplus
  200. }
  201. #endif
  202. #include "close_code.h"
  203. #endif /* SDL_test_common_h_ */
  204. /* vi: set ts=4 sw=4 expandtab: */