gosu 1.3.0 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +108 -14
  3. data/dependencies/SDL/include/SDL_assert.h +81 -50
  4. data/dependencies/SDL/include/SDL_atomic.h +135 -35
  5. data/dependencies/SDL/include/SDL_audio.h +960 -355
  6. data/dependencies/SDL/include/SDL_bits.h +11 -6
  7. data/dependencies/SDL/include/SDL_blendmode.h +91 -14
  8. data/dependencies/SDL/include/SDL_clipboard.h +30 -7
  9. data/dependencies/SDL/include/SDL_config.h +277 -27
  10. data/dependencies/SDL/include/SDL_config_android.h +13 -38
  11. data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
  12. data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
  13. data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
  14. data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
  15. data/dependencies/SDL/include/SDL_config_psp.h +16 -37
  16. data/dependencies/SDL/include/SDL_config_windows.h +28 -91
  17. data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
  18. data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
  19. data/dependencies/SDL/include/SDL_copying.h +1 -1
  20. data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
  21. data/dependencies/SDL/include/SDL_egl.h +906 -280
  22. data/dependencies/SDL/include/SDL_endian.h +101 -47
  23. data/dependencies/SDL/include/SDL_error.h +70 -19
  24. data/dependencies/SDL/include/SDL_events.h +387 -79
  25. data/dependencies/SDL/include/SDL_filesystem.h +73 -64
  26. data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
  27. data/dependencies/SDL/include/SDL_gesture.h +36 -6
  28. data/dependencies/SDL/include/SDL_haptic.h +304 -210
  29. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  30. data/dependencies/SDL/include/SDL_hints.h +1286 -897
  31. data/dependencies/SDL/include/SDL_joystick.h +577 -130
  32. data/dependencies/SDL/include/SDL_keyboard.h +162 -63
  33. data/dependencies/SDL/include/SDL_keycode.h +7 -5
  34. data/dependencies/SDL/include/SDL_loadso.h +42 -8
  35. data/dependencies/SDL/include/SDL_locale.h +34 -32
  36. data/dependencies/SDL/include/SDL_log.h +212 -19
  37. data/dependencies/SDL/include/SDL_main.h +72 -17
  38. data/dependencies/SDL/include/SDL_messagebox.h +70 -23
  39. data/dependencies/SDL/include/SDL_metal.h +27 -32
  40. data/dependencies/SDL/include/SDL_misc.h +19 -15
  41. data/dependencies/SDL/include/SDL_mouse.h +262 -110
  42. data/dependencies/SDL/include/SDL_mutex.h +286 -66
  43. data/dependencies/SDL/include/SDL_name.h +1 -1
  44. data/dependencies/SDL/include/SDL_opengl.h +1 -1
  45. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  46. data/dependencies/SDL/include/SDL_opengles2.h +2 -2
  47. data/dependencies/SDL/include/SDL_pixels.h +199 -34
  48. data/dependencies/SDL/include/SDL_platform.h +39 -2
  49. data/dependencies/SDL/include/SDL_power.h +23 -10
  50. data/dependencies/SDL/include/SDL_quit.h +1 -1
  51. data/dependencies/SDL/include/SDL_rect.h +78 -28
  52. data/dependencies/SDL/include/SDL_render.h +1204 -472
  53. data/dependencies/SDL/include/SDL_revision.h +2 -2
  54. data/dependencies/SDL/include/SDL_rwops.h +605 -33
  55. data/dependencies/SDL/include/SDL_scancode.h +1 -1
  56. data/dependencies/SDL/include/SDL_sensor.h +76 -42
  57. data/dependencies/SDL/include/SDL_shape.h +38 -27
  58. data/dependencies/SDL/include/SDL_stdinc.h +96 -24
  59. data/dependencies/SDL/include/SDL_surface.h +571 -139
  60. data/dependencies/SDL/include/SDL_system.h +339 -101
  61. data/dependencies/SDL/include/SDL_syswm.h +50 -20
  62. data/dependencies/SDL/include/SDL_test.h +1 -1
  63. data/dependencies/SDL/include/SDL_test_assert.h +2 -2
  64. data/dependencies/SDL/include/SDL_test_common.h +23 -6
  65. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  66. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_font.h +3 -3
  68. data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
  69. data/dependencies/SDL/include/SDL_test_harness.h +6 -6
  70. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  71. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  72. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  73. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  74. data/dependencies/SDL/include/SDL_test_random.h +2 -2
  75. data/dependencies/SDL/include/SDL_thread.h +226 -128
  76. data/dependencies/SDL/include/SDL_timer.h +129 -22
  77. data/dependencies/SDL/include/SDL_touch.h +48 -8
  78. data/dependencies/SDL/include/SDL_types.h +1 -1
  79. data/dependencies/SDL/include/SDL_version.h +72 -46
  80. data/dependencies/SDL/include/SDL_video.h +1266 -460
  81. data/dependencies/SDL/include/SDL_vulkan.h +100 -161
  82. data/dependencies/SDL/include/begin_code.h +22 -1
  83. data/dependencies/SDL/include/close_code.h +1 -1
  84. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  85. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  86. data/dependencies/SDL_sound/SDL_sound.c +104 -70
  87. data/dependencies/SDL_sound/SDL_sound.h +6 -6
  88. data/dependencies/SDL_sound/SDL_sound_aiff.c +32 -32
  89. data/dependencies/SDL_sound/SDL_sound_au.c +14 -14
  90. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +6 -7
  91. data/dependencies/SDL_sound/SDL_sound_flac.c +28 -30
  92. data/dependencies/SDL_sound/SDL_sound_internal.h +21 -14
  93. data/dependencies/SDL_sound/SDL_sound_modplug.c +26 -28
  94. data/dependencies/SDL_sound/SDL_sound_mp3.c +20 -36
  95. data/dependencies/SDL_sound/SDL_sound_raw.c +15 -16
  96. data/dependencies/SDL_sound/SDL_sound_shn.c +11 -10
  97. data/dependencies/SDL_sound/SDL_sound_voc.c +20 -18
  98. data/dependencies/SDL_sound/SDL_sound_vorbis.c +11 -9
  99. data/dependencies/SDL_sound/SDL_sound_wav.c +49 -43
  100. data/dependencies/SDL_sound/dr_flac.h +10925 -4466
  101. data/dependencies/SDL_sound/dr_mp3.h +2802 -844
  102. data/dependencies/SDL_sound/libmodplug/fastmix.c +63 -64
  103. data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
  104. data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
  105. data/dependencies/SDL_sound/libmodplug/load_amf.c +12 -7
  106. data/dependencies/SDL_sound/libmodplug/load_ams.c +103 -44
  107. data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
  108. data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
  109. data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
  110. data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
  111. data/dependencies/SDL_sound/libmodplug/load_it.c +61 -61
  112. data/dependencies/SDL_sound/libmodplug/load_mdl.c +94 -58
  113. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -11
  114. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  115. data/dependencies/SDL_sound/libmodplug/load_mt2.c +50 -19
  116. data/dependencies/SDL_sound/libmodplug/load_okt.c +59 -28
  117. data/dependencies/SDL_sound/libmodplug/load_psm.c +104 -79
  118. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
  119. data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
  120. data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
  121. data/dependencies/SDL_sound/libmodplug/load_ult.c +4 -3
  122. data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
  123. data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
  124. data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
  125. data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
  126. data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
  127. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
  128. data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
  129. data/dependencies/SDL_sound/libmodplug/snd_fx.c +32 -19
  130. data/dependencies/SDL_sound/libmodplug/sndfile.c +76 -160
  131. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
  132. data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
  133. data/dependencies/SDL_sound/stb_vorbis.h +504 -329
  134. data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
  135. data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
  136. data/dependencies/mojoAL/mojoal.c +4848 -0
  137. data/dependencies/stb/stb_image.h +208 -73
  138. data/dependencies/stb/stb_image_write.h +57 -23
  139. data/dependencies/stb/stb_truetype.h +345 -279
  140. data/dependencies/utf8proc/utf8proc.c +37 -18
  141. data/dependencies/utf8proc/utf8proc.h +17 -5
  142. data/dependencies/utf8proc/utf8proc_data.h +12012 -10089
  143. data/ext/gosu/extconf.rb +29 -30
  144. data/include/Gosu/Audio.hpp +70 -85
  145. data/include/Gosu/Buttons.hpp +103 -103
  146. data/include/Gosu/Color.hpp +19 -11
  147. data/include/Gosu/Directories.hpp +31 -24
  148. data/include/Gosu/Font.hpp +42 -44
  149. data/include/Gosu/Gosu.hpp +5 -8
  150. data/include/Gosu/Graphics.hpp +58 -71
  151. data/include/Gosu/GraphicsBase.hpp +26 -33
  152. data/include/Gosu/IO.hpp +0 -3
  153. data/include/Gosu/Image.hpp +56 -62
  154. data/include/Gosu/ImageData.hpp +23 -27
  155. data/include/Gosu/Inspection.hpp +1 -4
  156. data/include/Gosu/Math.hpp +0 -3
  157. data/include/Gosu/TextInput.hpp +34 -40
  158. data/include/Gosu/Timing.hpp +2 -8
  159. data/include/Gosu/Version.hpp +2 -2
  160. data/include/Gosu/Window.hpp +71 -70
  161. data/lib/SDL2.dll +0 -0
  162. data/lib/gosu/compat.rb +24 -37
  163. data/lib/gosu.rb +2 -2
  164. data/lib64/SDL2.dll +0 -0
  165. data/src/Audio.cpp +88 -86
  166. data/src/AudioFile.hpp +6 -6
  167. data/src/AudioFileAudioToolbox.cpp +1 -1
  168. data/src/AudioFileSDLSound.cpp +1 -1
  169. data/src/AudioImpl.cpp +0 -7
  170. data/src/AudioImpl.hpp +6 -8
  171. data/src/BitmapIO.cpp +23 -22
  172. data/src/BlockAllocator.cpp +2 -1
  173. data/src/Channel.cpp +22 -20
  174. data/src/Color.cpp +12 -9
  175. data/src/DirectoriesApple.cpp +25 -24
  176. data/src/DirectoriesUnix.cpp +14 -12
  177. data/src/DirectoriesWin.cpp +26 -30
  178. data/src/EmptyImageData.hpp +15 -17
  179. data/src/FileUnix.cpp +1 -1
  180. data/src/FileWin.cpp +1 -1
  181. data/src/Font.cpp +59 -54
  182. data/src/Graphics.cpp +135 -143
  183. data/src/Image.cpp +41 -47
  184. data/src/Input.cpp +1 -1
  185. data/src/InputUIKit.cpp +1 -1
  186. data/src/LargeImageData.cpp +108 -101
  187. data/src/LargeImageData.hpp +17 -15
  188. data/src/Log.hpp +6 -6
  189. data/src/Macro.cpp +35 -37
  190. data/src/Macro.hpp +11 -11
  191. data/src/Math.cpp +8 -1
  192. data/src/Resolution.cpp +12 -7
  193. data/src/RubyGosu.cxx +11 -39
  194. data/src/TexChunk.cpp +50 -41
  195. data/src/TexChunk.hpp +22 -22
  196. data/src/Text.cpp +37 -37
  197. data/src/TextBuilder.cpp +60 -57
  198. data/src/TextBuilder.hpp +20 -20
  199. data/src/TextInput.cpp +127 -135
  200. data/src/TimingApple.cpp +1 -7
  201. data/src/TimingUnix.cpp +0 -6
  202. data/src/TimingWin.cpp +0 -6
  203. data/src/TrueTypeFont.cpp +107 -107
  204. data/src/TrueTypeFont.hpp +39 -38
  205. data/src/TrueTypeFontApple.cpp +19 -22
  206. data/src/TrueTypeFontUnix.cpp +21 -26
  207. data/src/TrueTypeFontWin.cpp +30 -30
  208. data/src/Window.cpp +97 -87
  209. data/src/WindowUIKit.cpp +46 -49
  210. metadata +7 -17
  211. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  212. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  213. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  214. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  215. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  216. data/dependencies/al_soft/AL/alext.h +0 -585
  217. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  218. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  219. data/dependencies/al_soft/AL/efx.h +0 -762
  220. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  221. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  222. data/lib/OpenAL32.dll +0 -0
  223. data/lib64/OpenAL32.dll +0 -0
