gosu 1.4.6 → 2.0.0.pre6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +2 -1
  3. data/dependencies/SDL/include/SDL_atomic.h +2 -3
  4. data/dependencies/SDL/include/SDL_audio.h +7 -7
  5. data/dependencies/SDL/include/SDL_blendmode.h +1 -1
  6. data/dependencies/SDL/include/SDL_endian.h +3 -3
  7. data/dependencies/SDL/include/SDL_gamecontroller.h +4 -4
  8. data/dependencies/SDL/include/SDL_hints.h +72 -28
  9. data/dependencies/SDL/include/SDL_joystick.h +8 -5
  10. data/dependencies/SDL/include/SDL_keycode.h +1 -1
  11. data/dependencies/SDL/include/SDL_main.h +7 -0
  12. data/dependencies/SDL/include/SDL_mouse.h +6 -7
  13. data/dependencies/SDL/include/SDL_mutex.h +79 -5
  14. data/dependencies/SDL/include/SDL_opengl_glext.h +5 -1
  15. data/dependencies/SDL/include/SDL_power.h +7 -8
  16. data/dependencies/SDL/include/SDL_render.h +5 -0
  17. data/dependencies/SDL/include/SDL_revision.h +2 -2
  18. data/dependencies/SDL/include/SDL_sensor.h +1 -1
  19. data/dependencies/SDL/include/SDL_stdinc.h +19 -11
  20. data/dependencies/SDL/include/SDL_thread.h +2 -2
  21. data/dependencies/SDL/include/SDL_version.h +2 -2
  22. data/dependencies/SDL/include/SDL_video.h +30 -2
  23. data/dependencies/SDL/include/begin_code.h +7 -7
  24. data/dependencies/SDL/include/close_code.h +2 -2
  25. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  26. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  27. data/dependencies/SDL_sound/SDL_sound.h +1 -1
  28. data/dependencies/SDL_sound/dr_flac.h +48 -23
  29. data/dependencies/SDL_sound/dr_mp3.h +34 -14
  30. data/dependencies/SDL_sound/stb_vorbis.h +3 -2
  31. data/dependencies/mojoAL/mojoal.c +1 -1
  32. data/ext/{gosu → gosu-ffi}/extconf.rb +34 -33
  33. data/ext/gosu-ffi/gosu-ffi.def +464 -0
  34. data/ffi/Gosu.cpp +307 -0
  35. data/ffi/Gosu.h +84 -0
  36. data/ffi/Gosu_Channel.cpp +62 -0
  37. data/ffi/Gosu_Channel.h +17 -0
  38. data/ffi/Gosu_Color.cpp +132 -0
  39. data/ffi/Gosu_Color.h +31 -0
  40. data/ffi/Gosu_Constants.cpp +334 -0
  41. data/ffi/Gosu_FFI.h +34 -0
  42. data/ffi/Gosu_FFI_internal.h +161 -0
  43. data/ffi/Gosu_Font.cpp +92 -0
  44. data/ffi/Gosu_Font.h +32 -0
  45. data/ffi/Gosu_Image.cpp +206 -0
  46. data/ffi/Gosu_Image.h +60 -0
  47. data/ffi/Gosu_Sample.cpp +29 -0
  48. data/ffi/Gosu_Sample.h +14 -0
  49. data/ffi/Gosu_Song.cpp +69 -0
  50. data/ffi/Gosu_Song.h +18 -0
  51. data/ffi/Gosu_TextInput.cpp +94 -0
  52. data/ffi/Gosu_TextInput.h +25 -0
  53. data/ffi/Gosu_Window.cpp +314 -0
  54. data/ffi/Gosu_Window.h +78 -0
  55. data/include/Gosu/Audio.hpp +6 -11
  56. data/include/Gosu/Bitmap.hpp +38 -53
  57. data/include/Gosu/Buffer.hpp +54 -0
  58. data/include/Gosu/Color.hpp +27 -35
  59. data/include/Gosu/Directories.hpp +25 -28
  60. data/include/Gosu/Drawable.hpp +58 -0
  61. data/include/Gosu/Font.hpp +6 -5
  62. data/include/Gosu/Fwd.hpp +4 -6
  63. data/include/Gosu/Gosu.hpp +5 -5
  64. data/include/Gosu/Graphics.hpp +51 -61
  65. data/include/Gosu/GraphicsBase.hpp +1 -11
  66. data/include/Gosu/Image.hpp +11 -14
  67. data/include/Gosu/Math.hpp +50 -72
  68. data/include/Gosu/Transform.hpp +32 -0
  69. data/include/Gosu/Utility.hpp +51 -1
  70. data/include/Gosu/Version.hpp +3 -3
  71. data/include/Gosu/Window.hpp +15 -9
  72. data/lib/SDL2.dll +0 -0
  73. data/lib/gosu/channel.rb +49 -0
  74. data/lib/gosu/color.rb +150 -0
  75. data/lib/gosu/compat.rb +29 -8
  76. data/lib/gosu/constants.rb +386 -0
  77. data/lib/gosu/ffi.rb +258 -0
  78. data/lib/gosu/font.rb +56 -0
  79. data/lib/gosu/gl_tex_info.rb +33 -0
  80. data/lib/gosu/gosu.rb +210 -0
  81. data/lib/gosu/image.rb +141 -0
  82. data/lib/gosu/numeric.rb +17 -0
  83. data/lib/gosu/preview.rb +6 -6
  84. data/lib/gosu/sample.rb +24 -0
  85. data/lib/gosu/song.rb +56 -0
  86. data/lib/gosu/text_input.rb +69 -0
  87. data/lib/gosu/window.rb +228 -0
  88. data/lib/gosu.rb +29 -8
  89. data/lib64/SDL2.dll +0 -0
  90. data/rdoc/gosu.rb +0 -2
  91. data/src/Audio.cpp +12 -12
  92. data/src/AudioFile.hpp +5 -4
  93. data/src/AudioFileAudioToolbox.cpp +8 -8
  94. data/src/AudioFileSDLSound.cpp +7 -10
  95. data/src/BinPacker.cpp +187 -0
  96. data/src/BinPacker.hpp +55 -0
  97. data/src/Bitmap.cpp +166 -144
  98. data/src/BitmapIO.cpp +60 -86
  99. data/src/Buffer.cpp +159 -0
  100. data/src/Color.cpp +75 -80
  101. data/src/Directories.cpp +47 -0
  102. data/src/DirectoriesUIKit.cpp +50 -0
  103. data/src/DrawOp.hpp +9 -4
  104. data/src/DrawOpQueue.hpp +2 -2
  105. data/src/Drawable.cpp +95 -0
  106. data/src/EmptyDrawable.hpp +38 -0
  107. data/src/FPS.cpp +31 -0
  108. data/src/Font.cpp +104 -74
  109. data/src/GosuGLView.cpp +14 -6
  110. data/src/GosuViewController.cpp +2 -10
  111. data/src/Graphics.cpp +60 -126
  112. data/src/GraphicsImpl.hpp +17 -47
  113. data/src/Image.cpp +41 -35
  114. data/src/Input.cpp +7 -8
  115. data/src/Macro.cpp +6 -6
  116. data/src/Macro.hpp +4 -4
  117. data/src/MarkupParser.cpp +5 -5
  118. data/src/Math.cpp +35 -22
  119. data/src/OffScreenTarget.cpp +53 -49
  120. data/src/OffScreenTarget.hpp +13 -11
  121. data/src/OpenGLContext.cpp +117 -0
  122. data/src/OpenGLContext.hpp +41 -0
  123. data/src/RenderState.hpp +21 -19
  124. data/src/Resolution.cpp +23 -21
  125. data/src/TexChunk.cpp +35 -80
  126. data/src/TexChunk.hpp +44 -35
  127. data/src/Text.cpp +1 -1
  128. data/src/TextBuilder.cpp +35 -21
  129. data/src/TextBuilder.hpp +6 -9
  130. data/src/Texture.cpp +62 -80
  131. data/src/Texture.hpp +25 -23
  132. data/src/TiledDrawable.cpp +150 -0
  133. data/src/TiledDrawable.hpp +47 -0
  134. data/src/TimingApple.cpp +1 -1
  135. data/src/Transform.cpp +45 -50
  136. data/src/TransformStack.hpp +16 -16
  137. data/src/TrueTypeFont.cpp +59 -51
  138. data/src/TrueTypeFont.hpp +6 -7
  139. data/src/TrueTypeFontApple.cpp +28 -19
  140. data/src/TrueTypeFontUnix.cpp +27 -23
  141. data/src/TrueTypeFontWin.cpp +30 -30
  142. data/src/Utility.cpp +84 -21
  143. data/src/UtilityWin.cpp +45 -0
  144. data/src/Window.cpp +92 -142
  145. data/src/WindowUIKit.cpp +14 -14
  146. metadata +72 -31
  147. data/include/Gosu/IO.hpp +0 -254
  148. data/include/Gosu/ImageData.hpp +0 -53
  149. data/include/Gosu/Inspection.hpp +0 -7
  150. data/lib/gosu/patches.rb +0 -66
  151. data/lib/gosu/run.rb +0 -20
  152. data/lib/gosu/swig_patches.rb +0 -110
  153. data/src/BlockAllocator.cpp +0 -131
  154. data/src/BlockAllocator.hpp +0 -32
  155. data/src/DirectoriesApple.cpp +0 -69
  156. data/src/DirectoriesUnix.cpp +0 -46
  157. data/src/DirectoriesWin.cpp +0 -65
  158. data/src/EmptyImageData.hpp +0 -52
  159. data/src/FileUnix.cpp +0 -99
  160. data/src/FileWin.cpp +0 -88
  161. data/src/IO.cpp +0 -60
  162. data/src/Iconv.hpp +0 -51
  163. data/src/Inspection.cpp +0 -27
  164. data/src/LargeImageData.cpp +0 -215
  165. data/src/LargeImageData.hpp +0 -39
  166. data/src/Log.hpp +0 -19
  167. data/src/RubyGosu.cxx +0 -13100
  168. data/src/RubyGosu.h +0 -49
  169. data/src/WinUtility.cpp +0 -61
  170. data/src/WinUtility.hpp +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1633167d9fbc9fa4eaf8ce2f15763f07122299c8f1f41fc14237174b0f00184f
