gosu 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) 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 +83 -7
  87. data/dependencies/SDL_sound/SDL_sound.h +4 -4
  88. data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
  89. data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
  90. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
  91. data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
  92. data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
  93. data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
  94. data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
  95. data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
  96. data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
  97. data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
  98. data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
  99. data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
  100. data/dependencies/SDL_sound/dr_flac.h +618 -220
  101. data/dependencies/SDL_sound/dr_mp3.h +263 -94
  102. data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -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 +11 -7
  106. data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
  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 +45 -49
  112. data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
  113. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
  114. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  115. data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
  116. data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
  117. data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
  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 +2 -2
  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 +24 -18
  130. data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
  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 +508 -325
  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 +4594 -0
  137. data/ext/gosu/extconf.rb +29 -30
  138. data/include/Gosu/Audio.hpp +70 -85
  139. data/include/Gosu/Color.hpp +19 -11
  140. data/include/Gosu/Font.hpp +40 -44
  141. data/include/Gosu/Graphics.hpp +58 -71
  142. data/include/Gosu/GraphicsBase.hpp +26 -33
  143. data/include/Gosu/Image.hpp +56 -62
  144. data/include/Gosu/ImageData.hpp +23 -27
  145. data/include/Gosu/Inspection.hpp +1 -4
  146. data/include/Gosu/TextInput.hpp +34 -40
  147. data/include/Gosu/Version.hpp +1 -1
  148. data/include/Gosu/Window.hpp +71 -70
  149. data/lib/SDL2.dll +0 -0
  150. data/lib/gosu/compat.rb +24 -37
  151. data/lib/gosu.rb +2 -2
  152. data/lib64/SDL2.dll +0 -0
  153. data/src/Audio.cpp +86 -86
  154. data/src/AudioFile.hpp +6 -6
  155. data/src/AudioFileAudioToolbox.cpp +1 -1
  156. data/src/AudioFileSDLSound.cpp +1 -1
  157. data/src/AudioImpl.hpp +5 -5
  158. data/src/BitmapIO.cpp +0 -20
  159. data/src/BlockAllocator.cpp +2 -1
  160. data/src/Channel.cpp +22 -20
  161. data/src/Color.cpp +12 -9
  162. data/src/EmptyImageData.hpp +15 -17
  163. data/src/FileUnix.cpp +1 -1
  164. data/src/FileWin.cpp +1 -1
  165. data/src/Font.cpp +48 -53
  166. data/src/Graphics.cpp +135 -143
  167. data/src/Image.cpp +41 -42
  168. data/src/Input.cpp +1 -1
  169. data/src/InputUIKit.cpp +1 -1
  170. data/src/LargeImageData.cpp +108 -101
  171. data/src/LargeImageData.hpp +17 -15
  172. data/src/Log.hpp +6 -6
  173. data/src/Macro.cpp +35 -37
  174. data/src/Macro.hpp +11 -11
  175. data/src/Math.cpp +8 -1
  176. data/src/Resolution.cpp +12 -7
  177. data/src/RubyGosu.cxx +5 -5
  178. data/src/TexChunk.cpp +50 -41
  179. data/src/TexChunk.hpp +22 -22
  180. data/src/Text.cpp +37 -37
  181. data/src/TextBuilder.cpp +60 -57
  182. data/src/TextBuilder.hpp +20 -20
  183. data/src/TextInput.cpp +127 -135
  184. data/src/TrueTypeFont.cpp +107 -107
  185. data/src/TrueTypeFont.hpp +39 -38
  186. data/src/TrueTypeFontApple.cpp +19 -22
  187. data/src/TrueTypeFontUnix.cpp +21 -26
  188. data/src/TrueTypeFontWin.cpp +30 -30
  189. data/src/Window.cpp +95 -86
  190. data/src/WindowUIKit.cpp +46 -49
  191. metadata +7 -17
  192. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  193. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  194. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  195. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  196. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  197. data/dependencies/al_soft/AL/alext.h +0 -585
  198. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  199. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  200. data/dependencies/al_soft/AL/efx.h +0 -762
  201. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  202. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  203. data/lib/OpenAL32.dll +0 -0
  204. data/lib64/OpenAL32.dll +0 -0
data/src/Macro.cpp CHANGED
@@ -1,10 +1,10 @@
1
1
  #include "Macro.hpp"