@@ -1,36 +1,43 @@
1
- //! \file Directories.hpp
2
- //! Access to a small set of system paths.
3
-
4
1
  #pragma once
5
2
 
6
3
  #include <string>
7
4
 
8
5
  namespace Gosu
9
6
  {
10
- //! Changes the current directory to the result of resource_prefix().
7
+ /// Changes the current directory to the result of resource_prefix().
11
8
  void use_resource_directory();
12
9
 
13
- //! Prefix for a program's own resources.
14
- //! On Windows, the parent directory of the executable.
15
- //! On macOS, the 'Resources' directory inside the .app bundle.
16
- //! On Linux, the current directory (empty string).
17
- std::string resource_prefix();
10
+ /// Prefix for a program's own resources.
11
+ /// <ul>
12
+ /// <li> Windows: The parent directory of the executable.
13
+ /// <li> macOS, iOS: The 'Resources' directory inside the .app bundle.
14
+ /// <li> Linux: The current directory (empty string).
15
+ /// </ul>
16
+ const std::string& resource_prefix();
18
17
 
19
- //! Prefix for shared resources of a group of programs.
20
- //! On Windows, the parent directory of the executable.
21
- //! On macOS, the parent directory of the .app bundle.
22
- //! On Linux, the current directory (empty string).
23
- std::string shared_resource_prefix();
18
+ /// Prefix for shared resources of a group of programs, e.g. the game and its level editor.
19
+ /// <ul>
20
+ /// <li> Windows: The parent directory of the executable.
21
+ /// <li> macOS: The parent directory of the .app bundle.
22
+ /// <li> Linux: The current directory (empty string).
23
+ /// </uil>
24
+ const std::string& shared_resource_prefix();
24
25
 
25
- //! Prefix for user settings.
26
- //! On Windows, the same as %APPDATA%.
27
- //! On macOS, the user's Library/Preferences folder.
28
- //! On Linux, the home directory plus a trailing dot for hidden files.
29
- std::string user_settings_prefix();
26
+ /// Prefix for user settings.
27
+ /// <ul>
28
+ /// <li> Windows: The same as %APPDATA%.
29
+ /// <li> macOS: The user's Library/Preferences folder.
30
+ /// <li> Linux: The home directory plus a trailing dot for hidden files.
31
+ /// </ul>
32
+ const std::string& user_settings_prefix();
30
33
 
31
- //! Prefix for user documents, e.g. saved games.
32
- //! On Windows, the My Documents folder.
33
- //! On macOS, the user's Documents folder.
34
- //! On Linux, the home directory.
35
- std::string user_documents_prefix();
34
+ /// Prefix for user documents, e.g. saved games.
35
+ /// <ul>
36
+ /// <li> Windows: The "My Documents" folder.
37
+ /// <li> macOS: The user's "Documents" folder.
38
+ /// <li> Linux: The home directory.
39
+ /// </ul>
40
+ const std::string& user_documents_prefix();
41
+
42
+ // TODO: Instead of re-inventing wheels here, we should wrap SDL_GetBasePath / SDL_GetPrefPath.
36
43
  }