4
- data.tar.gz: aa1fba4f1d5ca11ff555232aa8cd66cca8031e5b831f8f7fc01bb8c7618c1544
3
+ metadata.gz: 8c216718d8cc417f4136f1231d7a845bfab4a5308900243750d218d1ba433a6b
4
+ data.tar.gz: 326fccc87ec22ee599c0536a744356423abf70e921f2e3bc247067b120a834a6
5
5
  SHA512:
6
- metadata.gz: 4e36daba8fc9ae286150dadf5a8e07d59cbd1d13e7058313b72cfff489987b7babc99fc80013b69a16ab2a76056f3c8e914e96fa89c7ce6bf175de92c71658e7
7
- data.tar.gz: ba3b1fed78d1c9affff3c68daffcf440612747315f21016a0e49357c87476b42e3395bb9fe063bb697aeacdd3664377a7ce0723cab262f30fd4819a553a8fbeb
6
+ metadata.gz: aaf8dce2376755bd906ff3598599941337544e489153ca691e68cd86bf773a0a7aeed6db2e27aedf591399d694bd3e67fa2e2e9aad62116371e8f3a51d06a00f
7
+ data.tar.gz: 19f7f2dff02d74c44292218234fad7cab148f139f0e1cc04475428f1c8200812075a073cb0663d221aac769d91eb87ab6a2894c7052a94f7190a1727226495d6
data/COPYING CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (C) 2001-2021 Julian Raschke, Jan Lücker and all contributors.
1
+ Copyright (C) 2001-2023 Julian Raschke, Jan Lücker, cyberarm, and all
2
+ other contributors: https://github.com/gosu/gosu/graphs/contributors
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining a
4
5
  copy of this software and associated documentation files (the "Software"),
