gosu 1.1.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +1 -1
  3. data/dependencies/SDL/include/SDL.h +108 -14
  4. data/dependencies/SDL/include/SDL_assert.h +81 -50
  5. data/dependencies/SDL/include/SDL_atomic.h +135 -35
  6. data/dependencies/SDL/include/SDL_audio.h +960 -355
  7. data/dependencies/SDL/include/SDL_bits.h +11 -6
  8. data/dependencies/SDL/include/SDL_blendmode.h +91 -14
  9. data/dependencies/SDL/include/SDL_clipboard.h +30 -7
  10. data/dependencies/SDL/include/SDL_config.h +277 -27
  11. data/dependencies/SDL/include/SDL_config_android.h +13 -38
  12. data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
  13. data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
  14. data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
  15. data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
  16. data/dependencies/SDL/include/SDL_config_psp.h +16 -37
  17. data/dependencies/SDL/include/SDL_config_windows.h +28 -91
  18. data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
  19. data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
  20. data/dependencies/SDL/include/SDL_copying.h +1 -1
  21. data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
  22. data/dependencies/SDL/include/SDL_egl.h +906 -280
  23. data/dependencies/SDL/include/SDL_endian.h +101 -47
  24. data/dependencies/SDL/include/SDL_error.h +70 -19
  25. data/dependencies/SDL/include/SDL_events.h +387 -79
  26. data/dependencies/SDL/include/SDL_filesystem.h +73 -64
  27. data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
  28. data/dependencies/SDL/include/SDL_gesture.h +36 -6
  29. data/dependencies/SDL/include/SDL_haptic.h +304 -210
  30. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  31. data/dependencies/SDL/include/SDL_hints.h +1286 -897
  32. data/dependencies/SDL/include/SDL_joystick.h +577 -130
  33. data/dependencies/SDL/include/SDL_keyboard.h +162 -63
  34. data/dependencies/SDL/include/SDL_keycode.h +7 -5
  35. data/dependencies/SDL/include/SDL_loadso.h +42 -8
  36. data/dependencies/SDL/include/SDL_locale.h +34 -32
  37. data/dependencies/SDL/include/SDL_log.h +212 -19
  38. data/dependencies/SDL/include/SDL_main.h +72 -17
  39. data/dependencies/SDL/include/SDL_messagebox.h +70 -23
  40. data/dependencies/SDL/include/SDL_metal.h +27 -32
  41. data/dependencies/SDL/include/SDL_misc.h +19 -15
  42. data/dependencies/SDL/include/SDL_mouse.h +262 -110
  43. data/dependencies/SDL/include/SDL_mutex.h +286 -66
  44. data/dependencies/SDL/include/SDL_name.h +1 -1
  45. data/dependencies/SDL/include/SDL_opengl.h +1 -1
  46. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  47. data/dependencies/SDL/include/SDL_opengles2.h +2 -2
  48. data/dependencies/SDL/include/SDL_pixels.h +199 -34
  49. data/dependencies/SDL/include/SDL_platform.h +39 -2
  50. data/dependencies/SDL/include/SDL_power.h +23 -10
  51. data/dependencies/SDL/include/SDL_quit.h +1 -1
  52. data/dependencies/SDL/include/SDL_rect.h +78 -28
  53. data/dependencies/SDL/include/SDL_render.h +1204 -472
  54. data/dependencies/SDL/include/SDL_revision.h +2 -2
  55. data/dependencies/SDL/include/SDL_rwops.h +605 -33
  56. data/dependencies/SDL/include/SDL_scancode.h +1 -1
  57. data/dependencies/SDL/include/SDL_sensor.h +76 -42
  58. data/dependencies/SDL/include/SDL_shape.h +38 -27
  59. data/dependencies/SDL/include/SDL_stdinc.h +96 -24
  60. data/dependencies/SDL/include/SDL_surface.h +571 -139
  61. data/dependencies/SDL/include/SDL_system.h +339 -101
  62. data/dependencies/SDL/include/SDL_syswm.h +50 -20
  63. data/dependencies/SDL/include/SDL_test.h +1 -1
  64. data/dependencies/SDL/include/SDL_test_assert.h +2 -2
  65. data/dependencies/SDL/include/SDL_test_common.h +23 -6
  66. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  68. data/dependencies/SDL/include/SDL_test_font.h +3 -3
  69. data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
  70. data/dependencies/SDL/include/SDL_test_harness.h +6 -6
  71. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  72. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  73. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  74. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  75. data/dependencies/SDL/include/SDL_test_random.h +2 -2
  76. data/dependencies/SDL/include/SDL_thread.h +226 -128
  77. data/dependencies/SDL/include/SDL_timer.h +129 -22
  78. data/dependencies/SDL/include/SDL_touch.h +48 -8
  79. data/dependencies/SDL/include/SDL_types.h +1 -1
  80. data/dependencies/SDL/include/SDL_version.h +72 -46
  81. data/dependencies/SDL/include/SDL_video.h +1266 -460
  82. data/dependencies/SDL/include/SDL_vulkan.h +100 -161
  83. data/dependencies/SDL/include/begin_code.h +22 -1
  84. data/dependencies/SDL/include/close_code.h +1 -1
  85. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  86. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  87. data/dependencies/SDL_sound/SDL_sound.c +83 -7
  88. data/dependencies/SDL_sound/SDL_sound.h +4 -4
  89. data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
  90. data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
  91. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
  92. data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
  93. data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
  94. data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
  95. data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
  96. data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
  97. data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
  98. data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
  99. data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
  100. data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
  101. data/dependencies/SDL_sound/dr_flac.h +618 -220
  102. data/dependencies/SDL_sound/dr_mp3.h +263 -94
  103. data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
  104. data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
  105. data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
  106. data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
  107. data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
  108. data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
  109. data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
  110. data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
  111. data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
  112. data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
  113. data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
  114. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
  115. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  116. data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
  117. data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
  118. data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
  119. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
  120. data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
  121. data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
  122. data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
  123. data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
  124. data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
  125. data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
  126. data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
  127. data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
  128. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
  129. data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
  130. data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
  131. data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
  132. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
  133. data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
  134. data/dependencies/SDL_sound/stb_vorbis.h +508 -325
  135. data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
  136. data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
  137. data/dependencies/mojoAL/mojoal.c +4594 -0
  138. data/ext/gosu/extconf.rb +33 -30
  139. data/include/Gosu/Audio.hpp +70 -85
  140. data/include/Gosu/Color.hpp +63 -107
  141. data/include/Gosu/Font.hpp +44 -50
  142. data/include/Gosu/Fwd.hpp +1 -1
  143. data/include/Gosu/Graphics.hpp +64 -75
  144. data/include/Gosu/GraphicsBase.hpp +32 -39
  145. data/include/Gosu/Image.hpp +56 -62
  146. data/include/Gosu/ImageData.hpp +23 -27
  147. data/include/Gosu/Inspection.hpp +1 -4
  148. data/include/Gosu/Math.hpp +4 -16
  149. data/include/Gosu/Platform.hpp +1 -51
  150. data/include/Gosu/Text.hpp +37 -40
  151. data/include/Gosu/TextInput.hpp +34 -40
  152. data/include/Gosu/Utility.hpp +10 -8
  153. data/include/Gosu/Version.hpp +1 -1
  154. data/include/Gosu/Window.hpp +73 -70
  155. data/lib/SDL2.dll +0 -0
  156. data/lib/gosu/compat.rb +28 -37
  157. data/lib/gosu/swig_patches.rb +31 -3
  158. data/lib/gosu.rb +2 -2
  159. data/lib64/SDL2.dll +0 -0
  160. data/rdoc/gosu.rb +9 -1
  161. data/src/Audio.cpp +86 -86
  162. data/src/AudioFile.hpp +6 -6
  163. data/src/AudioFileAudioToolbox.cpp +1 -1
  164. data/src/AudioFileSDLSound.cpp +1 -1
  165. data/src/AudioImpl.hpp +5 -5
  166. data/src/Bitmap.cpp +13 -13
  167. data/src/BitmapIO.cpp +0 -20
  168. data/src/BlockAllocator.cpp +2 -1
  169. data/src/Channel.cpp +22 -20
  170. data/src/Color.cpp +62 -55
  171. data/src/EmptyImageData.hpp +16 -18
  172. data/src/FileUnix.cpp +1 -1
  173. data/src/FileWin.cpp +1 -1
  174. data/src/Font.cpp +52 -57
  175. data/src/GosuViewController.cpp +2 -0
  176. data/src/Graphics.cpp +135 -143
  177. data/src/Image.cpp +42 -42
  178. data/src/Input.cpp +1 -1
  179. data/src/InputUIKit.cpp +1 -1
  180. data/src/LargeImageData.cpp +120 -113
  181. data/src/LargeImageData.hpp +18 -16
  182. data/src/Log.hpp +6 -6
  183. data/src/Macro.cpp +124 -169
  184. data/src/Macro.hpp +11 -11
  185. data/src/Math.cpp +8 -1
  186. data/src/RenderState.hpp +5 -5
  187. data/src/Resolution.cpp +114 -61
  188. data/src/RubyGosu.cxx +470 -501
  189. data/src/RubyGosu.h +3 -2
  190. data/src/TexChunk.cpp +50 -41
  191. data/src/TexChunk.hpp +22 -22
  192. data/src/Text.cpp +58 -59
  193. data/src/TextBuilder.cpp +60 -57
  194. data/src/TextBuilder.hpp +20 -20
  195. data/src/TextInput.cpp +127 -135
  196. data/src/TrueTypeFont.cpp +108 -108
  197. data/src/TrueTypeFont.hpp +39 -38
  198. data/src/TrueTypeFontApple.cpp +27 -23
  199. data/src/TrueTypeFontUnix.cpp +21 -26
  200. data/src/TrueTypeFontWin.cpp +30 -30
  201. data/src/Utility.cpp +82 -23
  202. data/src/WinUtility.hpp +2 -1
  203. data/src/Window.cpp +103 -86
  204. data/src/WindowUIKit.cpp +48 -51
  205. metadata +8 -20
  206. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  207. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  208. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  209. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  210. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  211. data/dependencies/al_soft/AL/alext.h +0 -585
  212. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  213. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  214. data/dependencies/al_soft/AL/efx.h +0 -762
  215. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  216. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  217. data/lib/OpenAL32.dll +0 -0
  218. data/lib64/OpenAL32.dll +0 -0
  219. data/src/UtilityApple.cpp +0 -16
  220. data/src/UtilityWin.cpp +0 -17