@@ -1,6 +1,3 @@
1
- //! \file Font.hpp
2
- //! Interface of the Font class.
3
-
4
1
  #pragma once
5
2
 
6
3
  #include <Gosu/Fwd.hpp>
@@ -13,66 +10,67 @@
13
10
 
14
11
  namespace Gosu
15
12
  {
16
- //! Fonts are ideal for drawing short, dynamic strings.
17
- //! For large, static texts you should use Gosu::layout_text and turn the result into an image.
13
+ /// A simple bitmap font that renders and caches glyphs on demand.
14
+ /// For large, static texts you should use Gosu::layout_text and turn the result into an image.
18
15
  class Font
19
16
  {
20
17
  struct Impl;
21
- std::shared_ptr<Impl> pimpl;
18
+ std::shared_ptr<Impl> m_impl;
22
19
 
23
20
  public:
24
- //! Constructs a font that can be drawn onto the graphics object.
25
- //! \param name Name of a system font, or a filename to a TTF file.
26
- //! \param height Height of the font, in pixels.
27
- //! \param flags Flags used to render individual characters of the font.
28
- Font(int height, const std::string& name = default_font_name(), unsigned flags = 0);
29
-
30
- //! Returns the name of the font that was used to create it.
21
+ /// @param name Name of a system font, or path to a TTF file (must contain '/').
22
+ /// @param height Height of the font, in pixels.
23
+ /// @param font_flags Flags used to render individual characters of the font (FontFlags enum).
24
+ /// @param image_flags Flags used to render individual characters of the font (ImageFlags enum).
25
+ explicit Font(int height, const std::string& name = default_font_name(),
26
+ unsigned font_flags = 0, unsigned image_flags = 0);
27
+
28
+ /// Returns the name of the font that was used to create it, i.e. the filename, nor the
29
+ /// internal TTF name. (TODO: Why not?)
31
30
  const std::string& name() const;
32
-
33
- //! Returns the height of the font, in pixels.
31
+
32
+ /// Returns the height of the font, in pixels.
34
33
  int height() const;
35
-
36
- //! Returns the flags used to create the font characters.
34
+
35
+ /// Returns the flags used to render the characters of the font (FontFlags enum).
37
36
  unsigned flags() const;
38
-
39
- //! Returns the width, in pixels, the given text would occupy if drawn.
37
+ unsigned image_flags() const;
38
+
39
+ /// Returns the width, in pixels, that the given text would occupy if drawn.
40
40
  double text_width(const std::string& text) const;
41
- //! Returns the width, in pixels, the given markup would occupy if drawn.
41
+ /// Returns the width, in pixels, that the given markup would occupy if drawn.
42
42
  double markup_width(const std::string& markup) const;
43
-
44
- //! Draws text so the top left corner of the text is at (x; y).
45
- void draw_text(const std::string& text, double x, double y, ZPos z,
43
+
44
+ /// Draws text so the top left corner of the text is at (x; y).
45
+ void draw_text(const std::string& text, double x, double y, ZPos z, //
46
46
  double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
47
47
  BlendMode mode = BM_DEFAULT) const;
48
- //! Draws markup so the top left corner of the text is at (x; y).
49
- void draw_markup(const std::string& markup, double x, double y, ZPos z,
48
+ /// Draws markup so the top left corner of the text is at (x; y).
49
+ void draw_markup(const std::string& markup, double x, double y, ZPos z, //
50
50
  double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
51
51
  BlendMode mode = BM_DEFAULT) const;
52
-
53
- //! Draws text at a position relative to (x; y).
54
- //! \param rel_x Determines where the text is drawn horizontally. If
55
- //! rel_x is 0.0, the text will be to the right of x, if it is 1.0,
56
- //! the text will be to the left of x, if it is 0.5, it will be
57
- //! centered on x. All real numbers are possible values.
58
- //! \param rel_y See rel_x.
59
- void draw_text_rel(const std::string& text, double x, double y, ZPos z,
52
+
53
+ /// Draws text at a position relative to (x; y).
54
+ /// @param rel_x Determines where the text is drawn horizontally. If rel_x is 0.0, the text
55
+ /// will be to the right of x, if it is 1.0, the text will be to the left of x, if it is
56
+ /// 0.5, it will be centered on x.
57
+ /// @param rel_y See rel_x.
58
+ void draw_text_rel(const std::string& text, double x, double y, ZPos z, //
60
59
  double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
61
60
  Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
62
- //! Draws text at a position relative to (x; y).
63
- //! \param rel_x Determines where the text is drawn horizontally. If
64
- //! rel_x is 0.0, the text will be to the right of x, if it is 1.0,
65
- //! the text will be to the left of x, if it is 0.5, it will be
66
- //! centered on x. All real numbers are possible values.
67
- //! \param rel_y See rel_x.
68
- void draw_markup_rel(const std::string& markup, double x, double y, ZPos z,
61
+ /// Draws markup at a position relative to (x; y).
62
+ /// @param rel_x Determines where the text is drawn horizontally. If rel_x is 0.0, the text
63
+ /// will be to the right of x, if it is 1.0, the text will be to the left of x, if it is
64
+ /// 0.5, it will be centered on x.
65
+ /// @param rel_y See rel_x.
66
+ void draw_markup_rel(const std::string& markup, double x, double y, ZPos z, //
69
67
  double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
70
68
  Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
71
-
72
- //! Maps a letter to a specific image, instead of generating one using
73
- //! Gosu's built-in text rendering.
69
+
70
+ /// Maps a letter to a specific image, instead of generating one using Gosu's built-in text
71
+ /// rendering.
74
72
  void set_image(std::string codepoint, unsigned font_flags, const Gosu::Image& image);
75
- //! A shortcut for mapping a character to an image regardless of font_flags.
73
+ /// A shortcut for mapping a character to an image regardless of font_flags.
76
74
  void set_image(std::string codepoint, const Gosu::Image& image);
77
75
  };
78
76
  }
@@ -1,11 +1,8 @@
1
- //! \file Gosu.hpp
2
- //! Umbrella header for all of Gosu.
3
-
4
- //! \mainpage Gosu C++ Documentation
5
- //!
6
- //! These pages serve as a reference on the C++ interface of Gosu. For a higher-level
7
- //! discussion of concepts and ideas behind the library, see the Wiki entries linked
8
- //! from the official website, https://www.libgosu.org/.
1
+ /// \mainpage Gosu C++ Documentation
2
+ ///
3
+ /// These pages serve as a reference on the C++ interface of Gosu. For a higher-level
4
+ /// discussion of concepts and ideas behind the library, see the Wiki entries linked
5
+ /// from the official website, https://www.libgosu.org/.
9
6
 
10
7
  #pragma once
11
8
 
@@ -1,6 +1,3 @@
1
- //! \file Graphics.hpp
2
- //! Interface of the Graphics class.
3
-
4
1
  #pragma once
5
2
 
6
3
  #include <Gosu/Fwd.hpp>
@@ -12,19 +9,17 @@
12
9
  namespace Gosu
13
10
  {
14
11
  struct DrawOp;
15
-
16
- //! Returns the maximum size of an texture that will be allocated
17
- //! internally by Gosu.
18
- //! Useful when extending Gosu using OpenGL.
12
+
13
+ /// Returns the maximum size of an texture that will be allocated internally by Gosu.
14
+ /// Useful when extending Gosu using OpenGL.
19
15
  const unsigned MAX_TEXTURE_SIZE = 1024;
20
-
21
- //! Serves as the target of all drawing and provides primitive drawing
22
- //! functionality.
23
- //! Usually created internally by Gosu::Window.
16
+
17
+ /// Serves as the target of all drawing and provides primitive drawing functionality.
18
+ /// Usually created internally by Gosu::Window.
24
19
  class Graphics
25
20
  {
26
21
  struct Impl;
27
- std::unique_ptr<Impl> pimpl;
22
+ std::unique_ptr<Impl> m_impl;
28
23
 
29
24
  public:
30
25
  Graphics(unsigned physical_width, unsigned physical_height);
@@ -32,80 +27,72 @@ namespace Gosu
32
27
 
33
28
  void set_resolution(unsigned logical_width, unsigned logical_height,
34
29
  double black_bar_width = 0, double black_bar_height = 0);
35
-
30
+
36
31
  unsigned width() const;
37
32
  unsigned height() const;
38
33
 
39
- //! Prepares the graphics object for drawing and then runs the rendering code in f.
40
- //! Nothing must be drawn outside of frame() and record().
41
- void frame(const std::function<void ()>& f);
42
-
43
- //! Flushes the Z queue to the screen and starts a new one.
44
- //! This can be useful to separate the Z queues of two parts of the game, e.g. the two
45
- //! halves of a game that runs in split-screen mode.
34
+ /// Prepares the graphics object for drawing and then runs the rendering code in f.
35
+ /// Nothing must be drawn outside of frame() and record().
36
+ void frame(const std::function<void()>& f);
37
+
38
+ /// Flushes the Z queue to the screen and starts a new one.
39
+ /// This can be useful to separate the Z queues of two parts of the game, e.g. the two
40
+ /// halves of a game that runs in split-screen mode.
46
41
  static void flush();
47
-
48
- //! Finishes all pending Gosu drawing operations and executes the code in f in a clean
49
- //! OpenGL environment.
50
- static void gl(const std::function<void ()>& f);
51
-
52
- //! Schedules a custom GL functor to be executed at a certain Z level.
53
- //! The functor f is run in a clean GL context.
54
- //! Note: You may not call any Gosu rendering functions from within the
55
- //! functor.
56
- static void gl(ZPos z, const std::function<void ()>& f);
57
-
58
- //! Renders everything drawn in f clipped to a rectangle on the screen.
42
+
43
+ /// Finishes all pending Gosu drawing operations and executes the code in f in a clean
44
+ /// OpenGL environment.
45
+ static void gl(const std::function<void()>& f);
46
+
47
+ /// Schedules a custom GL functor to be executed at a certain Z level.
48
+ /// The functor f is run in a clean GL context.
49
+ /// Note: You may not call any Gosu rendering functions from within the functor.
50
+ static void gl(ZPos z, const std::function<void()>& f);
51
+
52
+ /// Renders everything drawn in f clipped to a rectangle on the screen.
59
53
  static void clip_to(double x, double y, double width, double height,
60
- const std::function<void ()>& f);
61
-
62
- //! Renders everything drawn in f onto a new Image of size (width, height).
63
- //! \param image_flags Pass Gosu::IF_RETRO if you do not want the resulting image to use
64
- //! interpolation when it is scaled or rotated.
65
- static Gosu::Image render(int width, int height, const std::function<void ()>& f,
54
+ const std::function<void()>& f);
55
+
56
+ /// Renders everything drawn in f onto a new Image of size (width, height).
57
+ /// @param image_flags Pass Gosu::IF_RETRO if you do not want the resulting image to use
58
+ /// interpolation when it is scaled or rotated.
59
+ static Gosu::Image render(int width, int height, const std::function<void()>& f,
66
60
  unsigned image_flags = 0);
67
-
68
- //! Records a macro and returns it as an Image.
69
- static Gosu::Image record(int width, int height, const std::function<void ()>& f);
70
-
71
- //! Pushes one transformation onto the transformation stack.
72
- static void transform(const Transform& transform,
73
- const std::function<void ()>& f);
74
-
75
- //! Draws a line from one point to another (last pixel exclusive).
76
- //! Note: OpenGL lines are not reliable at all and may have a missing pixel at the start
77
- //! or end point. Please only use this for debugging purposes. Otherwise, use a quad or
78
- //! image to simulate lines, or contribute a better draw_line to Gosu.
79
- static void draw_line(double x1, double y1, Color c1,
80
- double x2, double y2, Color c2,
61
+
62
+ /// Records a macro and returns it as an Image.
63
+ static Gosu::Image record(int width, int height, const std::function<void()>& f);
64
+
65
+ /// Pushes one transformation onto the transformation stack.
66
+ static void transform(const Transform& transform, const std::function<void()>& f);
67
+
68
+ /// Draws a line from one point to another (last pixel exclusive).
69
+ /// Note: OpenGL lines are not reliable at all and may have a missing pixel at the start
70
+ /// or end point. Please only use this for debugging purposes. Otherwise, use a quad or
71
+ /// image to simulate lines, or contribute a better draw_line to Gosu.
72
+ static void draw_line(double x1, double y1, Color c1, double x2, double y2, Color c2,
81
73
  ZPos z, BlendMode mode = BM_DEFAULT);
82
74
 
83
- static void draw_triangle(double x1, double y1, Color c1,
84
- double x2, double y2, Color c2,
85
- double x3, double y3, Color c3,
86
- ZPos z,
87
- BlendMode mode = BM_DEFAULT);
75
+ static void draw_triangle(double x1, double y1, Color c1, //
76
+ double x2, double y2, Color c2, //
77
+ double x3, double y3, Color c3, //
78
+ ZPos z, BlendMode mode = BM_DEFAULT);
88
79
 
89
- static void draw_quad(double x1, double y1, Color c1,
90
- double x2, double y2, Color c2,
91
- double x3, double y3, Color c3,
92
- double x4, double y4, Color c4,
80
+ static void draw_quad(double x1, double y1, Color c1, double x2, double y2, Color c2,
81
+ double x3, double y3, Color c3, double x4, double y4, Color c4,
93
82
  ZPos z, BlendMode mode = BM_DEFAULT);
94
-
95
- static void draw_rect(double x, double y, double width, double height,
96
- Color c, ZPos z,
83
+
84
+ static void draw_rect(double x, double y, double width, double height, Color c, ZPos z,
97
85
  BlendMode mode = BM_DEFAULT);
98
86
 
99
- //! For internal use only.
87
+ /// For internal use only.
100
88
  void set_physical_resolution(unsigned physical_width, unsigned physical_height);
101
89
 
102
- //! For internal use only.
90
+ /// For internal use only.
103
91
  static void schedule_draw_op(const DrawOp& op);
104
92
 
105
- //! Turns a portion of a bitmap into something that can be drawn on a Graphics object.
106
- static std::unique_ptr<ImageData> create_image(const Bitmap& src,
107
- unsigned src_x, unsigned src_y,
108
- unsigned src_width, unsigned src_height,
109
- unsigned image_flags);
93
+ /// Turns a portion of a bitmap into something that can be drawn on a Graphics object.
94
+ static std::unique_ptr<ImageData> create_image(const Bitmap& src, unsigned src_x,
95
+ unsigned src_y, unsigned src_width,
96
+ unsigned src_height, unsigned image_flags);
110
97
  };
111
98
  }
@@ -1,6 +1,3 @@
1
- //! \file GraphicsBase.hpp
2
- //! Contains general typedefs and enums related to graphics.
3
-
4
1
  #pragma once
5
2
 
6
3
  #include <Gosu/Platform.hpp>
@@ -8,35 +5,32 @@
8
5
 
9
6
  namespace Gosu
10
7
  {
11
- //! Represents the Z position of something drawn with Gosu's graphics
12
- //! system. Draw calls with higher ZPos values will cover those with a
13
- //! lower ZPos value.
8
+ /// Represents the Z position of something drawn with Gosu's graphics system.
9
+ /// Draw calls with higher ZPos values will cover those with a lower ZPos value.
14
10
  typedef double ZPos;
15
-
16
- //! Determines the way colors are combined when one is drawn onto
17
- //! another.
11
+
12
+ /// Determines the way pixel colors are combined when images overlap.
18
13
  enum BlendMode
19
14
  {
20
15
  BM_DEFAULT,
21
- //! The color's channels will be interpolated. The alpha channel
22
- //! specifies the opacity of the new color, 255 is full opacity.
16
+ /// The color's channels will be interpolated. The alpha channel specifies the opacity of
17
+ /// the new color, 255 is full opacity.
23
18
  BM_INTERPOLATE = BM_DEFAULT,
24
- //! The colors' channels will be added. The alpha channel specifies
25
- //! the percentage of the new color's channels that will be added
26
- //! to the old color's channels.
19
+ /// The colors' channels will be added. The alpha channel specifies the percentage of the
20
+ /// new color's channels that will be added to the old color's channels.
27
21
  BM_ADD,
28
- //! The color's channels will be multiplied with each other.
22
+ /// The color's channels will be multiplied with each other.
29
23
  BM_MULTIPLY
30
24
  };
31
-
25
+
32
26
  enum FontFlags
33
27
  {
34
- FF_BOLD = 1,
35
- FF_ITALIC = 2,
36
- FF_UNDERLINE = 4,
28
+ FF_BOLD = 1,
29
+ FF_ITALIC = 2,
30
+ FF_UNDERLINE = 4,
37
31
  FF_COMBINATIONS = 8
38
32
  };
39
-
33
+
40
34
  enum Alignment
41
35
  {
42
36
  AL_LEFT,
@@ -44,26 +38,25 @@ namespace Gosu
44
38
  AL_CENTER,
45
39
  AL_JUSTIFY
46
40
  };
47
-
48
- //! Flags that affect the tileability or interpolation of an image.
41
+
42
+ /// Flags that affect the tileability or interpolation of an image.
49
43
  enum ImageFlags
50
44
  {
51
45
  IF_SMOOTH = 0,
52
-
46
+
53
47
  // Note: No constant for '1', but Gosu treats '1' as IF_TILEABLE for
54
48
  // backward compatibility reasons (this parameter used to be a bool).
55
-
56
- IF_TILEABLE_LEFT = 1 << 1,
57
- IF_TILEABLE_TOP = 1 << 2,
58
- IF_TILEABLE_RIGHT = 1 << 3,
49
+
50
+ IF_TILEABLE_LEFT = 1 << 1,
51
+ IF_TILEABLE_TOP = 1 << 2,
52
+ IF_TILEABLE_RIGHT = 1 << 3,
59
53
  IF_TILEABLE_BOTTOM = 1 << 4,
60
- IF_TILEABLE = IF_TILEABLE_LEFT | IF_TILEABLE_TOP | IF_TILEABLE_RIGHT | IF_TILEABLE_BOTTOM,
61
-
62
- //! Apply nearest-neighbor interpolation when scaling this image up or
63
- //! down.
64
- IF_RETRO = 1 << 5
54
+ IF_TILEABLE = IF_TILEABLE_LEFT | IF_TILEABLE_TOP | IF_TILEABLE_RIGHT | IF_TILEABLE_BOTTOM,
55
+
56
+ /// Apply nearest-neighbor interpolation when scaling this image up or down.
57
+ IF_RETRO = 1 << 5
65
58
  };
66
-
59
+
67
60
  typedef std::array<double, 16> Transform;
68
61
  Transform translate(double x, double y);
69
62
  Transform rotate(double angle, double around_x = 0, double around_y = 0);
data/include/Gosu/IO.hpp CHANGED
@@ -1,6 +1,3 @@
1
- //! \file IO.hpp
2
- //! Contains everything related to input and output.
3
-
4
1
  #pragma once
5
2
 
6
3
  #include <Gosu/Platform.hpp>
@@ -1,6 +1,3 @@
1
- //! \file Image.hpp
2
- //! Interface of the Image class and helper functions.
3
-
4
1
  #pragma once
5
2
 
6
3
  #include <Gosu/Fwd.hpp>
@@ -12,80 +9,77 @@
12
9
 
13
10
  namespace Gosu
14
11
  {
15
- //! Provides functionality for drawing rectangular images.
12
+ /// Provides functionality for drawing rectangular images.
16
13
  class Image
17
14
  {
18
- std::shared_ptr<ImageData> data_;
15
+ std::shared_ptr<ImageData> m_data;
19
16
 
20
17
  public:
21
- //! Creates an empty image. It will have a width and height of 0, and not contain anything.
18
+ /// Creates an empty image. It will have a width and height of 0, and not contain anything.
22
19
  Image();
23
-
24
- //! Loads an image from a given filename.
25
- //!
26
- //! A color key of #ff00ff is automatically applied to BMP image files.
27
- //! For more flexibility, use the corresponding constructor that uses a Bitmap object.
20
+
21
+ /// Loads an image from a given filename.
22
+ ///
23
+ /// A color key of #ff00ff is automatically applied to BMP image files.
24
+ /// For more flexibility, use the corresponding constructor that uses a Bitmap object.
28
25
  explicit Image(const std::string& filename, unsigned image_flags = IF_SMOOTH);
29
-
26
+
30
27
  //! Loads a portion of the the image at the given filename..
31
- //!
32
- //! A color key of #ff00ff is automatically applied to BMP image files.
33
- //! For more flexibility, use the corresponding constructor that uses a Bitmap object.
34
- Image(const std::string& filename, int src_x, int src_y,
35
- int src_width, int src_height, unsigned image_flags = IF_SMOOTH);
36
-
37
- //! Converts the given bitmap into an image.
28
+ ///
29
+ /// A color key of #ff00ff is automatically applied to BMP image files.
30
+ /// For more flexibility, use the corresponding constructor that uses a Bitmap object.
31
+ Image(const std::string& filename, int src_x, int src_y, int src_width, int src_height,
32
+ unsigned image_flags = IF_SMOOTH);
33
+
34
+ /// Converts the given bitmap into an image.
38
35
  explicit Image(const Bitmap& source, unsigned image_flags = IF_SMOOTH);
39
-
40
- //! Converts a portion of the given bitmap into an image.
41
- Image(const Bitmap& source, int src_x, int src_y, int src_width,
42
- int src_height, unsigned image_flags = IF_SMOOTH);
43
-
44
- //! Creates an Image from a user-supplied instance of the ImageData interface.
36
+
37
+ /// Converts a portion of the given bitmap into an image.
38
+ Image(const Bitmap& source, int src_x, int src_y, int src_width, int src_height,
39
+ unsigned image_flags = IF_SMOOTH);
40
+
41
+ /// Creates an Image from a user-supplied instance of the ImageData interface.
45
42
  explicit Image(std::unique_ptr<ImageData>&& data);
46
43
 
47
44
  unsigned width() const;
48
45
  unsigned height() const;
49
46
 
50
- //! Draws the image so its upper left corner is at (x; y).
47
+ /// Draws the image so its upper left corner is at (x; y).
51
48
  void draw(double x, double y, ZPos z = 0, double scale_x = 1, double scale_y = 1,
52
- Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
53
- //! Like draw(), but with modulation colors for all four corners.
54
- void draw_mod(double x, double y, ZPos z, double scale_x, double scale_y,
55
- Color c1, Color c2, Color c3, Color c4, BlendMode mode = BM_DEFAULT) const;
49
+ Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
50
+ /// Like draw(), but with modulation colors for all four corners.
51
+ void draw_mod(double x, double y, ZPos z, double scale_x, double scale_y, Color c1,
52
+ Color c2, Color c3, Color c4, BlendMode mode = BM_DEFAULT) const;
53
+
54
+ /// Draws the image rotated by the given angle so that its rotation center is at (x; y).
55
+ /// Note that this is different from how all the other drawing functions work!
56
+ /// @param angle See Math.hpp for an explanation of how Gosu interprets angles.
57
+ /// @param center_x Relative horizontal position of the rotation center on the image.
58
+ /// 0 is the left border, 1 is the right border, 0.5 is the center (and default).
59
+ /// @param center_y See center_x.
60
+ void draw_rot(double x, double y, ZPos z = 0, double angle = 0, double center_x = 0.5,
61
+ double center_y = 0.5, double scale_x = 1, double scale_y = 1,
62
+ Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
56
63
 
57
- //! Draws the image rotated by the given angle so that its rotation
58
- //! center is at (x; y). Note that this is different from how all the
59
- //! other drawing functions work!
60
- //! \param angle See Math.hpp for an explanation of how Gosu interprets
61
- //! angles.
62
- //! \param center_x Relative horizontal position of the rotation center
63
- //! on the image. 0 is the left border, 1 is the right border, 0.5 is
64
- //! the center (and default).
65
- //! \param center_y See center_x.
66
- void draw_rot(double x, double y, ZPos z = 0, double angle = 0,
67
- double center_x = 0.5, double center_y = 0.5, double scale_x = 1, double scale_y = 1,
68
- Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
69
-
70
- #ifndef SWIG
71
- //! Provides access to the underlying image data object.
64
+ #ifndef SWIG
65
+ /// Provides access to the underlying image data object.
72
66
  ImageData& data() const;
73
- #endif
67
+ #endif
74
68
  };
75
-
76
- #ifndef SWIG
77
- //! Convenience function that slices an image file into a grid and creates images from them.
78
- //! \param tile_width If positive, specifies the width of one tile in pixels.
79
- //! If negative, the bitmap is divided into -tile_width rows.
80
- //! \param tile_height See tile_width.
81
- std::vector<Gosu::Image> load_tiles(const Bitmap& bmp,
82
- int tile_width, int tile_height, unsigned image_flags = IF_SMOOTH);
83
-
84
- //! Convenience function that slices a bitmap into a grid and creates images from them.
85
- //! \param tile_width If positive, specifies the width of one tile in pixels.
86
- //! If negative, the bitmap is divided into -tile_width rows.
87
- //! \param tile_height See tile_width.
88
- std::vector<Gosu::Image> load_tiles(const std::string& filename,
89
- int tile_width, int tile_height, unsigned image_flags = IF_SMOOTH);
90
- #endif
69
+
70
+ #ifndef SWIG
71
+ /// Convenience function that slices an image file into a grid and creates images from them.
72
+ /// @param tile_width If positive, specifies the width of one tile in pixels.
73
+ /// If negative, the bitmap is divided into -tile_width rows.
74
+ /// @param tile_height See tile_width.
75
+ std::vector<Gosu::Image> load_tiles(const Bitmap& bmp, int tile_width, int tile_height,
76
+ unsigned image_flags = IF_SMOOTH);
77
+
78
+ /// Convenience function that slices a bitmap into a grid and creates images from them.
79
+ /// @param tile_width If positive, specifies the width of one tile in pixels.
80
+ /// If negative, the bitmap is divided into -tile_width rows.
81
+ /// @param tile_height See tile_width.
82
+ std::vector<Gosu::Image> load_tiles(const std::string& filename, int tile_width,
83
+ int tile_height, unsigned image_flags = IF_SMOOTH);
84
+ #endif
91
85
  }