@@ -240,7 +240,7 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
240
240
  /* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
241
241
  #if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
242
242
  #define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */
243
- #elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
243
+ #elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__)
244
244
  #define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")
245
245
  #elif (defined(__powerpc__) || defined(__powerpc64__))
246
246
  #define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");
@@ -249,9 +249,8 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
249
249
  #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
250
250
  #define SDL_CPUPauseInstruction() __yield()
251
251
  #elif defined(__WATCOMC__) && defined(__386__)
252
- /* watcom assembler rejects PAUSE if CPU < i686, and it refuses REP NOP as an invalid combination. Hardcode the bytes. */
253
252
  extern __inline void SDL_CPUPauseInstruction(void);
254
- #pragma aux SDL_CPUPauseInstruction = "db 0f3h,90h"
253
+ #pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause"
255
254
  #else
256
255
  #define SDL_CPUPauseInstruction()
257
256
  #endif
@@ -169,13 +169,13 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
169
169
  * The calculated values in this structure are calculated by SDL_OpenAudio().
170
170
  *
171
171
  * For multi-channel audio, the default SDL channel mapping is:
172
- * 2: FL FR (stereo)
173
- * 3: FL FR LFE (2.1 surround)
174
- * 4: FL FR BL BR (quad)
175
- * 5: FL FR LFE BL BR (4.1 surround)
176
- * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
177
- * 7: FL FR FC LFE BC SL SR (6.1 surround)
178
- * 8: FL FR FC LFE BL BR SL SR (7.1 surround)
172
+ * 2: FL FR (stereo)
173
+ * 3: FL FR LFE (2.1 surround)
174
+ * 4: FL FR BL BR (quad)
175
+ * 5: FL FR LFE BL BR (4.1 surround)
176
+ * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
177
+ * 7: FL FR FC LFE BC SL SR (6.1 surround)
178
+ * 8: FL FR FC LFE BL BR SL SR (7.1 surround)
179
179
  */
180
180
  typedef struct SDL_AudioSpec