data/src/Graphics.cpp CHANGED
@@ -1,4 +1,7 @@
1
+ #include <Gosu/Bitmap.hpp>
1
2
  #include <Gosu/Graphics.hpp>
3
+ #include <Gosu/Image.hpp>
4
+ #include <Gosu/Utility.hpp>
2
5
  #include "DrawOp.hpp"
3
6
  #include "DrawOpQueue.hpp"
4
7
  #include "GraphicsImpl.hpp"
@@ -6,86 +9,83 @@
6
9
  #include "Macro.hpp"
7
10
  #include "OffScreenTarget.hpp"
8
11
  #include "Texture.hpp"
9
- #include <Gosu/Bitmap.hpp>
10
- #include <Gosu/Image.hpp>
11
- #include <Gosu/Platform.hpp>
12
- #include <cmath>
13
12
  #include <algorithm>
13
+ #include <cmath>
14
14
  #include <functional>
15
15
  #include <memory>
16
- using namespace std;
17
16
 
18
17
  namespace Gosu
19
18
  {
20
19
  namespace
21
20
  {
22
21
  Graphics* current_graphics_pointer = nullptr;
23
-
22
+
24
23
  Graphics& current_graphics()
25
24
  {
26
25
  if (current_graphics_pointer == nullptr) {
27
- throw logic_error("Gosu::Graphics can only be drawn to while rendering");
26
+ throw std::logic_error{"Gosu::Graphics can only be drawn to while rendering"};
28
27
  }
29
28
  return *current_graphics_pointer;
30
29
  }
31
-
32
- vector<shared_ptr<Texture>> textures;
33
-
30
+
31
+ std::vector<std::shared_ptr<Texture>> textures;
32
+
34
33
  DrawOpQueueStack queues;
35
-
34
+
36
35
  DrawOpQueue& current_queue()
37
36
  {
38
37
  if (queues.empty()) {
39
- throw logic_error("There is no rendering queue for this operation");
38
+ throw std::logic_error{"There is no rendering queue for this operation"};
40
39
  }
41
40
  return queues.back();
42
41
  }
43
42
  }
44
43
  }