2
- #include "DrawOpQueue.hpp"
3
2
  #include <Gosu/Image.hpp>
3
+ #include <Gosu/Utility.hpp>
4
+ #include "DrawOpQueue.hpp"
4
5
  #include <stdexcept>
5
- using namespace std;
6
6
 
7
- struct Gosu::Macro::Impl
7
+ struct Gosu::Macro::Impl : Gosu::Noncopyable
8
8
  {
9
9
  VertexArrays vertex_arrays;
10
10
  int width, height;
@@ -13,8 +13,8 @@ struct Gosu::Macro::Impl
13
13
  // (a11 a12) (x1) = (b1)
14
14
  // (a21 a22) (x2) = (b2)
15
15
  // x1, x2 are output parameters. Returns false if the matrix is singular.
16
- static bool solve_2x2(double a11, double a12, double a21, double a22, double b1, double b2,
17
- double& x1, double& x2)
16
+ static bool solve_2x2(double a11, double a12, double a21, double a22, //
17
+ double b1, double b2, double& x1, double& x2)
18
18
  {
19
19
  const double det = a11 * a22 - a21 * a12;
20
20
  if (det == 0) return false;
@@ -23,8 +23,8 @@ struct Gosu::Macro::Impl
23
23
  return true;
24
24
  }
25
25
 
26
- Transform find_transform_for_target(double x1, double y1, double x2, double y2,
27
- double x3, double y3, double x4, double y4) const
26
+ Transform find_transform_for_target(double x1, double y1, double x2, double y2, //
27
+ double x3, double y3, double x4, double y4) const
28
28
  {
29
29
  // Transformation logic follows a discussion on the ImageMagick mailing
30
30
  // list (on which ImageMagick's perspective_transform.pl is based).
@@ -100,37 +100,35 @@ struct Gosu::Macro::Impl
100
100
  // 0, 0, 0, 0, 0, 0, 0, 1 | qy
101
101
 
102
102
  double c[8];
103
- c[0] = (x2 - x1) / width + qx * x2;
103
+ c[0] = (x2 - x1) / width + qx * x2;
104
104
  c[1] = (x3 - x1) / height + qy * x3;
105
105
  c[2] = x1;
106
- c[3] = (y2 - y1) / width + qx * y2;
106
+ c[3] = (y2 - y1) / width + qx * y2;
107
107
  c[4] = (y3 - y1) / height + qy * y3;
108
108
  c[5] = y1;
109
109
  c[6] = qx;
110
110
  c[7] = qy;
111
111
 
112
- Transform result = {{
113
- c[0], c[3], 0, c[6],
114
- c[1], c[4], 0, c[7],
115
- 0, 0, 1, 0,
116
- c[2], c[5], 0, 1
117
- }};
112
+ Transform result = {{c[0], c[3], 0, c[6], //
113
+ c[1], c[4], 0, c[7], //
114
+ 0, 0, 1, 0, //
115
+ c[2], c[5], 0, 1}};
118
116
  return result;
119
117
  }
120
118
 
121
- void draw_vertex_arrays(double x1, double y1, double x2, double y2, double x3, double y3,
122
- double x4, double y4) const
119
+ void draw_vertex_arrays(double x1, double y1, double x2, double y2, //
120
+ double x3, double y3, double x4, double y4) const
123
121
  {
124
122
  // TODO: Macros should not be split up just because they have different transforms.
125
123
  // They should be premultiplied and have the same transform by definition. Then the
126
124
  // transformation only has to be performed once.
127
-
128
- #ifndef GOSU_IS_OPENGLES
125
+
126
+ #ifndef GOSU_IS_OPENGLES
129
127
  glEnable(GL_BLEND);
130
128
  glMatrixMode(GL_MODELVIEW);
131
-
129
+
132
130
  Transform transform = find_transform_for_target(x1, y1, x2, y2, x3, y3, x4, y4);
133
-
131
+
134
132
  for (const auto& vertex_array : vertex_arrays) {
135
133
  glPushMatrix();
136
134
  vertex_array.render_state.apply();
@@ -139,7 +137,7 @@ struct Gosu::Macro::Impl
139
137
  glDrawArrays(GL_QUADS, 0, (GLsizei) vertex_array.vertices.size());
140
138
  glPopMatrix();
141
139
  }
142
- #endif
140
+ #endif
143
141
  }
144
142
  };