181
181
  {
@@ -52,7 +52,7 @@ typedef enum
52
52
  dstA = dstA */
53
53
  SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply
54
54
  dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
55
- dstA = (srcA * dstA) + (dstA * (1-srcA)) */
55
+ dstA = dstA */
56
56
  SDL_BLENDMODE_INVALID = 0x7FFFFFFF
57
57
 
58
58
  /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
@@ -140,7 +140,7 @@ extern "C" {
140
140
 
141
141
  #if HAS_BUILTIN_BSWAP16
142
142
  #define SDL_Swap16(x) __builtin_bswap16(x)
143
- #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
143
+ #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
144
144
  #pragma intrinsic(_byteswap_ushort)
145
145
  #define SDL_Swap16(x) _byteswap_ushort(x)
146
146
  #elif defined(__i386__) && !HAS_BROKEN_BSWAP
@@ -189,7 +189,7 @@ SDL_Swap16(Uint16 x)
189
189
 
190
190
  #if HAS_BUILTIN_BSWAP32
191
191
  #define SDL_Swap32(x) __builtin_bswap32(x)
192
- #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
192
+ #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
193
193
  #pragma intrinsic(_byteswap_ulong)
194
194
  #define SDL_Swap32(x) _byteswap_ulong(x)
195
195
  #elif defined(__i386__) && !HAS_BROKEN_BSWAP
@@ -241,7 +241,7 @@ SDL_Swap32(Uint32 x)
241
241
 
242
242
  #if HAS_BUILTIN_BSWAP64
243
243
  #define SDL_Swap64(x) __builtin_bswap64(x)
244
- #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
244
+ #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
245
245
  #pragma intrinsic(_byteswap_uint64)
246
246
  #define SDL_Swap64(x) _byteswap_uint64(x)
247
247
  #elif defined(__i386__) && !HAS_BROKEN_BSWAP
@@ -724,10 +724,10 @@ typedef enum
724
724
  SDL_CONTROLLER_BUTTON_DPAD_LEFT,
725
725
  SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
726
726
  SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
727
- SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
728
- SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
729
- SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
730
- SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
727
+ SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 (upper left, facing the back) */
728
+ SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 (upper right, facing the back) */
729
+ SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 (lower left, facing the back) */
730
+ SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 (lower right, facing the back) */
731
731
  SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
732
732
  SDL_CONTROLLER_BUTTON_MAX
733
733
  } SDL_GameControllerButton;
@@ -92,7 +92,7 @@ extern "C" {
92
92
  * By default this hint is not set and the APK expansion files are not searched.
93
93
  */
94
94
  #define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"
95
-
95
+
96
96
  /**
97
97
  * \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc.
98
98
  *
@@ -132,13 +132,13 @@ extern "C" {
132
132
  * \brief A variable to control whether we trap the Android back button to handle it manually.
133
133
  * This is necessary for the right mouse button to work on some Android devices, or
134
134
  * to be able to trap the back button for use in your code reliably. If set to true,
135
- * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of
135
+ * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of
136
136
  * SDL_SCANCODE_AC_BACK.
137
137
  *
138
138
  * The variable can be set to the following values:
139
139
  * "0" - Back button will be handled as usual for system. (default)
140
140
  * "1" - Back button will be trapped, allowing you to handle the key press
141
- * manually. (This will also let right mouse click work on systems
141
+ * manually. (This will also let right mouse click work on systems
142
142
  * where the right mouse button functions as back.)
143
143
  *
144
144
  * The value of this hint is used at runtime, so it can be changed at any time.
@@ -147,7 +147,7 @@ extern "C" {
147
147
 
148
148
  /**
149
149
  * \brief Specify an application name.
150
- *
150
+ *
151
151
  * This hint lets you specify the application name sent to the OS when
152
152
  * required. For example, this will often appear in volume control applets for
153
153
  * audio streams, and in lists of applications which are inhibiting the
@@ -377,6 +377,17 @@ extern "C" {
377
377
  */
378
378
  #define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
379
379
 
380
+ /**
381
+ * \brief A variable that controls whether the on-screen keyboard should be shown when text input is active
382
+ *
383
+ * The variable can be set to the following values:
384
+ * "0" - Do not show the on-screen keyboard
385
+ * "1" - Show the on-screen keyboard
386
+ *
387
+ * The default value is "1". This hint must be set before text input is activated.
388
+ */
389
+ #define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD"
390
+
380
391
  /**
381
392
  * \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
382
393
  *
@@ -507,7 +518,7 @@ extern "C" {
507
518
 
508
519
  /**
509
520
  * \brief If set, game controller face buttons report their values according to their labels instead of their positional layout.
510
- *
521
+ *
511
522
  * For example, on Nintendo Switch controllers, normally you'd get:
512
523
  *
513
524
  * (Y)
@@ -569,9 +580,9 @@ extern "C" {
569
580
  *
570
581
  * The variable can be set to the following values:
571
582
  * "0" - SDL_TEXTEDITING events are sent, and it is the application's
572
- * responsibility to render the text from these events and
583
+ * responsibility to render the text from these events and
573
584
  * differentiate it somehow from committed text. (default)
574
- * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent,
585
+ * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent,
575
586
  * and text that is being composed will be rendered in its own UI.
576
587
  */
577
588
  #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
@@ -996,6 +1007,15 @@ extern "C" {
996
1007
  */
997
1008
  #define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD"
998
1009
 
1010
+ /**
1011
+ * \brief A variable controlling whether Windows.Gaming.Input should be used for controller handling.
1012
+ *
1013
+ * This variable can be set to the following values:
1014
+ * "0" - WGI is not used
1015
+ * "1" - WGI is used (the default)
1016
+ */
1017
+ #define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI"
1018
+
999
1019
  /**
1000
1020
  * \brief Determines whether SDL enforces that DRM master is required in order
1001
1021
  * to initialize the KMSDRM video backend.
@@ -1310,6 +1330,8 @@ extern "C" {
1310
1330
  *
1311
1331
  * This variable can be one of the following values:
1312
1332
  * "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape"
1333
+ *
1334
+ * Since SDL 2.0.22 this variable accepts a comma-separated list of values above.
1313
1335
  */
1314
1336
  #define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION"
1315
1337
 
@@ -1495,7 +1517,7 @@ extern "C" {
1495
1517
  * disabled. You should use a string that describes what your program is doing
1496
1518
  * (and, therefore, why the screensaver is disabled). For example, "Playing a
1497
1519
  * game" or "Watching a video".
1498
- *
1520
+ *
1499
1521
  * Setting this to "" or leaving it unset will have SDL use a reasonable
1500
1522
  * default: "Playing a game" or something similar.
1501
1523
  *
@@ -1509,13 +1531,13 @@ extern "C" {
1509
1531
  * On some platforms, like Linux, a realtime priority thread may be subject to restrictions
1510
1532
  * that require special handling by the application. This hint exists to let SDL know that
1511
1533
  * the app is prepared to handle said restrictions.
1512
- *
1534
+ *
1513
1535
  * On Linux, SDL will apply the following configuration to any thread that becomes realtime:
1514
1536
  * * The SCHED_RESET_ON_FORK bit will be set on the scheduling policy,
1515
1537
  * * An RLIMIT_RTTIME budget will be configured to the rtkit specified limit.
1516
1538
  * * Exceeding this limit will result in the kernel sending SIGKILL to the app,
1517
1539
  * * Refer to the man pages for more information.
1518
- *
1540
+ *
1519
1541
  * This variable can be set to the following values:
1520
1542
  * "0" - default platform specific behaviour
1521
1543
  * "1" - Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling policy
@@ -1603,7 +1625,7 @@ extern "C" {
1603
1625
  #define SDL_HINT_TV_REMOTE_AS_JOYSTICK "SDL_TV_REMOTE_AS_JOYSTICK"
1604
1626
 
1605
1627
  /**
1606
- * \brief A variable controlling whether the screensaver is enabled.
1628
+ * \brief A variable controlling whether the screensaver is enabled.
1607
1629
  *
1608
1630
  * This variable can be set to the following values:
1609
1631
  * "0" - Disable screensaver
@@ -1616,7 +1638,7 @@ extern "C" {
1616
1638
  /**
1617
1639
  * \brief Tell the video driver that we only want a double buffer.
1618
1640
  *
1619
- * By default, most lowlevel 2D APIs will use a triple buffer scheme that
1641
+ * By default, most lowlevel 2D APIs will use a triple buffer scheme that
1620
1642
  * wastes no CPU time on waiting for vsync after issuing a flip, but
1621
1643
  * introduces a frame of latency. On the other hand, using a double buffer
1622
1644
  * scheme instead is recommended for cases where low latency is an important
@@ -1747,9 +1769,9 @@ extern "C" {
1747
1769
 
1748
1770
  /**
1749
1771
  * \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p").
1750
- *
1772
+ *
1751
1773
  * If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has
1752
- * SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly
1774
+ * SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly
1753
1775
  * created SDL_Window:
1754
1776
  *
1755
1777
  * 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is
@@ -1815,13 +1837,13 @@ extern "C" {
1815
1837
 
1816
1838
  /**
1817
1839
  * \brief A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint should be used.
1818
- *
1840
+ *
1819
1841
  * This variable can be set to the following values:
1820
1842
  * "0" - Disable _NET_WM_BYPASS_COMPOSITOR
1821
1843
  * "1" - Enable _NET_WM_BYPASS_COMPOSITOR
1822
- *
1844
+ *
1823
1845
  * By default SDL will use _NET_WM_BYPASS_COMPOSITOR
1824
- *
1846
+ *
1825
1847
  */
1826
1848
  #define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR"
1827
1849
 
@@ -1955,7 +1977,29 @@ extern "C" {
1955
1977
  #define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING"
1956
1978
 
1957
1979
  /**
1958
- * \brief A variable controlling whether the windows message loop is processed by SDL
1980
+ * \brief Controls whether menus can be opened with their keyboard shortcut (Alt+mnemonic).
1981
+ *
1982
+ * If the mnemonics are enabled, then menus can be opened by pressing the Alt
1983
+ * key and the corresponding mnemonic (for example, Alt+F opens the File menu).
1984
+ * However, in case an invalid mnemonic is pressed, Windows makes an audible
1985
+ * beep to convey that nothing happened. This is true even if the window has
1986
+ * no menu at all!
1987
+ *
1988
+ * Because most SDL applications don't have menus, and some want to use the Alt
1989
+ * key for other purposes, SDL disables mnemonics (and the beeping) by default.
1990
+ *
1991
+ * Note: This also affects keyboard events: with mnemonics enabled, when a
1992
+ * menu is opened from the keyboard, you will not receive a KEYUP event for
1993
+ * the mnemonic key, and *might* not receive one for Alt.
1994
+ *
1995
+ * This variable can be set to the following values:
1996
+ * "0" - Alt+mnemonic does nothing, no beeping. (default)
1997
+ * "1" - Alt+mnemonic opens menus, invalid mnemonics produce a beep.
1998
+ */
1999
+ #define SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS "SDL_WINDOWS_ENABLE_MENU_MNEMONICS"
2000
+
2001
+ /**
2002
+ * \brief A variable controlling whether the windows message loop is processed by SDL
1959
2003
  *
1960
2004
  * This variable can be set to the following values:
1961
2005
  * "0" - The window message loop is not run
@@ -1996,7 +2040,7 @@ extern "C" {
1996
2040
  #define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL"
1997
2041
 
1998
2042
  /**
1999
- * \brief A variable to specify custom icon resource id from RC file on Windows platform
2043
+ * \brief A variable to specify custom icon resource id from RC file on Windows platform
2000
2044
  */
2001
2045
  #define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON"
2002
2046
  #define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL"
@@ -2035,16 +2079,16 @@ extern "C" {
2035
2079
  *
2036
2080
  * This hint must be set before initializing the video subsystem.
2037
2081
  *
2038
- * The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with
2082
+ * The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with
2039
2083
  * a DPI scale factor.
2040
- *
2084
+ *
2041
2085
  * This hint is equivalent to requesting DPI awareness via external means (e.g. calling SetProcessDpiAwarenessContext)
2042
2086
  * and does not cause SDL to use a virtualized coordinate system, so it will generally give you 1 SDL coordinate = 1 pixel
2043
2087
  * even on high-DPI displays.
2044
- *
2088
+ *
2045
2089
  * For more information, see:
2046
2090
  * https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
2047
- *
2091
+ *
2048
2092
  * This variable can be set to the following values:
2049
2093
  * "" - Do not change the DPI awareness (default).
2050
2094
  * "unaware" - Declare the process as DPI unaware. (Windows 8.1 and later).
@@ -2062,16 +2106,16 @@ extern "C" {
2062
2106
 
2063
2107
  /**
2064
2108
  * \brief Uses DPI-scaled points as the SDL coordinate system on Windows.
2065
- *
2109
+ *
2066
2110
  * This changes the SDL coordinate system units to be DPI-scaled points, rather than pixels everywhere.
2067
2111
  * This means windows will be appropriately sized, even when created on high-DPI displays with scaling.
2068
- *
2112
+ *
2069
2113
  * e.g. requesting a 640x480 window from SDL, on a display with 125% scaling in Windows display settings,
2070
2114
  * will create a window with an 800x600 client area (in pixels).
2071
2115
  *
2072
2116
  * Setting this to "1" implicitly requests process DPI awareness (setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
2073
2117
  * and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
2074
- *
2118
+ *
2075
2119
  * This variable can be set to the following values:
2076
2120
  * "0" - SDL coordinates equal Windows coordinates. No automatic window resizing when dragging
2077
2121
  * between monitors with different scale factors (unless this is performed by
@@ -2082,7 +2126,7 @@ extern "C" {
2082
2126
  #define SDL_HINT_WINDOWS_DPI_SCALING "SDL_WINDOWS_DPI_SCALING"
2083
2127
 
2084
2128
  /**
2085
- * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
2129
+ * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
2086
2130
  *
2087
2131
  * This variable can be set to the following values:
2088
2132
  * "0" - The window frame is not interactive when the cursor is hidden (no move, resize, etc)
@@ -2093,7 +2137,7 @@ extern "C" {
2093
2137
  #define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"
2094
2138
 
2095
2139
  /**
2096
- * \brief A variable controlling whether the window is activated when the SDL_ShowWindow function is called
2140
+ * \brief A variable controlling whether the window is activated when the SDL_ShowWindow function is called
2097
2141
  *
2098
2142
  * This variable can be set to the following values:
2099
2143
  * "0" - The window is activated when the SDL_ShowWindow function is called
@@ -44,6 +44,7 @@
44
44
  #include "SDL_stdinc.h"
45
45
  #include "SDL_error.h"
46
46
  #include "SDL_guid.h"
47
+ #include "SDL_mutex.h"
47
48
 
48
49
  #include "begin_code.h"
49
50
  /* Set up for C function definitions, even when using C++ */
@@ -66,6 +67,9 @@ extern "C" {
66
67
  /**
67
68
  * The joystick structure used to identify an SDL joystick
68
69
  */
70
+ #ifdef SDL_THREAD_SAFETY_ANALYSIS
71
+ extern SDL_mutex *SDL_joystick_lock;
72
+ #endif
69
73
  struct _SDL_Joystick;
70
74
  typedef struct _SDL_Joystick SDL_Joystick;
71
75
 
@@ -131,7 +135,7 @@ typedef enum
131
135
  *
132
136
  * \since This function is available since SDL 2.0.7.
133
137
  */
134
- extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
138
+ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
135
139
 
136
140
 
137
141
  /**
@@ -146,7 +150,7 @@ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
146
150
  *
147
151
  * \since This function is available since SDL 2.0.7.
148
152
  */
149
- extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void);
153
+ extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
150
154
 
151
155
  /**
152
156
  * Count the number of joysticks attached to the system.
@@ -284,13 +288,12 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_in
284
288
  /**
285
289
  * Get the instance ID of a joystick.
286
290
  *
287
- * This can be called before any joysticks are opened. If the index is out of
288
- * range, this function will return -1.
291
+ * This can be called before any joysticks are opened.
289
292
  *
290
293
  * \param device_index the index of the joystick to query (the N'th joystick
291
294
  * on the system
292
295
  * \returns the instance id of the selected joystick. If called on an invalid
293
- * index, this function returns zero
296
+ * index, this function returns -1.
294
297
  *
295
298
  * \since This function is available since SDL 2.0.6.
296
299
  */
@@ -40,7 +40,7 @@
40
40
  * an SDLK_* constant for those keys that do not generate characters.
41
41
  *
42
42
  * A special exception is the number keys at the top of the keyboard which
43
- * always map to SDLK_0...SDLK_9, regardless of layout.
43
+ * map to SDLK_0...SDLK_9 on AZERTY layouts.
44
44
  */
45
45
  typedef Sint32 SDL_Keycode;
46
46
 
@@ -263,6 +263,13 @@ extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_fun
263
263
  */
264
264
  extern DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved);
265
265
 
266
+ /**
267
+ * Callback from the application to let the suspend continue.
268
+ *
269
+ * \since This function is available since SDL 2.28.0.
270
+ */
271
+ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
272
+
266
273
  #endif /* __GDK__ */
267
274
 
268
275
  #ifdef __cplusplus
@@ -198,13 +198,9 @@ extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
198
198
  /**
199
199
  * Set relative mouse mode.
200
200
  *
201
- * While the mouse is in relative mode, the cursor is hidden, and the driver
202
- * will try to report continuous motion in the current window. Only relative
203
- * motion events will be delivered, the mouse position will not change.
204
- *
205
- * Note that this function will not be able to provide continuous relative
206
- * motion when used over Microsoft Remote Desktop, instead motion is limited
207
- * to the bounds of the screen.
201
+ * While the mouse is in relative mode, the cursor is hidden, the mouse
202
+ * position is constrained to the window, and SDL will report continuous
203
+ * relative mouse motion even if the mouse is at the edge of the window.
208
204
  *
209
205
  * This function will flush any pending mouse motion.
210
206
  *
@@ -389,6 +385,9 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
389
385
  /**
390
386
  * Get the default cursor.
391
387
  *
388
+ * You do not have to call SDL_FreeCursor() on the return value, but it is
389
+ * safe to do so.
390
+ *
392
391
  * \returns the default cursor on success or NULL on failure.
393
392
  *
394
393
  * \since This function is available since SDL 2.0.0.
@@ -31,6 +31,80 @@
31
31
  #include "SDL_stdinc.h"
32
32
  #include "SDL_error.h"
33
33
 
34
+ /******************************************************************************/
35
+ /* Enable thread safety attributes only with clang.
36
+ * The attributes can be safely erased when compiling with other compilers.
37
+ */
38
+ #if defined(SDL_THREAD_SAFETY_ANALYSIS) && \
39
+ defined(__clang__) && (!defined(SWIG))
40
+ #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
41
+ #else
42
+ #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) /* no-op */
43
+ #endif
44
+
45
+ #define SDL_CAPABILITY(x) \
46
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
47
+
48
+ #define SDL_SCOPED_CAPABILITY \
49
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
50
+
51
+ #define SDL_GUARDED_BY(x) \
52
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
53
+
54
+ #define SDL_PT_GUARDED_BY(x) \
55
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
56
+
57
+ #define SDL_ACQUIRED_BEFORE(x) \
58
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x))
59
+
60
+ #define SDL_ACQUIRED_AFTER(x) \
61
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x))
62
+
63
+ #define SDL_REQUIRES(x) \
64
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x))
65
+
66
+ #define SDL_REQUIRES_SHARED(x) \
67
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x))
68
+
69
+ #define SDL_ACQUIRE(x) \
70
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x))
71
+
72
+ #define SDL_ACQUIRE_SHARED(x) \
73
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x))
74
+
75
+ #define SDL_RELEASE(x) \
76
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x))
77
+
78
+ #define SDL_RELEASE_SHARED(x) \
79
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x))
80
+
81
+ #define SDL_RELEASE_GENERIC(x) \
82
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x))
83
+
84
+ #define SDL_TRY_ACQUIRE(x, y) \
85
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y))
86
+
87
+ #define SDL_TRY_ACQUIRE_SHARED(x, y) \
88
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y))
89
+
90
+ #define SDL_EXCLUDES(x) \
91
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x))
92
+
93
+ #define SDL_ASSERT_CAPABILITY(x) \
94
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
95
+
96
+ #define SDL_ASSERT_SHARED_CAPABILITY(x) \
97
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
98
+
99
+ #define SDL_RETURN_CAPABILITY(x) \
100
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
101
+
102
+ #define SDL_NO_THREAD_SAFETY_ANALYSIS \
103
+ SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
104
+
105
+ /******************************************************************************/
106
+
107
+
34
108
  #include "begin_code.h"