45
44
 
46
- struct Gosu::Graphics::Impl
45
+ struct Gosu::Graphics::Impl : Gosu::Noncopyable
47
46
  {
48
- unsigned virt_width, virt_height;
49
- unsigned phys_width, phys_height;
50
- double black_width, black_height;
47
+ unsigned virt_width = 0, virt_height = 0;
48
+ unsigned phys_width = 0, phys_height = 0;
49
+ double black_width = 0.0, black_height = 0.0;
51
50
  Transform base_transform;
52
-
51
+
53
52
  DrawOpQueueStack warmed_up_queues;
54
53
 
55
54
  void update_base_transform()
56
55
  {
57
56
  double scale_x = 1.0 * phys_width / virt_width;
58
57
  double scale_y = 1.0 * phys_height / virt_height;
59
- double scale_factor = min(scale_x, scale_y);
58
+ double scale_factor = std::min(scale_x, scale_y);
60
59
 
61
60
  Transform scale_transform = scale(scale_factor);
62
61
  Transform translate_transform = translate(black_width, black_height);
63
62
  base_transform = concat(translate_transform, scale_transform);
64
63
  }
65
-
64
+
66
65
  #ifndef GOSU_IS_OPENGLES
67
- void begin_gl()
66
+ void begin_gl() // NOLINT(readability-convert-member-functions-to-static)
68
67
  {
69
68
  glPushAttrib(GL_ALL_ATTRIB_BITS);
70
69
  glDisable(GL_BLEND);
71
70
  // Reset the color to white to avoid surprises.
72
71
  // https://www.libgosu.org/cgi-bin/mwf/topic_show.pl?pid=9115#pid9115
73
72
  glColor4ubv(reinterpret_cast<const GLubyte*>(&Color::WHITE));
74
- while (glGetError() != GL_NO_ERROR);
73
+ while (glGetError() != GL_NO_ERROR)
74
+ ;
75
75
  }
76
-
76
+
77
77
  void end_gl()
78
78
  {
79
79
  glPopAttrib();
80
-
80
+
81
81
  // Restore matrices.
82
82
  // TODO: Should be merged into RenderState and removed from Graphics.
83
-
83
+
84
84
  glMatrixMode(GL_PROJECTION);
85
85
  glLoadIdentity();
86
- glViewport(0, 0, phys_width, phys_height);
86
+ glViewport(0, 0, static_cast<GLsizei>(phys_width), static_cast<GLsizei>(phys_height));
87
87
  glOrtho(0, phys_width, phys_height, 0, -1, 1);
88
-
88
+
89
89
  glMatrixMode(GL_MODELVIEW);
90
90
  glLoadIdentity();
91
91
  glEnable(GL_BLEND);
@@ -94,12 +94,12 @@ struct Gosu::Graphics::Impl
94
94
  };
95
95
 
96
96
  Gosu::Graphics::Graphics(unsigned phys_width, unsigned phys_height)
97
- : pimpl(new Impl)
97
+ : m_impl(new Impl)
98
98
  {
99
- pimpl->virt_width = phys_width;
100
- pimpl->virt_height = phys_height;
101
- pimpl->black_width = 0;
102
- pimpl->black_height = 0;
99
+ m_impl->virt_width = phys_width;
100
+ m_impl->virt_height = phys_height;
101
+ m_impl->black_width = 0;
102
+ m_impl->black_height = 0;
103
103
 
104
104
  // TODO: Should be merged into RenderState and removed from Graphics.
105
105
  glMatrixMode(GL_MODELVIEW);
@@ -118,97 +118,90 @@ Gosu::Graphics::~Graphics()
118
118
 
119
119
  unsigned Gosu::Graphics::width() const
120
120
  {
121
- return pimpl->virt_width;
121
+ return m_impl->virt_width;
122
122
  }
123
123
 
124
124
  unsigned Gosu::Graphics::height() const
125
125
  {
126
- return pimpl->virt_height;
126
+ return m_impl->virt_height;
127
127
  }
128
128
 
129
129
  void Gosu::Graphics::set_resolution(unsigned virtual_width, unsigned virtual_height,
130
- double horizontal_black_bar_width, double vertical_black_bar_height)
130
+ double horizontal_black_bar_width,
131
+ double vertical_black_bar_height)
131
132
  {
132
133
  if (virtual_width == 0 || virtual_height == 0) {
133
- throw invalid_argument("Invalid virtual resolution.");
134
+ throw std::invalid_argument{"Invalid virtual resolution."};
134
135
  }
135
-
136
- pimpl->virt_width = virtual_width;
137
- pimpl->virt_height = virtual_height;
138
- pimpl->black_width = horizontal_black_bar_width;
139
- pimpl->black_height = vertical_black_bar_height;
140
136
 
141
- pimpl->update_base_transform();
137
+ m_impl->virt_width = virtual_width;
138
+ m_impl->virt_height = virtual_height;
139
+ m_impl->black_width = horizontal_black_bar_width;
140
+ m_impl->black_height = vertical_black_bar_height;
141
+
142
+ m_impl->update_base_transform();
142
143
  }
143
144
 
144
- void Gosu::Graphics::frame(const function<void ()>& f)
145
+ void Gosu::Graphics::frame(const std::function<void()>& f)
145
146
  {
146
147
  if (current_graphics_pointer != nullptr) {
147
- throw logic_error("Cannot nest calls to Gosu::Graphics::begin()");
148
+ throw std::logic_error{"Cannot nest calls to Gosu::Graphics::begin()"};
148
149
  }
149
-
150
+
150
151
  // Cancel all recording or whatever that might still be in progress...
151
152
  queues.clear();
152
-
153
- if (pimpl->warmed_up_queues.size() == 1) {
153
+
154
+ if (m_impl->warmed_up_queues.size() == 1) {
154
155
  // If we already have a "warmed up" queue, use that instead.
155
156
  // -> All internal std::vectors will already have a lot of capacity.
156
157
  // This helps reduce allocations during normal operation.
157
158
  queues.clear();
158
- queues.swap(pimpl->warmed_up_queues);
159
+ queues.swap(m_impl->warmed_up_queues);
159
160
  }
160
161
  else {
161
162
  // Create default draw-op queue.
162
163
  queues.emplace_back(QM_RENDER_TO_SCREEN);
163
164
  }
164
-
165
- queues.back().set_base_transform(pimpl->base_transform);
166
-
165
+
166
+ queues.back().set_base_transform(m_impl->base_transform);
167
+
167
168
  ensure_current_context();
168
169
  glClearColor(0, 0, 0, 1);
169
170
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
170
171
 
171
172
  current_graphics_pointer = this;
172
-
173
+
173
174
  f();
174
-
175
+
175
176
  // Cancel all intermediate queues that have not been cleaned up.
176
177
  while (queues.size() > 1) queues.pop_back();
177
-
178
+
178
179
  flush();
179
-
180
- if (pimpl->black_height || pimpl->black_width) {
181
- if (pimpl->black_height) {
182
- draw_quad(0, -pimpl->black_height, Color::BLACK,
183
- width(), -pimpl->black_height, Color::BLACK,
184
- 0, 0, Color::BLACK,
185
- width(), 0, Color::BLACK, 0);
186
- draw_quad(0, height(), Color::BLACK,
187
- width(), height(), Color::BLACK,
188
- 0, height() + pimpl->black_height, Color::BLACK,
189
- width(), height() + pimpl->black_height, Color::BLACK, 0);
180
+
181
+ if (m_impl->black_height != 0 || m_impl->black_width != 0) {
182
+ if (m_impl->black_height != 0) {
183
+ // Top black bar.
184
+ draw_rect(0, 0, width(), -m_impl->black_height, Color::BLACK, 0);
185
+ // Bottom black bar.
186
+ draw_rect(0, height(), width(), +m_impl->black_height, Color::BLACK, 0);
190
187
  }
191
- if (pimpl->black_width) {
192
- draw_quad(-pimpl->black_width, 0, Color::BLACK,
193
- 0, 0, Color::BLACK,
194
- -pimpl->black_width, height(), Color::BLACK,
195
- 0, height(), Color::BLACK, 0);
196
- draw_quad(width(), 0, Color::BLACK,
197
- width() + pimpl->black_width, 0, Color::BLACK,
198
- width(), height(), Color::BLACK,
199
- width() + pimpl->black_width, height(), Color::BLACK, 0);
188
+ if (m_impl->black_width != 0) {
189
+ // Left black bar.
190
+ draw_rect(0, 0, -m_impl->black_width, height(), Color::BLACK, 0);
191
+ // Right black bar.
192
+ draw_rect(width(), 0, +m_impl->black_width, height(), Color::BLACK, 0);
200
193
  }
201
194
  flush();
202
195
  }
203
-
196
+
204
197
  glFlush();
205
-
198
+
206
199
  current_graphics_pointer = nullptr;
207
-
200
+
208
201
  // Clear leftover transforms, clip rects etc.
209
202
  if (queues.size() == 1) {
210
- queues.swap(pimpl->warmed_up_queues);
211
- pimpl->warmed_up_queues.back().reset();
203
+ queues.swap(m_impl->warmed_up_queues);
204
+ m_impl->warmed_up_queues.back().reset();
212
205
  }
213
206
  else {
214
207
  queues.clear();
@@ -221,55 +214,56 @@ void Gosu::Graphics::flush()
221
214
  current_queue().clear_queue();
222
215
  }
223
216
 
224
- void Gosu::Graphics::gl(const function<void ()>& f)
217
+ void Gosu::Graphics::gl(const std::function<void()>& f)
225
218
  {
226
219
  if (current_queue().mode() == QM_RECORD_MACRO) {
227
- throw logic_error("Custom OpenGL is not allowed while creating a macro");
220
+ throw std::logic_error{"Custom OpenGL is not allowed while creating a macro"};
228
221
  }
229
-
222
+
230
223
  #ifdef GOSU_IS_OPENGLES
231
- throw logic_error("Custom OpenGL ES is not supported yet");
224
+ throw std::logic_error{"Custom OpenGL ES is not supported yet"};
232
225
  #else
233
226
  Graphics& cg = current_graphics();
234
227
 
235
228
  flush();
236
-
237
- cg.pimpl->begin_gl();
229
+
230
+ cg.m_impl->begin_gl();
238
231
 
239
232
  f();
240
233
 
241
- cg.pimpl->end_gl();
234
+ cg.m_impl->end_gl();
242
235
  #endif
243
236
  }
244
237
 
245
- void Gosu::Graphics::gl(Gosu::ZPos z, const function<void ()>& f)
238
+ void Gosu::Graphics::gl(Gosu::ZPos z, const std::function<void()>& f)
246
239
  {
247
240
  #ifdef GOSU_IS_OPENGLES
248
- throw logic_error("Custom OpenGL ES is not supported yet");
241
+ throw std::logic_error{"Custom OpenGL ES is not supported yet"};
249
242
  #else
250
- current_queue().gl([f] {
243
+ const auto wrapped_f = [f] {
251
244
  Graphics& cg = current_graphics();
252
- cg.pimpl->begin_gl();
245
+ cg.m_impl->begin_gl();
253
246
  f();
254
- cg.pimpl->end_gl();
255
- }, z);
247
+ cg.m_impl->end_gl();
248
+ };
249
+ current_queue().gl(wrapped_f, z);
256
250
  #endif
257
251
  }
258
252
 
259
253
  void Gosu::Graphics::clip_to(double x, double y, double width, double height,
260
- const function<void ()>& f)
254
+ const std::function<void()>& f)
261
255
  {
262
- double screen_height = current_graphics().pimpl->phys_height;
256
+ double screen_height = current_graphics().m_impl->phys_height;
263
257
  current_queue().begin_clipping(x, y, width, height, screen_height);
264
258
  f();
265
259
  current_queue().end_clipping();
266
260
  }
267
261
 
268
- Gosu::Image Gosu::Graphics::render(int width, int height, const function<void ()>& f,
262
+ Gosu::Image Gosu::Graphics::render(int width, int height, const std::function<void()>& f,
269
263
  unsigned image_flags)
270
264
  {
271
265
  ensure_current_context();
272
-
266
+
273
267
  // Prepare for rendering at the requested size, but save the previous matrix and viewport.
274
268
  glMatrixMode(GL_PROJECTION);
275
269
  glPushMatrix();
@@ -280,9 +274,9 @@ Gosu::Image Gosu::Graphics::render(int width, int height, const function<void ()
280
274
  // Note the flipped vertical axis in the glOrtho call - this is so we don't have to vertically
281
275
  // flip the texture afterwards.
282
276
  #ifdef GOSU_IS_OPENGLES
283
- glOrthof(0, width, 0, height, -1, 1);
277
+ glOrthof(0, width, 0, height, -1, 1); // NOLINT(readability-suspicious-call-argument)
284
278
  #else
285
- glOrtho(0, width, 0, height, -1, 1);
279
+ glOrtho(0, width, 0, height, -1, 1); // NOLINT(readability-suspicious-call-argument)
286
280
  #endif
287
281
 
288
282
  // This is the actual render-to-texture step.
@@ -302,35 +296,35 @@ Gosu::Image Gosu::Graphics::render(int width, int height, const function<void ()
302
296
  glPopAttrib();
303
297
  #endif
304
298
  });
305
-
299
+
306
300
  // Restore previous matrix and glViewport.
307
301
  glMatrixMode(GL_PROJECTION);
308
302
  glPopMatrix();
309
303
  glViewport(prev_viewport[0], prev_viewport[1], prev_viewport[2], prev_viewport[3]);
310
-
304
+
311
305
  return result;
312
306
  }
313
307
 
314
- Gosu::Image Gosu::Graphics::record(int width, int height, const function<void ()>& f)
308
+ Gosu::Image Gosu::Graphics::record(int width, int height, const std::function<void()>& f)
315
309
  {
316
310
  queues.emplace_back(QM_RECORD_MACRO);
317
311
 
318
312
  f();
319
-
320
- unique_ptr<ImageData> result(new Macro(current_queue(), width, height));
313
+
314
+ std::unique_ptr<ImageData> result(new Macro(current_queue(), width, height));
321
315
  queues.pop_back();
322
316
  return Image(move(result));
323
317
  }
324
318
 
325
- void Gosu::Graphics::transform(const Gosu::Transform& transform, const function<void ()>& f)
319
+ void Gosu::Graphics::transform(const Gosu::Transform& transform, const std::function<void()>& f)
326
320
  {
327
321
  current_queue().push_transform(transform);
328
322
  f();
329
323
  current_queue().pop_transform();
330
324
  }
331
325
 
332
- void Gosu::Graphics::draw_line(double x1, double y1, Color c1,
333
- double x2, double y2, Color c2, ZPos z, AlphaMode mode)
326
+ void Gosu::Graphics::draw_line(double x1, double y1, Color c1, double x2, double y2, Color c2,
327
+ ZPos z, BlendMode mode)
334
328
  {
335
329
  DrawOp op;
336
330
  op.render_state.mode = mode;
@@ -338,12 +332,12 @@ void Gosu::Graphics::draw_line(double x1, double y1, Color c1,
338
332
  op.vertices[0] = DrawOp::Vertex(x1, y1, c1);
339
333
  op.vertices[1] = DrawOp::Vertex(x2, y2, c2);
340
334
  op.z = z;
341
-
335
+
342
336
  current_queue().schedule_draw_op(op);
343
337
  }
344
338
 
345
339
  void Gosu::Graphics::draw_triangle(double x1, double y1, Color c1, double x2, double y2, Color c2,
346
- double x3, double y3, Color c3, ZPos z, AlphaMode mode)
340
+ double x3, double y3, Color c3, ZPos z, BlendMode mode)
347
341
  {
348
342
  DrawOp op;
349
343
  op.render_state.mode = mode;
@@ -356,12 +350,13 @@ void Gosu::Graphics::draw_triangle(double x1, double y1, Color c1, double x2, do
356
350
  op.vertices[3] = op.vertices[2];
357
351
  #endif
358
352
  op.z = z;
359
-
353
+
360
354
  current_queue().schedule_draw_op(op);
361
355
  }
362
356
 
363
357
  void Gosu::Graphics::draw_quad(double x1, double y1, Color c1, double x2, double y2, Color c2,
364
- double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z, AlphaMode mode)
358
+ double x3, double y3, Color c3, double x4, double y4, Color c4,
359
+ ZPos z, BlendMode mode)
365
360
  {
366
361
  normalize_coordinates(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
367
362
 
@@ -379,12 +374,12 @@ void Gosu::Graphics::draw_quad(double x1, double y1, Color c1, double x2, double
379
374
  op.vertices[2] = DrawOp::Vertex(x4, y4, c4);
380
375
  #endif
381
376
  op.z = z;
382
-
377
+
383
378
  current_queue().schedule_draw_op(op);
384
379
  }
385
380
 
386
- void Gosu::Graphics::draw_rect(double x, double y, double width, double height, Color c,
387
- ZPos z, Gosu::AlphaMode mode)
381
+ void Gosu::Graphics::draw_rect(double x, double y, double width, double height, Color c, ZPos z,
382
+ Gosu::BlendMode mode)
388
383
  {
389
384
  draw_quad(x, y, c, x + width, y, c, x, y + height, c, x + width, y + height, c, z, mode);
390
385
  }
@@ -396,8 +391,8 @@ void Gosu::Graphics::schedule_draw_op(const Gosu::DrawOp& op)
396
391
 
397
392
  void Gosu::Graphics::set_physical_resolution(unsigned phys_width, unsigned phys_height)
398
393
  {
399
- pimpl->phys_width = phys_width;
400
- pimpl->phys_height = phys_height;
394
+ m_impl->phys_width = phys_width;
395
+ m_impl->phys_height = phys_height;
401
396
  // TODO: Should be merged into RenderState and removed from Graphics.
402
397
  glMatrixMode(GL_PROJECTION);
403
398
  glLoadIdentity();
@@ -408,29 +403,28 @@ void Gosu::Graphics::set_physical_resolution(unsigned phys_width, unsigned phys_
408
403
  glOrtho(0, phys_width, phys_height, 0, -1, 1);
409
404
  #endif
410
405
 
411
- pimpl->update_base_transform();
406
+ m_impl->update_base_transform();
412
407
  }
413
408
 
414
- unique_ptr<Gosu::ImageData> Gosu::Graphics::create_image(const Bitmap& src,
415
- unsigned src_x, unsigned src_y, unsigned src_width, unsigned src_height, unsigned flags)
409
+ std::unique_ptr<Gosu::ImageData> Gosu::Graphics::create_image(const Bitmap& src, unsigned src_x,
410
+ unsigned src_y, unsigned src_width,
411
+ unsigned src_height, unsigned flags)
416
412
  {
417
413
  static const unsigned max_size = MAX_TEXTURE_SIZE;
418
-
414
+
419
415
  // Backward compatibility: This used to be 'bool tileable'.
420
416
  if (flags == 1) flags = IF_TILEABLE;
421
417
 
422
418
  bool wants_retro = (flags & IF_RETRO);
423
-
419
+
424
420
  // Special case: If the texture is supposed to have hard borders, is
425
421
  // quadratic, has a size that is at least 64 pixels but no more than max_size
426
422
  // pixels and a power of two, create a single texture just for this image.
427
- if ((flags & IF_TILEABLE) == IF_TILEABLE &&
428
- src_width == src_height &&
429
- (src_width & (src_width - 1)) == 0 &&
430
- src_width >= 64 && src_width <= max_size) {
431
- shared_ptr<Texture> texture(new Texture(src_width, src_height, wants_retro));
432
- unique_ptr<ImageData> data;
433
-
423
+ if ((flags & IF_TILEABLE) == IF_TILEABLE && src_width == src_height &&
424
+ (src_width & (src_width - 1)) == 0 && src_width >= 64 && src_width <= max_size) {
425
+ std::shared_ptr<Texture> texture{new Texture(src_width, src_height, wants_retro)};
426
+ std::unique_ptr<ImageData> data;
427
+
434
428
  // Use the source bitmap directly if the source area completely covers
435
429
  // it.
436
430
  if (src_x == 0 && src_width == src.width() && src_y == 0 && src_height == src.height()) {
@@ -441,38 +435,36 @@ unique_ptr<Gosu::ImageData> Gosu::Graphics::create_image(const Bitmap& src,
441
435
  bmp.insert(0, 0, src, src_x, src_y, src_width, src_height);
442
436
  data = texture->try_alloc(bmp, 0);
443
437
  }
444
-
445
- if (!data) throw logic_error("Internal texture block allocation error");
438
+
439
+ if (!data) throw std::logic_error{"Internal texture block allocation error"};
446
440
  return data;
447
441
  }
448
-
442
+
449
443
  // Too large to fit on a single texture.
450
444
  if (src_width > max_size - 2 || src_height > max_size - 2) {
451
445
  Bitmap bmp(src_width, src_height);
452
446
  bmp.insert(0, 0, src, src_x, src_y, src_width, src_height);
453
- unique_ptr<ImageData> lidi;
454
- lidi.reset(new LargeImageData(bmp, max_size - 2, max_size - 2, flags));
455
- return lidi;
447
+ return std::unique_ptr<ImageData>{
448
+ new LargeImageData(bmp, max_size - 2, max_size - 2, flags)};
456
449
  }
457
-
450
+
458
451
  Bitmap bmp = apply_border_flags(flags, src, src_x, src_y, src_width, src_height);
459
452
 
460
453
  // Try to put the bitmap into one of the already allocated textures.
461
454
  for (const auto& texture : textures) {
462
455
  if (texture->retro() != wants_retro) continue;
463
-
464
- unique_ptr<ImageData> data = texture->try_alloc(bmp, 1);
456
+
457
+ std::unique_ptr<ImageData> data = texture->try_alloc(bmp, 1);
465
458
  if (data) return data;
466
459
  }
467
-
460
+
468
461
  // All textures are full: Create a new one.
469
-
470
- shared_ptr<Texture> texture;
471
- texture.reset(new Texture(max_size, max_size, wants_retro));
462
+
463
+ std::shared_ptr<Texture> texture{new Texture(max_size, max_size, wants_retro)};
472
464
  textures.push_back(texture);
473
-
474
- unique_ptr<ImageData> data;
475
- data = texture->try_alloc(bmp, 1);
476
- if (!data.get()) throw logic_error("Internal texture block allocation error");
465
+
466
+ std::unique_ptr<ImageData> data{texture->try_alloc(bmp, 1)};
467
+ if (!data.get()) throw std::logic_error("Internal texture block allocation error");
468
+
477
469
  return data;
478
470
  }