145
143
 
@@ -161,15 +159,16 @@ int Gosu::Macro::height() const
161
159
  return pimpl->height;
162
160
  }
163
161
 
164
- void Gosu::Macro::draw(double x1, double y1, Color c1, double x2, double y2, Color c2,
165
- double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z, BlendMode mode) const
162
+ void Gosu::Macro::draw(double x1, double y1, Color c1, double x2, double y2, Color c2, //
163
+ double x3, double y3, Color c3, double x4, double y4, Color c4, //
164
+ ZPos z, BlendMode mode) const
166
165
  {
167
166
  if (c1 != Color::WHITE || c2 != Color::WHITE || c3 != Color::WHITE || c4 != Color::WHITE) {
168
- throw invalid_argument("Macros cannot be tinted with colors");
167
+ throw std::invalid_argument{"Macros cannot be tinted with colors"};
169
168
  }
170
-
169
+
171
170
  normalize_coordinates(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
172
-
171
+
173
172
  Gosu::Graphics::gl(z, [=] { pimpl->draw_vertex_arrays(x1, y1, x2, y2, x3, y3, x4, y4); });
174
173
  }
175
174
 
@@ -180,21 +179,20 @@ const Gosu::GLTexInfo* Gosu::Macro::gl_tex_info() const
180
179
 
181
180
  Gosu::Bitmap Gosu::Macro::to_bitmap() const
182
181
  {
183
- return Gosu::Graphics::render(pimpl->width, pimpl->height, [this] {
184
- draw(0, 0, Color::WHITE,
185
- pimpl->width, 0, Color::WHITE,
186
- 0, pimpl->height, Color::WHITE,
187
- pimpl->width, pimpl->height, Color::WHITE,
188
- 0, BM_DEFAULT);
189
- }).data().to_bitmap();
182
+ const auto render_this = [this] {
183
+ draw(0, 0, Color::WHITE, pimpl->width, 0, Color::WHITE, 0, pimpl->height, Color::WHITE,
184
+ pimpl->width, pimpl->height, Color::WHITE, 0, BM_DEFAULT);
185
+ };
186
+
187
+ return Gosu::Graphics::render(pimpl->width, pimpl->height, render_this).data().to_bitmap();
190
188
  }
191
189
 
192
- unique_ptr<Gosu::ImageData> Gosu::Macro::subimage(int x, int y, int width, int height) const
190
+ std::unique_ptr<Gosu::ImageData> Gosu::Macro::subimage(int x, int y, int width, int height) const
193
191
  {
194
- return unique_ptr<ImageData>();
192
+ return std::unique_ptr<ImageData>{};
195
193
  }
196
194
 
197
195
  void Gosu::Macro::insert(const Bitmap& bitmap, int x, int y)
198
196
  {
199
- throw logic_error("Gosu::Macro cannot be updated with a Gosu::Bitmap yet");
197
+ throw std::logic_error{"Gosu::Macro cannot be updated with a Gosu::Bitmap yet"};
200
198
  }
data/src/Macro.hpp CHANGED
@@ -1,30 +1,30 @@
1
1
  #pragma once
2
2
 
3
- #include "GraphicsImpl.hpp"
4
3
  #include <Gosu/Fwd.hpp>
5
4
  #include <Gosu/ImageData.hpp>
5
+ #include "GraphicsImpl.hpp"
6
6
  #include <memory>
7
7
 
8
8
  class Gosu::Macro : public Gosu::ImageData
9
9
  {
10
10
  struct Impl;
11
11
  std::shared_ptr<Impl> pimpl;
12
-
12
+
13
13
  public:
14
14
  Macro(DrawOpQueue& queue, int width, int height);
15
-
15
+
16
16
  int width() const override;
17
17
  int height() const override;
18
-
19
- void draw(double x1, double y1, Color c1, double x2, double y2, Color c2,
20
- double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z,
21
- BlendMode mode) const override;
22
-
18
+
19
+ void draw(double x1, double y1, Color c1, double x2, double y2, Color c2, //
20
+ double x3, double y3, Color c3, double x4, double y4, Color c4, //
21
+ ZPos z, BlendMode mode) const override;
22
+
23
23
  const Gosu::GLTexInfo* gl_tex_info() const override;
24
-
24
+
25
25
  Gosu::Bitmap to_bitmap() const override;
26
-
26
+
27
27
  std::unique_ptr<ImageData> subimage(int x, int y, int width, int height) const override;
28
-
28
+
29
29
  void insert(const Bitmap& bitmap, int x, int y) override;
30
30
  };
data/src/Math.cpp CHANGED
@@ -23,7 +23,14 @@ double Gosu::angle(double from_x, double from_y, double to_x, double to_y, doubl
23
23
  double dist_x = to_x - from_x;
24
24
  double dist_y = to_y - from_y;
25
25
 
26
- if (dist_x == 0 && dist_y == 0) return def;
26
+ if (dist_x == 0) {
27
+ // Special-case these values so that for a result of 0°/360° we never
28
+ // run into subtle precision errors by converting from radian to angles.
29
+ if (dist_y < 0) return 0;
30
+ if (dist_y > 0) return 180;
31
+ // dist_y == 0
32
+ return 0;
33
+ }
27
34
 
28
35
  return normalize_angle(radians_to_gosu(atan2(dist_y, dist_x)));
29
36
  }
data/src/Resolution.cpp CHANGED
@@ -7,8 +7,9 @@
7
7
 
8
8
  static SDL_DisplayMode display_mode(Gosu::Window* window)
9
9
  {
10
- static struct VideoSubsystem {
11
- VideoSubsystem() { SDL_InitSubSystem(SDL_INIT_VIDEO); };
10
+ static struct VideoSubsystem
11
+ {
12
+ VideoSubsystem() { SDL_InitSubSystem(SDL_INIT_VIDEO); };
12
13
  ~VideoSubsystem() { SDL_QuitSubSystem(SDL_INIT_VIDEO); };
13
14
  } subsystem;
14
15
 
@@ -40,7 +41,8 @@ static SDL_Rect max_window_size(Gosu::Window* window)
40
41
  style = NSWindowStyleMaskBorderless;
41
42
  }
42
43
  else {
43
- style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable;
44
+ style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
45
+ NSWindowStyleMaskMiniaturizable;
44
46
  }
45
47
  if (window && window->resizable()) {
46
48
  style |= NSWindowStyleMaskResizable;
@@ -61,10 +63,10 @@ static SDL_Rect max_window_size(Gosu::Window* window)
61
63
 
62
64
  // TODO: Remove this implementation and remove ifdef for GOSU_IS_X once WIN_GetWindowBordersSize is patched
63
65
  #ifdef GOSU_IS_WIN
64
- #include <windows.h>
65
66
  #include <SDL_syswm.h>
66
67
  #include <dwmapi.h>
67
- #pragma comment (lib, "Dwmapi.lib")
68
+ #include <windows.h>
69
+ #pragma comment(lib, "Dwmapi.lib")
68
70
 
69
71
  static SDL_Rect max_window_size(Gosu::Window* window)
70
72
  {
@@ -72,7 +74,8 @@ static SDL_Rect max_window_size(Gosu::Window* window)
72
74
  // until it's patched to ignore the window drop shadow (window border is 1px but with drop shadow it's reported as 8px)
73
75
  // REF: https://github.com/libsdl-org/SDL/issues/3835
74
76
 
75
- static struct VideoSubsystem {
77
+ static struct VideoSubsystem
78
+ {
76
79
  VideoSubsystem() { SDL_InitSubSystem(SDL_INIT_VIDEO); };
77
80
  ~VideoSubsystem() { SDL_QuitSubSystem(SDL_INIT_VIDEO); };
78
81
  } subsystem;
@@ -136,7 +139,8 @@ static SDL_Rect max_window_size(Gosu::Window* window)
136
139
  #ifdef GOSU_IS_X
137
140
  static SDL_Rect max_window_size(Gosu::Window* window)
138
141
  {
139
- static struct VideoSubsystem {
142
+ static struct VideoSubsystem
143
+ {
140
144
  VideoSubsystem() { SDL_InitSubSystem(SDL_INIT_VIDEO); };
141
145
  ~VideoSubsystem() { SDL_QuitSubSystem(SDL_INIT_VIDEO); };
142
146
  } subsystem;
@@ -163,4 +167,5 @@ int Gosu::available_height(Window* window)
163
167
  {
164
168
  return max_window_size(window).h;
165
169
  }
170
+
166
171
  #endif
data/src/RubyGosu.cxx CHANGED
@@ -8217,8 +8217,8 @@ fail:
8217
8217
  SWIGINTERN VALUE
8218
8218
  _wrap_Sample_play(int argc, VALUE *argv, VALUE self) {
8219
8219
  Gosu::Sample *arg1 = (Gosu::Sample *) 0 ;
8220
- double arg2 = (double) 1 ;
8221
- double arg3 = (double) 1 ;
8220
+ double arg2 = (double) 1.0 ;
8221
+ double arg3 = (double) 1.0 ;
8222
8222
  bool arg4 = (bool) false ;
8223
8223
  void *argp1 = 0 ;
8224
8224
  int res1 = 0 ;
@@ -8279,8 +8279,8 @@ SWIGINTERN VALUE
8279
8279
  _wrap_Sample_play_pan(int argc, VALUE *argv, VALUE self) {
8280
8280
  Gosu::Sample *arg1 = (Gosu::Sample *) 0 ;
8281
8281
  double arg2 ;
8282
- double arg3 = (double) 1 ;
8283
- double arg4 = (double) 1 ;
8282
+ double arg3 = (double) 1.0 ;
8283
+ double arg4 = (double) 1.0 ;
8284
8284
  bool arg5 = (bool) false ;
8285
8285
  void *argp1 = 0 ;
8286
8286
  int res1 = 0 ;
@@ -12485,7 +12485,7 @@ SWIGEXPORT void Init_gosu(void) {
12485
12485
  rb_define_const(mGosu, "VERSION", SWIG_From_std_string(static_cast< std::string >(Gosu::VERSION)));
12486
12486
  rb_define_const(mGosu, "LICENSES", SWIG_From_std_string(static_cast< std::string >(Gosu::LICENSES)));
12487
12487
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(1)));
12488
- rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(3)));
12488
+ rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(4)));
12489
12489
  rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(0)));
12490
12490
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
12491
12491
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
data/src/TexChunk.cpp CHANGED
@@ -1,57 +1,66 @@
1
1
  #include "TexChunk.hpp"
2
- #include "DrawOpQueue.hpp"
3
- #include "Texture.hpp"
4
2
  #include <Gosu/Bitmap.hpp>
5
3
  #include <Gosu/Graphics.hpp>
4
+ #include "DrawOpQueue.hpp"
5
+ #include "Texture.hpp"
6
6
  #include <stdexcept>
7
7
 
8
- using namespace std;
9
-
10
8
  void Gosu::TexChunk::set_tex_info()
11
9
  {
12
- double width = texture->width(), height = texture->height();
10
+ double width = m_texture->width(), height = m_texture->height();
13
11
 
14
- info.tex_name = texture->tex_name();
15
- info.left = x / width;
16
- info.top = y / height;
17
- info.right = (x + w) / width;
18
- info.bottom = (y + h) / height;
12
+ m_info.tex_name = m_texture->tex_name();
13
+ m_info.left = m_x / width;
14
+ m_info.top = m_y / height;
15
+ m_info.right = (m_x + m_w) / width;
16
+ m_info.bottom = (m_y + m_h) / height;
19
17
  }
20
18
 
21
- Gosu::TexChunk::TexChunk(shared_ptr<Texture> texture, int x, int y, int w, int h, int padding)
22
- : texture(move(texture)), x(x), y(y), w(w), h(h), padding(padding)
19
+ Gosu::TexChunk::TexChunk(std::shared_ptr<Texture> texture, int x, int y, int w, int h, int padding)
20
+ : m_texture{move(texture)},
21
+ m_x{x},
22
+ m_y{y},
23
+ m_w{w},
24
+ m_h{h},
25
+ m_padding{padding}
23
26
  {
24
27
  set_tex_info();
25
28
  }
26
29
 
27
30
  Gosu::TexChunk::TexChunk(const TexChunk& parent, int x, int y, int w, int h)
28
- : texture(parent.texture), x(parent.x + x), y(parent.y + y), w(w), h(h), padding(0)
31
+ : m_texture{parent.m_texture},
32
+ m_x{parent.m_x + x},
33
+ m_y{parent.m_y + y},
34
+ m_w{w},
35
+ m_h{h},
36
+ m_padding{0}
29
37
  {
30
- if (x < 0 || y < 0 || x + w > parent.w || y + h > parent.h) {
31
- throw invalid_argument("subimage bounds exceed those of its parent");
38
+ if (x < 0 || y < 0 || x + w > parent.m_w || y + h > parent.m_h) {
39
+ throw std::invalid_argument{"subimage bounds exceed those of its parent"};
32
40
  }
33
41
  if (w <= 0 || h <= 0) {
34
- throw invalid_argument("cannot create empty image");
42
+ throw std::invalid_argument{"cannot create empty image"};
35
43
  }
36
-
44
+
37
45
  set_tex_info();
38
- texture->block(this->x, this->y, this->w, this->h);
46
+ m_texture->block(m_x, m_y, m_w, m_h);
39
47
  }
40
48
 
41
49
  Gosu::TexChunk::~TexChunk()
42
50
  {
43
- texture->free(x - padding, y - padding, w + 2 * padding, h + 2 * padding);
51
+ m_texture->free(m_x - m_padding, m_y - m_padding, m_w + 2 * m_padding, m_h + 2 * m_padding);
44
52
  }
45
53
 
46
- void Gosu::TexChunk::draw(double x1, double y1, Color c1, double x2, double y2, Color c2,
47
- double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z, BlendMode mode) const
54
+ void Gosu::TexChunk::draw(double x1, double y1, Color c1, double x2, double y2, Color c2, //
55
+ double x3, double y3, Color c3, double x4, double y4, Color c4, //
56
+ ZPos z, BlendMode mode) const
48
57
  {
49
58
  DrawOp op;
50
- op.render_state.texture = texture;
59
+ op.render_state.texture = m_texture;
51
60
  op.render_state.mode = mode;
52
-
61
+
53
62
  normalize_coordinates(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
54
-
63
+
55
64
  op.vertices_or_block_index = 4;
56
65
  op.vertices[0] = DrawOp::Vertex(x1, y1, c1);
57
66
  op.vertices[1] = DrawOp::Vertex(x2, y2, c2);
@@ -63,34 +72,34 @@ void Gosu::TexChunk::draw(double x1, double y1, Color c1, double x2, double y2,
63
72
  op.vertices[3] = DrawOp::Vertex(x3, y3, c3);
64
73
  op.vertices[2] = DrawOp::Vertex(x4, y4, c4);
65
74
  #endif
66
- op.left = info.left;
67
- op.top = info.top;
68
- op.right = info.right;
69
- op.bottom = info.bottom;
70
-
75
+ op.left = m_info.left;
76
+ op.top = m_info.top;
77
+ op.right = m_info.right;
78
+ op.bottom = m_info.bottom;
79
+
71
80
  op.z = z;
72
81
  Graphics::schedule_draw_op(op);
73
82
  }
74
83
 
75
- unique_ptr<Gosu::ImageData> Gosu::TexChunk::subimage(int x, int y, int width, int height) const
84
+ std::unique_ptr<Gosu::ImageData> Gosu::TexChunk::subimage(int x, int y, int width, int height) const
76
85
  {
77
- return unique_ptr<Gosu::ImageData>(new TexChunk(*this, x, y, width, height));
86
+ return std::unique_ptr<Gosu::ImageData>(new TexChunk(*this, x, y, width, height));
78
87
  }
79
88
 
80
89
  Gosu::Bitmap Gosu::TexChunk::to_bitmap() const
81
90
  {
82
- return texture->to_bitmap(x, y, w, h);
91
+ return m_texture->to_bitmap(m_x, m_y, m_w, m_h);
83
92
  }
84
93
 
85
94
  void Gosu::TexChunk::insert(const Bitmap& original_bitmap, int x, int y)
86
95
  {
87
96
  Bitmap clipped_bitmap;
88
97
  const Bitmap* bitmap = &original_bitmap;
89
-
98
+
90
99
  // If inserting the bitmap at the given position exceeds the boundaries of the space allocated
91
100
  // for this image on the texture, we need to clip the bitmap and insert the clipped version
92
101
  // instead.
93
- if (x < 0 || y < 0 || x + original_bitmap.width() > w || y + original_bitmap.height() > h) {
102
+ if (x < 0 || y < 0 || x + original_bitmap.width() > m_w || y + original_bitmap.height() > m_h) {
94
103
  // How many pixels to remove at the top and left sides.
95
104
  int clip_left = 0, clip_top = 0;
96
105
  // How large the clipped version needs to be.
@@ -109,22 +118,22 @@ void Gosu::TexChunk::insert(const Bitmap& original_bitmap, int x, int y)
109
118
  y = 0;
110
119
  }
111
120
  // Clip away pixels on the right side, if necessary.
112
- if (x + clipped_width > w) {
113
- clipped_width = (w - x);
121
+ if (x + clipped_width > m_w) {
122
+ clipped_width = (m_w - x);
114
123
  }
115
124
  // Clip away pixels on the bottom, if necessary.
116
- if (y + clipped_height > h) {
117
- clipped_height = (h - y);
125
+ if (y + clipped_height > m_h) {
126
+ clipped_height = (m_h - y);
118
127
  }
119
128
 
120
129
  if (clipped_width <= 0 || clipped_height <= 0) return;
121
-
130
+
122
131
  clipped_bitmap.resize(clipped_width, clipped_height);
123
132
  clipped_bitmap.insert(-clip_left, -clip_top, original_bitmap);
124
133
  bitmap = &clipped_bitmap;
125
134
  }
126
-
135
+
127
136
  glBindTexture(GL_TEXTURE_2D, tex_name());
128
- glTexSubImage2D(GL_TEXTURE_2D, 0, this->x + x, this->y + y, bitmap->width(), bitmap->height(),
137
+ glTexSubImage2D(GL_TEXTURE_2D, 0, m_x + x, m_y + y, bitmap->width(), bitmap->height(),
129
138
  Color::GL_FORMAT, GL_UNSIGNED_BYTE, bitmap->data());
130
139
  }
data/src/TexChunk.hpp CHANGED
@@ -1,41 +1,41 @@
1
1
  #pragma once
2
2
 
3
- #include "GraphicsImpl.hpp"
4
3
  #include <Gosu/Fwd.hpp>
5
4
  #include <Gosu/ImageData.hpp>
5
+ #include "GraphicsImpl.hpp"
6
6
  #include <memory>
7
7
  #include <stdexcept>
8
8
 
9
9
  class Gosu::TexChunk : public Gosu::ImageData
10
10
  {
11
- std::shared_ptr<Texture> texture;
12
- int x, y, w, h, padding;
13
-
14
- GLTexInfo info;
15
-
11
+ std::shared_ptr<Texture> m_texture;
12
+ int m_x, m_y, m_w, m_h, m_padding;
13
+
14
+ GLTexInfo m_info;
15
+
16
16
  void set_tex_info();
17
-
17
+
18
18
  public:
19
19
  TexChunk(std::shared_ptr<Texture> texture, int x, int y, int w, int h, int padding);
20
20
  TexChunk(const TexChunk& parent, int x, int y, int w, int h);
21
21
  ~TexChunk() override;
22
22
 
23
- int width() const override { return w; }
24
- int height() const override { return h; }
25
-
26
- GLuint tex_name() const { return info.tex_name; }
27
-
28
- void draw(double x1, double y1, Color c1,
29
- double x2, double y2, Color c2,
30
- double x3, double y3, Color c3,
31
- double x4, double y4, Color c4,
32
- ZPos z, BlendMode mode) const override;
33
-
34
- const GLTexInfo* gl_tex_info() const override { return &info; }
35
-
23
+ int width() const override { return m_w; }
24
+ int height() const override { return m_h; }
25
+
26
+ GLuint tex_name() const { return m_info.tex_name; }
27
+
28
+ void draw(double x1, double y1, Color c1, //
29
+ double x2, double y2, Color c2, //
30
+ double x3, double y3, Color c3, //
31
+ double x4, double y4, Color c4, //
32
+ ZPos z, BlendMode mode) const override;
33
+
34
+ const GLTexInfo* gl_tex_info() const override { return &m_info; }
35
+
36
36
  std::unique_ptr<ImageData> subimage(int x, int y, int width, int height) const override;
37
-
37
+
38
38
  Gosu::Bitmap to_bitmap() const override;
39
-
39
+
40
40
  void insert(const Bitmap& bitmap, int x, int y) override;
41
41
  };