35
109
  /* Set up for C function definitions, even when using C++ */
36
110
  #ifdef __cplusplus
@@ -96,7 +170,7 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
96
170
  *
97
171
  * \since This function is available since SDL 2.0.0.
98
172
  */
99
- extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
173
+ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex) SDL_ACQUIRE(mutex);
100
174
  #define SDL_mutexP(m) SDL_LockMutex(m)
101
175
 
102
176
  /**
@@ -119,7 +193,7 @@ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
119
193
  * \sa SDL_LockMutex
120
194
  * \sa SDL_UnlockMutex
121
195
  */
122
- extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
196
+ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex) SDL_TRY_ACQUIRE(0, mutex);
123
197
 
124
198
  /**
125
199
  * Unlock the mutex.
@@ -138,7 +212,7 @@ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
138
212
  *
139
213
  * \since This function is available since SDL 2.0.0.
140
214
  */
141
- extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
215
+ extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex) SDL_RELEASE(mutex);
142
216
  #define SDL_mutexV(m) SDL_UnlockMutex(m)
143
217
 
144
218
  /**
@@ -276,7 +350,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
276
350
  * successful it will atomically decrement the semaphore value.
277
351
  *
278
352
  * \param sem the semaphore to wait on
279
- * \param ms the length of the timeout, in milliseconds
353
+ * \param timeout the length of the timeout, in milliseconds
280
354
  * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
281
355
  * succeed in the allotted time, or a negative error code on failure;
282
356
  * call SDL_GetError() for more information.
@@ -290,7 +364,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
290
364
  * \sa SDL_SemValue
291
365
  * \sa SDL_SemWait
292
366
  */
293
- extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
367
+ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout);
294
368
 
295
369
  /**
296
370
  * Atomically increment a semaphore's value and wake waiting threads.
@@ -1,4 +1,8 @@
1
- #ifndef __gl_glext_h_
1
+ /* SDL modified the include guard to be compatible with Mesa and Apple include guards:
2
+ * - Mesa uses: __gl_glext_h_
3
+ * - Apple uses: __glext_h_ */
4
+ #if !defined(__glext_h_) && !defined(__gl_glext_h_)
5
+ #define __glext_h_ 1
2
6
  #define __gl_glext_h_ 1
3
7
 
4
8
  #ifdef __cplusplus
@@ -48,7 +48,6 @@ typedef enum
48
48
  SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
49
49
  } SDL_PowerState;
50
50
 
51
-
52
51
  /**
53
52
  * Get the current power supply details.
54
53
  *
@@ -65,17 +64,17 @@ typedef enum
65
64
  * It's possible a platform can only report battery percentage or time left
66
65
  * but not both.
67
66
  *
68
- * \param secs seconds of battery life left, you can pass a NULL here if you
69
- * don't care, will return -1 if we can't determine a value, or
70
- * we're not running on a battery
71
- * \param pct percentage of battery life left, between 0 and 100, you can pass
72
- * a NULL here if you don't care, will return -1 if we can't
73
- * determine a value, or we're not running on a battery
67
+ * \param seconds seconds of battery life left, you can pass a NULL here if
68
+ * you don't care, will return -1 if we can't determine a
69
+ * value, or we're not running on a battery
70
+ * \param percent percentage of battery life left, between 0 and 100, you can
71
+ * pass a NULL here if you don't care, will return -1 if we
72
+ * can't determine a value, or we're not running on a battery
74
73
  * \returns an SDL_PowerState enum representing the current battery state.
75
74
  *
76
75
  * \since This function is available since SDL 2.0.0.
77
76
  */
78
- extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);
77
+ extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent);
79
78
 
80
79
  /* Ends C function definitions when using C++ */
81
80
  #ifdef __cplusplus