gosu 1.4.6 → 2.0.0.pre6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +2 -1
  3. data/dependencies/SDL/include/SDL_atomic.h +2 -3
  4. data/dependencies/SDL/include/SDL_audio.h +7 -7
  5. data/dependencies/SDL/include/SDL_blendmode.h +1 -1
  6. data/dependencies/SDL/include/SDL_endian.h +3 -3
  7. data/dependencies/SDL/include/SDL_gamecontroller.h +4 -4
  8. data/dependencies/SDL/include/SDL_hints.h +72 -28
  9. data/dependencies/SDL/include/SDL_joystick.h +8 -5
  10. data/dependencies/SDL/include/SDL_keycode.h +1 -1
  11. data/dependencies/SDL/include/SDL_main.h +7 -0
  12. data/dependencies/SDL/include/SDL_mouse.h +6 -7
  13. data/dependencies/SDL/include/SDL_mutex.h +79 -5
  14. data/dependencies/SDL/include/SDL_opengl_glext.h +5 -1
  15. data/dependencies/SDL/include/SDL_power.h +7 -8
  16. data/dependencies/SDL/include/SDL_render.h +5 -0
  17. data/dependencies/SDL/include/SDL_revision.h +2 -2
  18. data/dependencies/SDL/include/SDL_sensor.h +1 -1
  19. data/dependencies/SDL/include/SDL_stdinc.h +19 -11
  20. data/dependencies/SDL/include/SDL_thread.h +2 -2
  21. data/dependencies/SDL/include/SDL_version.h +2 -2
  22. data/dependencies/SDL/include/SDL_video.h +30 -2
  23. data/dependencies/SDL/include/begin_code.h +7 -7
  24. data/dependencies/SDL/include/close_code.h +2 -2
  25. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  26. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  27. data/dependencies/SDL_sound/SDL_sound.h +1 -1
  28. data/dependencies/SDL_sound/dr_flac.h +48 -23
  29. data/dependencies/SDL_sound/dr_mp3.h +34 -14
  30. data/dependencies/SDL_sound/stb_vorbis.h +3 -2
  31. data/dependencies/mojoAL/mojoal.c +1 -1
  32. data/ext/{gosu → gosu-ffi}/extconf.rb +34 -33
  33. data/ext/gosu-ffi/gosu-ffi.def +464 -0
  34. data/ffi/Gosu.cpp +307 -0
  35. data/ffi/Gosu.h +84 -0
  36. data/ffi/Gosu_Channel.cpp +62 -0
  37. data/ffi/Gosu_Channel.h +17 -0
  38. data/ffi/Gosu_Color.cpp +132 -0
  39. data/ffi/Gosu_Color.h +31 -0
  40. data/ffi/Gosu_Constants.cpp +334 -0
  41. data/ffi/Gosu_FFI.h +34 -0
  42. data/ffi/Gosu_FFI_internal.h +161 -0
  43. data/ffi/Gosu_Font.cpp +92 -0
  44. data/ffi/Gosu_Font.h +32 -0
  45. data/ffi/Gosu_Image.cpp +206 -0
  46. data/ffi/Gosu_Image.h +60 -0
  47. data/ffi/Gosu_Sample.cpp +29 -0
  48. data/ffi/Gosu_Sample.h +14 -0
  49. data/ffi/Gosu_Song.cpp +69 -0
  50. data/ffi/Gosu_Song.h +18 -0
  51. data/ffi/Gosu_TextInput.cpp +94 -0
  52. data/ffi/Gosu_TextInput.h +25 -0
  53. data/ffi/Gosu_Window.cpp +314 -0
  54. data/ffi/Gosu_Window.h +78 -0
  55. data/include/Gosu/Audio.hpp +6 -11
  56. data/include/Gosu/Bitmap.hpp +38 -53
  57. data/include/Gosu/Buffer.hpp +54 -0
  58. data/include/Gosu/Color.hpp +27 -35
  59. data/include/Gosu/Directories.hpp +25 -28
  60. data/include/Gosu/Drawable.hpp +58 -0
  61. data/include/Gosu/Font.hpp +6 -5
  62. data/include/Gosu/Fwd.hpp +4 -6
  63. data/include/Gosu/Gosu.hpp +5 -5
  64. data/include/Gosu/Graphics.hpp +51 -61
  65. data/include/Gosu/GraphicsBase.hpp +1 -11
  66. data/include/Gosu/Image.hpp +11 -14
  67. data/include/Gosu/Math.hpp +50 -72
  68. data/include/Gosu/Transform.hpp +32 -0
  69. data/include/Gosu/Utility.hpp +51 -1
  70. data/include/Gosu/Version.hpp +3 -3
  71. data/include/Gosu/Window.hpp +15 -9
  72. data/lib/SDL2.dll +0 -0
  73. data/lib/gosu/channel.rb +49 -0
  74. data/lib/gosu/color.rb +150 -0
  75. data/lib/gosu/compat.rb +29 -8
  76. data/lib/gosu/constants.rb +386 -0
  77. data/lib/gosu/ffi.rb +258 -0
  78. data/lib/gosu/font.rb +56 -0
  79. data/lib/gosu/gl_tex_info.rb +33 -0
  80. data/lib/gosu/gosu.rb +210 -0
  81. data/lib/gosu/image.rb +141 -0
  82. data/lib/gosu/numeric.rb +17 -0
  83. data/lib/gosu/preview.rb +6 -6
  84. data/lib/gosu/sample.rb +24 -0
  85. data/lib/gosu/song.rb +56 -0
  86. data/lib/gosu/text_input.rb +69 -0
  87. data/lib/gosu/window.rb +228 -0
  88. data/lib/gosu.rb +29 -8
  89. data/lib64/SDL2.dll +0 -0
  90. data/rdoc/gosu.rb +0 -2
  91. data/src/Audio.cpp +12 -12
  92. data/src/AudioFile.hpp +5 -4
  93. data/src/AudioFileAudioToolbox.cpp +8 -8
  94. data/src/AudioFileSDLSound.cpp +7 -10
  95. data/src/BinPacker.cpp +187 -0
  96. data/src/BinPacker.hpp +55 -0
  97. data/src/Bitmap.cpp +166 -144
  98. data/src/BitmapIO.cpp +60 -86
  99. data/src/Buffer.cpp +159 -0
  100. data/src/Color.cpp +75 -80
  101. data/src/Directories.cpp +47 -0
  102. data/src/DirectoriesUIKit.cpp +50 -0
  103. data/src/DrawOp.hpp +9 -4
  104. data/src/DrawOpQueue.hpp +2 -2
  105. data/src/Drawable.cpp +95 -0
  106. data/src/EmptyDrawable.hpp +38 -0
  107. data/src/FPS.cpp +31 -0
  108. data/src/Font.cpp +104 -74
  109. data/src/GosuGLView.cpp +14 -6
  110. data/src/GosuViewController.cpp +2 -10
  111. data/src/Graphics.cpp +60 -126
  112. data/src/GraphicsImpl.hpp +17 -47
  113. data/src/Image.cpp +41 -35
  114. data/src/Input.cpp +7 -8
  115. data/src/Macro.cpp +6 -6
  116. data/src/Macro.hpp +4 -4
  117. data/src/MarkupParser.cpp +5 -5
  118. data/src/Math.cpp +35 -22
  119. data/src/OffScreenTarget.cpp +53 -49
  120. data/src/OffScreenTarget.hpp +13 -11
  121. data/src/OpenGLContext.cpp +117 -0
  122. data/src/OpenGLContext.hpp +41 -0
  123. data/src/RenderState.hpp +21 -19
  124. data/src/Resolution.cpp +23 -21
  125. data/src/TexChunk.cpp +35 -80
  126. data/src/TexChunk.hpp +44 -35
  127. data/src/Text.cpp +1 -1
  128. data/src/TextBuilder.cpp +35 -21
  129. data/src/TextBuilder.hpp +6 -9
  130. data/src/Texture.cpp +62 -80
  131. data/src/Texture.hpp +25 -23
  132. data/src/TiledDrawable.cpp +150 -0
  133. data/src/TiledDrawable.hpp +47 -0
  134. data/src/TimingApple.cpp +1 -1
  135. data/src/Transform.cpp +45 -50
  136. data/src/TransformStack.hpp +16 -16
  137. data/src/TrueTypeFont.cpp +59 -51
  138. data/src/TrueTypeFont.hpp +6 -7
  139. data/src/TrueTypeFontApple.cpp +28 -19
  140. data/src/TrueTypeFontUnix.cpp +27 -23
  141. data/src/TrueTypeFontWin.cpp +30 -30
  142. data/src/Utility.cpp +84 -21
  143. data/src/UtilityWin.cpp +45 -0
  144. data/src/Window.cpp +92 -142
  145. data/src/WindowUIKit.cpp +14 -14
  146. metadata +72 -31
  147. data/include/Gosu/IO.hpp +0 -254
  148. data/include/Gosu/ImageData.hpp +0 -53
  149. data/include/Gosu/Inspection.hpp +0 -7
  150. data/lib/gosu/patches.rb +0 -66
  151. data/lib/gosu/run.rb +0 -20
  152. data/lib/gosu/swig_patches.rb +0 -110
  153. data/src/BlockAllocator.cpp +0 -131
  154. data/src/BlockAllocator.hpp +0 -32
  155. data/src/DirectoriesApple.cpp +0 -69
  156. data/src/DirectoriesUnix.cpp +0 -46
  157. data/src/DirectoriesWin.cpp +0 -65
  158. data/src/EmptyImageData.hpp +0 -52
  159. data/src/FileUnix.cpp +0 -99
  160. data/src/FileWin.cpp +0 -88
  161. data/src/IO.cpp +0 -60
  162. data/src/Iconv.hpp +0 -51
  163. data/src/Inspection.cpp +0 -27
  164. data/src/LargeImageData.cpp +0 -215
  165. data/src/LargeImageData.hpp +0 -39
  166. data/src/Log.hpp +0 -19
  167. data/src/RubyGosu.cxx +0 -13100
  168. data/src/RubyGosu.h +0 -49
  169. data/src/WinUtility.cpp +0 -61
  170. data/src/WinUtility.hpp +0 -27
data/ffi/Gosu.cpp ADDED
@@ -0,0 +1,307 @@
1
+ #include <Gosu/Transform.hpp>
2
+ #include "Gosu_FFI_internal.h"
3
+
4
+ GOSU_FFI_API void Init_gosu()
5
+ {
6
+ }
7
+
8
+ std::string& Gosu_internal_error()
9
+ {
10
+ static thread_local std::string error;
11
+ return error;
12
+ }
13
+
14
+ GOSU_FFI_API const char* Gosu_last_error(void)
15
+ {
16
+ return Gosu_internal_error().empty() ? nullptr : Gosu_internal_error().c_str();
17
+ }
18
+
19
+ GOSU_FFI_API void Gosu_gl_z(double z, void function(void*), void* data)
20
+ {
21
+ Gosu_translate_exceptions([=] {
22
+ Gosu::gl(z, [=] { function(data); });
23
+ });
24
+ }
25
+
26
+ GOSU_FFI_API void Gosu_gl(void function(void*), void* data)
27
+ {
28
+ Gosu_translate_exceptions([=] {
29
+ Gosu::gl([=] { function(data); });
30
+ });
31
+ }
32
+
33
+ GOSU_FFI_API Gosu_Image* Gosu_render(int width, int height, void function(void*), void* data,
34
+ unsigned image_flags)
35
+ {
36
+ return Gosu_translate_exceptions([=] {
37
+ Gosu::Image image = Gosu::render(width, height, [=] { function(data); }, image_flags);
38
+ return new Gosu_Image{image};
39
+ });
40
+ }
41
+
42
+ GOSU_FFI_API Gosu_Image* Gosu_record(int width, int height, void function(void*), void* data)
43
+ {
44
+ return Gosu_translate_exceptions([=] {
45
+ Gosu::Image image = Gosu::record(width, height, [=] { function(data); });
46
+ return new Gosu_Image{image};
47
+ });
48
+ }
49
+
50
+ GOSU_FFI_API void Gosu_flush(void)
51
+ {
52
+ Gosu_translate_exceptions([=] {
53
+ Gosu::flush();
54
+ });
55
+ }
56
+
57
+ GOSU_FFI_API void Gosu_transform(double m0, double m1, double m2, double m3, double m4, double m5,
58
+ double m6, double m7, double m8, double m9, double m10, double m11,
59
+ double m12, double m13, double m14, double m15,
60
+ void function(void*), void* data)
61
+ {
62
+ Gosu_translate_exceptions([=] {
63
+ Gosu::Transform transform = {m0, m1, m2, m3, m4, m5, m6, m7,
64
+ m8, m9, m10, m11, m12, m13, m14, m15};
65
+ Gosu::transform(transform, [=] { function(data); });
66
+ });
67
+ }
68
+
69
+ GOSU_FFI_API void Gosu_translate(double x, double y, void function(void*), void* data)
70
+ {
71
+ Gosu_translate_exceptions([=] {
72
+ Gosu::transform(Gosu::Transform::translate(x, y), [=] { function(data); });
73
+ });
74
+ }
75
+
76
+ GOSU_FFI_API void Gosu_scale(double scale_x, double scale_y, double around_x, double around_y,
77
+ void function(void*), void* data)
78
+ {
79
+ Gosu_translate_exceptions([=] {
80
+ Gosu::transform(Gosu::Transform::scale(scale_x, scale_y).around(around_x, around_y),
81
+ [=] { function(data); });
82
+ });
83
+ }
84
+
85
+ GOSU_FFI_API void Gosu_rotate(double angle, double around_x, double around_y, void function(void*),
86
+ void* data)
87
+ {
88
+ Gosu_translate_exceptions([=] {
89
+ Gosu::transform(Gosu::Transform::rotate(angle).around(around_x, around_y),
90
+ [=] { function(data); });
91
+ });
92
+ }
93
+
94
+ GOSU_FFI_API void Gosu_clip_to(double x, double y, double width, double height,
95
+ void function(void*), void* data)
96
+ {
97
+ Gosu_translate_exceptions([=] {
98
+ Gosu::clip_to(x, y, width, height, [=] { function(data); });
99
+ });
100
+ }
101
+
102
+ GOSU_FFI_API void Gosu_draw_line(double x1, double y1, unsigned c1, double x2, double y2,
103
+ unsigned c2, double z, unsigned mode)
104
+ {
105
+ Gosu_translate_exceptions([=] {
106
+ Gosu::draw_line(x1, y1, c1, x2, y2, c2, z, static_cast<Gosu::BlendMode>(mode));
107
+ });
108
+ }
109
+
110
+ GOSU_FFI_API void Gosu_draw_triangle(double x1, double y1, unsigned c1, double x2, double y2,
111
+ unsigned c2, double x3, double y3, unsigned c3, double z,
112
+ unsigned mode)
113
+ {
114
+ Gosu_translate_exceptions([=] {
115
+ Gosu::draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z,
116
+ static_cast<Gosu::BlendMode>(mode));
117
+ });
118
+ }
119
+
120
+ GOSU_FFI_API void Gosu_draw_rect(double x, double y, double width, double height, unsigned c,
121
+ double z, unsigned mode)
122
+ {
123
+ Gosu_translate_exceptions([=] {
124
+ Gosu::draw_rect(x, y, width, height, c, z, static_cast<Gosu::BlendMode>(mode));
125
+ });
126
+ }
127
+
128
+ GOSU_FFI_API void Gosu_draw_quad(double x1, double y1, unsigned c1, double x2, double y2,
129
+ unsigned c2, double x3, double y3, unsigned c3, double x4,
130
+ double y4, unsigned c4, double z, unsigned mode)
131
+ {
132
+ Gosu_translate_exceptions([=] {
133
+ Gosu::draw_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z,
134
+ static_cast<Gosu::BlendMode>(mode));
135
+ });
136
+ }
137
+
138
+ GOSU_FFI_API double Gosu_distance(double x1, double y1, double x2, double y2)
139
+ {
140
+ return Gosu_translate_exceptions([=] {
141
+ return Gosu::distance(x1, y1, x2, y2);
142
+ });
143
+ }
144
+
145
+ GOSU_FFI_API double Gosu_angle(double from_x, double from_y, double to_x, double to_y)
146
+ {
147
+ return Gosu_translate_exceptions([=] {
148
+ return Gosu::angle(from_x, from_y, to_x, to_y);
149
+ });
150
+ }
151
+
152
+ GOSU_FFI_API double Gosu_angle_diff(double from, double to)
153
+ {
154
+ return Gosu_translate_exceptions([=] {
155
+ return Gosu::angle_diff(from, to);
156
+ });
157
+ }
158
+
159
+ GOSU_FFI_API double Gosu_offset_x(double angle, double radius)
160
+ {
161
+ return Gosu_translate_exceptions([=] {
162
+ return Gosu::offset_x(angle, radius);
163
+ });
164
+ }
165
+
166
+ GOSU_FFI_API double Gosu_offset_y(double angle, double radius)
167
+ {
168
+ return Gosu_translate_exceptions([=] {
169
+ return Gosu::offset_y(angle, radius);
170
+ });
171
+ }
172
+
173
+ GOSU_FFI_API double Gosu_random(double min, double max)
174
+ {
175
+ return Gosu_translate_exceptions([=] {
176
+ return Gosu::random(min, max);
177
+ });
178
+ }
179
+
180
+ GOSU_FFI_API int Gosu_available_width(Gosu_Window* window)
181
+ {
182
+ return Gosu_translate_exceptions([=] {
183
+ return Gosu::available_width(window);
184
+ });
185
+ }
186
+
187
+ GOSU_FFI_API int Gosu_available_height(Gosu_Window* window)
188
+ {
189
+ return Gosu_translate_exceptions([=] {
190
+ return Gosu::available_height(window);
191
+ });
192
+ }
193
+
194
+ GOSU_FFI_API int Gosu_screen_width(Gosu_Window* window)
195
+ {
196
+ return Gosu_translate_exceptions([=] {
197
+ return Gosu::screen_width(window);
198
+ });
199
+ }
200
+
201
+ GOSU_FFI_API int Gosu_screen_height(Gosu_Window* window)
202
+ {
203
+ return Gosu_translate_exceptions([=] {
204
+ return Gosu::screen_height(window);
205
+ });
206
+ }
207
+
208
+ GOSU_FFI_API int Gosu_button_down(int id)
209
+ {
210
+ return Gosu_translate_exceptions([=] {
211
+ return Gosu::Input::down(static_cast<Gosu::Button>(id));
212
+ });
213
+ }
214
+
215
+ GOSU_FFI_API const char* Gosu_button_id_to_char(int id)
216
+ {
217
+ static thread_local std::string button;
218
+
219
+ return Gosu_translate_exceptions([=] {
220
+ button = Gosu::Input::id_to_char(static_cast<Gosu::Button>(id));
221
+ return button.c_str();
222
+ });
223
+ }
224
+
225
+ GOSU_FFI_API unsigned Gosu_button_char_to_id(const char* btn)
226
+ {
227
+ return Gosu_translate_exceptions([=] {
228
+ return Gosu::Input::char_to_id(btn);
229
+ });
230
+ }
231
+
232
+ GOSU_FFI_API const char* Gosu_button_name(int id)
233
+ {
234
+ static thread_local std::string name;
235
+
236
+ return Gosu_translate_exceptions([=] {
237
+ name = Gosu::Input::button_name(static_cast<Gosu::Button>(id));
238
+ return name.empty() ? nullptr : name.c_str();
239
+ });
240
+ }
241
+
242
+ GOSU_FFI_API const char* Gosu_gamepad_name(int id)
243
+ {
244
+ static thread_local std::string name;
245
+
246
+ return Gosu_translate_exceptions([=] {
247
+ name = Gosu::Input::gamepad_name(id);
248
+ return name.empty() ? nullptr : name.c_str();
249
+ });
250
+ }
251
+
252
+ GOSU_FFI_API double Gosu_axis(int id)
253
+ {
254
+ return Gosu_translate_exceptions([=] {
255
+ return Gosu::Input::axis(static_cast<Gosu::Button>(id));
256
+ });
257
+ }
258
+
259
+ GOSU_FFI_API const char* Gosu_clipboard()
260
+ {
261
+ static thread_local std::string text;
262
+
263
+ return Gosu_translate_exceptions([=] {
264
+ text = Gosu::Input::clipboard();
265
+ return text.c_str();
266
+ });
267
+ }
268
+
269
+ GOSU_FFI_API void Gosu_set_clipboard(const char* text)
270
+ {
271
+ Gosu_translate_exceptions([=] {
272
+ Gosu::Input::set_clipboard(text);
273
+ });
274
+ }
275
+
276
+ GOSU_FFI_API int Gosu_fps()
277
+ {
278
+ return Gosu_translate_exceptions([=] {
279
+ return Gosu::fps();
280
+ });
281
+ }
282
+
283
+ GOSU_FFI_API void Gosu_user_languages(void function(void*, const char*), void* data)
284
+ {
285
+ Gosu_translate_exceptions([=] {
286
+ for (const std::string& user_language : Gosu::user_languages()) {
287
+ function(data, user_language.c_str());
288
+ }
289
+ });
290
+ }
291
+
292
+ GOSU_FFI_API uint64_t Gosu_milliseconds()
293
+ {
294
+ return Gosu_translate_exceptions([=] {
295
+ return Gosu::milliseconds();
296
+ });
297
+ }
298
+
299
+ GOSU_FFI_API const char* Gosu_default_font_name()
300
+ {
301
+ static thread_local std::string name;
302
+
303
+ return Gosu_translate_exceptions([=] {
304
+ name = Gosu::default_font_name();
305
+ return name.c_str();
306
+ });
307
+ }
data/ffi/Gosu.h ADDED
@@ -0,0 +1,84 @@
1
+ #pragma once
2
+
3
+ #include "Gosu_Channel.h"
4
+ #include "Gosu_Color.h"
5
+ #include "Gosu_FFI.h"
6
+ #include "Gosu_Font.h"
7
+ #include "Gosu_Image.h"
8
+ #include "Gosu_Sample.h"
9
+ #include "Gosu_Song.h"
10
+ #include "Gosu_TextInput.h"
11
+ #include "Gosu_Window.h"
12
+ #include <stdint.h>
13
+
14
+ // Error reporting
15
+ GOSU_FFI_API const char* Gosu_last_error(void);
16
+
17
+ // Graphics operations
18
+ GOSU_FFI_API void Gosu_gl_z(double z, void function(void* data), void* data);
19
+ GOSU_FFI_API void Gosu_gl(void function(void* data), void* data);
20
+ GOSU_FFI_API void Gosu_flush(void);
21
+ GOSU_FFI_API Gosu_Image* Gosu_render(int width, int height, void function(void* data), void* data,
22
+ unsigned image_flags);
23
+ GOSU_FFI_API Gosu_Image* Gosu_record(int width, int height, void function(void* data), void* data);
24
+ GOSU_FFI_API void Gosu_clip_to(double x, double y, double width, double height,
25
+ void function(void* data), void* data);
26
+
27
+ // Transformations
28
+ GOSU_FFI_API void Gosu_transform(double m0, double m1, double m2, double m3, double m4, double m5,
29
+ double m6, double m7, double m8, double m9, double m10, double m11,
30
+ double m12, double m13, double m14, double m15,
31
+ void function(void* data), void* data);
32
+ GOSU_FFI_API void Gosu_translate(double x, double y, void function(void* data), void* data);
33
+ GOSU_FFI_API void Gosu_scale(double scale_x, double scale_y, double around_x, double around_y,
34
+ void function(void* data), void* data);
35
+ GOSU_FFI_API void Gosu_rotate(double angle, double around_x, double around_y,
36
+ void function(void* data), void* data);
37
+
38
+ // Rendering
39
+ GOSU_FFI_API void Gosu_draw_line(double x1, double y1, unsigned c1, double x2, double y2,
40
+ unsigned c2, double z, unsigned mode);
41
+ GOSU_FFI_API void Gosu_draw_triangle(double x1, double y1, unsigned c1, double x2, double y2,
42
+ unsigned c2, double x3, double y3, unsigned c3, double z,
43
+ unsigned mode);
44
+ GOSU_FFI_API void Gosu_draw_rect(double x, double y, double width, double height, unsigned c,
45
+ double z, unsigned mode);
46
+ GOSU_FFI_API void Gosu_draw_quad(double x1, double y1, unsigned c1, double x2, double y2,
47
+ unsigned c2, double x3, double y3, unsigned c3, double x4,
48
+ double y4, unsigned c4, double z, unsigned mode);
49
+
50
+ // Math functions
51
+ GOSU_FFI_API double Gosu_distance(double x1, double y1, double x2, double y2);
52
+
53
+ GOSU_FFI_API double Gosu_angle(double from_x, double from_y, double to_x, double to_y);
54
+ GOSU_FFI_API double Gosu_angle_diff(double from, double to);
55
+
56
+ GOSU_FFI_API double Gosu_offset_x(double angle, double radius);
57
+ GOSU_FFI_API double Gosu_offset_y(double angle, double radius);
58
+
59
+ GOSU_FFI_API double Gosu_random(double min, double max);
60
+
61
+ // Window/Screen information
62
+ GOSU_FFI_API int Gosu_available_width(Gosu_Window* window);
63
+ GOSU_FFI_API int Gosu_available_height(Gosu_Window* window);
64
+ GOSU_FFI_API int Gosu_screen_width(Gosu_Window* window);
65
+ GOSU_FFI_API int Gosu_screen_height(Gosu_Window* window);
66
+
67
+ // Button querying
68
+ GOSU_FFI_API int Gosu_button_down(int id);
69
+ GOSU_FFI_API const char* Gosu_button_id_to_char(int id);
70
+ GOSU_FFI_API unsigned Gosu_button_char_to_id(const char* character);
71
+ GOSU_FFI_API const char* Gosu_button_name(int id);
72
+ GOSU_FFI_API const char* Gosu_gamepad_name(int id);
73
+ GOSU_FFI_API double Gosu_axis(int id);
74
+
75
+ // Clipboard
76
+ GOSU_FFI_API const char* Gosu_clipboard();
77
+ GOSU_FFI_API void Gosu_set_clipboard(const char* text);
78
+
79
+ // Misc
80
+ GOSU_FFI_API int Gosu_fps(void);
81
+ GOSU_FFI_API void Gosu_user_languages(void function(void* data, const char* language),
82
+ void* data);
83
+ GOSU_FFI_API uint64_t Gosu_milliseconds(void);
84
+ GOSU_FFI_API const char* Gosu_default_font_name(void);
@@ -0,0 +1,62 @@
1
+ #include "Gosu_FFI_internal.h"
2
+
3
+ GOSU_FFI_API void Gosu_Channel_destroy(Gosu_Channel* channel)
4
+ {
5
+ delete channel;
6
+ }
7
+
8
+ GOSU_FFI_API bool Gosu_Channel_playing(Gosu_Channel* channel)
9
+ {
10
+ return Gosu_translate_exceptions([=] {
11
+ return channel->channel.playing();
12
+ });
13
+ }
14
+
15
+ GOSU_FFI_API void Gosu_Channel_pause(Gosu_Channel* channel)
16
+ {
17
+ Gosu_translate_exceptions([=] {
18
+ channel->channel.pause();
19
+ });
20
+ }
21
+
22
+ GOSU_FFI_API bool Gosu_Channel_paused(Gosu_Channel* channel)
23
+ {
24
+ return Gosu_translate_exceptions([=] {
25
+ return channel->channel.paused();
26
+ });
27
+ }
28
+
29
+ GOSU_FFI_API void Gosu_Channel_resume(Gosu_Channel* channel)
30
+ {
31
+ Gosu_translate_exceptions([=] {
32
+ channel->channel.resume();
33
+ });
34
+ }
35
+
36
+ GOSU_FFI_API void Gosu_Channel_stop(Gosu_Channel* channel)
37
+ {
38
+ Gosu_translate_exceptions([=] {
39
+ channel->channel.stop();
40
+ });
41
+ }
42
+
43
+ GOSU_FFI_API void Gosu_Channel_set_volume(Gosu_Channel* channel, double volume)
44
+ {
45
+ Gosu_translate_exceptions([=] {
46
+ channel->channel.set_volume(volume);
47
+ });
48
+ }
49
+
50
+ GOSU_FFI_API void Gosu_Channel_set_speed(Gosu_Channel* channel, double speed)
51
+ {
52
+ Gosu_translate_exceptions([=] {
53
+ channel->channel.set_speed(speed);
54
+ });
55
+ }
56
+
57
+ GOSU_FFI_API void Gosu_Channel_set_pan(Gosu_Channel* channel, double pan)
58
+ {
59
+ Gosu_translate_exceptions([=] {
60
+ channel->channel.set_pan(pan);
61
+ });
62
+ }
@@ -0,0 +1,17 @@
1
+ #pragma once
2
+
3
+ #include "Gosu_FFI.h"
4
+
5
+ typedef struct Gosu_Channel Gosu_Channel;
6
+
7
+ GOSU_FFI_API void Gosu_Channel_destroy(Gosu_Channel* channel);
8
+
9
+ GOSU_FFI_API bool Gosu_Channel_playing(Gosu_Channel* channel);
10
+ GOSU_FFI_API void Gosu_Channel_pause(Gosu_Channel* channel);
11
+ GOSU_FFI_API bool Gosu_Channel_paused(Gosu_Channel* channel);
12
+ GOSU_FFI_API void Gosu_Channel_resume(Gosu_Channel* channel);
13
+ GOSU_FFI_API void Gosu_Channel_stop(Gosu_Channel* channel);
14
+
15
+ GOSU_FFI_API void Gosu_Channel_set_volume(Gosu_Channel* channel, double volume);
16
+ GOSU_FFI_API void Gosu_Channel_set_speed(Gosu_Channel* channel, double speed);
17
+ GOSU_FFI_API void Gosu_Channel_set_pan(Gosu_Channel* channel, double pan);
@@ -0,0 +1,132 @@
1
+ #include "Gosu_FFI_internal.h"
2
+
3
+ GOSU_FFI_API uint32_t Gosu_Color_create(uint32_t argb)
4
+ {
5
+ return Gosu::Color{argb}.argb();
6
+ }
7
+
8
+ GOSU_FFI_API uint32_t Gosu_Color_create_argb(uint8_t a, uint8_t r, uint8_t g, uint8_t b)
9
+ {
10
+ return Gosu::Color{r, g, b}.with_alpha(a).argb();
11
+ }
12
+
13
+ GOSU_FFI_API uint32_t Gosu_Color_create_from_hsv(double h, double s, double v)
14
+ {
15
+ return Gosu::Color::from_hsv(h, s, v).argb();
16
+ }
17
+
18
+ GOSU_FFI_API uint32_t Gosu_Color_create_from_ahsv(uint8_t alpha, double h, double s, double v)
19
+ {
20
+ return Gosu::Color::from_hsv(h, s, v).with_alpha(alpha).argb();
21
+ }
22
+
23
+ GOSU_FFI_API uint8_t Gosu_Color_alpha(uint32_t color)
24
+ {
25
+ return Gosu::Color{color}.alpha;
26
+ }
27
+
28
+ GOSU_FFI_API uint8_t Gosu_Color_red(uint32_t color)
29
+ {
30
+ return Gosu::Color{color}.red;
31
+ }
32
+
33
+ GOSU_FFI_API uint8_t Gosu_Color_green(uint32_t color)
34
+ {
35
+ return Gosu::Color{color}.green;
36
+ }
37
+
38
+ GOSU_FFI_API uint8_t Gosu_Color_blue(uint32_t color)
39
+ {
40
+ return Gosu::Color{color}.blue;
41
+ }
42
+
43
+ GOSU_FFI_API uint32_t Gosu_Color_set_alpha(uint32_t color, uint8_t value)
44
+ {
45
+ Gosu::Color gosu_color{color};
46
+ gosu_color.alpha = value;
47
+
48
+ return gosu_color.argb();
49
+ }
50
+
51
+ GOSU_FFI_API uint32_t Gosu_Color_set_red(uint32_t color, uint8_t value)
52
+ {
53
+ Gosu::Color gosu_color{color};
54
+ gosu_color.red = value;
55
+
56
+ return gosu_color.argb();
57
+ }
58
+
59
+ GOSU_FFI_API uint32_t Gosu_Color_set_green(uint32_t color, uint8_t value)
60
+ {
61
+ Gosu::Color gosu_color{color};
62
+ gosu_color.green = value;
63
+
64
+ return gosu_color.argb();
65
+ }
66
+
67
+ GOSU_FFI_API uint32_t Gosu_Color_set_blue(uint32_t color, uint8_t value)
68
+ {
69
+ Gosu::Color gosu_color{color};
70
+ gosu_color.blue = value;
71
+
72
+ return gosu_color.argb();
73
+ }
74
+
75
+ GOSU_FFI_API double Gosu_Color_hue(uint32_t color)
76
+ {
77
+ return Gosu::Color{color}.hue();
78
+ }
79
+
80
+ GOSU_FFI_API double Gosu_Color_saturation(uint32_t color)
81
+ {
82
+ return Gosu::Color{color}.saturation();
83
+ }
84
+
85
+ GOSU_FFI_API double Gosu_Color_value(uint32_t color)
86
+ {
87
+ return Gosu::Color{color}.value();
88
+ }
89
+
90
+ GOSU_FFI_API uint32_t Gosu_Color_set_hue(uint32_t color, double value)
91
+ {
92
+ Gosu::Color gosu_color{color};
93
+ gosu_color.set_hue(value);
94
+
95
+ return gosu_color.argb();
96
+ }
97
+
98
+ GOSU_FFI_API uint32_t Gosu_Color_set_saturation(uint32_t color, double value)
99
+ {
100
+ Gosu::Color gosu_color{color};
101
+ gosu_color.set_saturation(value);
102
+
103
+ return gosu_color.argb();
104
+ }
105
+
106
+ GOSU_FFI_API uint32_t Gosu_Color_set_value(uint32_t color, double value)
107
+ {
108
+ Gosu::Color gosu_color{color};
109
+ gosu_color.set_value(value);
110
+
111
+ return gosu_color.argb();
112
+ }
113
+
114
+ GOSU_FFI_API uint32_t Gosu_Color_argb(uint32_t color)
115
+ {
116
+ return Gosu::Color{color}.argb();
117
+ }
118
+
119
+ GOSU_FFI_API uint32_t Gosu_Color_bgr(uint32_t color)
120
+ {
121
+ return Gosu::Color{color}.bgr();
122
+ }
123
+
124
+ GOSU_FFI_API uint32_t Gosu_Color_abgr(uint32_t color)
125
+ {
126
+ return Gosu::Color{color}.abgr();
127
+ }
128
+
129
+ GOSU_FFI_API uint32_t Gosu_Color_gl(uint32_t color)
130
+ {
131
+ return color;
132
+ }
data/ffi/Gosu_Color.h ADDED
@@ -0,0 +1,31 @@
1
+ #pragma once
2
+
3
+ #include "Gosu_FFI.h"
4
+ #include "stdint.h"
5
+
6
+ GOSU_FFI_API uint32_t Gosu_Color_create(uint32_t argb);
7
+ GOSU_FFI_API uint32_t Gosu_Color_create_argb(uint8_t a, uint8_t r, uint8_t g, uint8_t b);
8
+ GOSU_FFI_API uint32_t Gosu_Color_create_from_hsv(double h, double s, double v);
9
+ GOSU_FFI_API uint32_t Gosu_Color_create_from_ahsv(uint8_t alpha, double h, double s, double v);
10
+
11
+ GOSU_FFI_API uint8_t Gosu_Color_alpha(uint32_t color);
12
+ GOSU_FFI_API uint8_t Gosu_Color_red(uint32_t color);
13
+ GOSU_FFI_API uint8_t Gosu_Color_green(uint32_t color);
14
+ GOSU_FFI_API uint8_t Gosu_Color_blue(uint32_t color);
15
+ GOSU_FFI_API uint32_t Gosu_Color_set_alpha(uint32_t color, uint8_t value);
16
+ GOSU_FFI_API uint32_t Gosu_Color_set_red(uint32_t color, uint8_t value);
17
+ GOSU_FFI_API uint32_t Gosu_Color_set_green(uint32_t color, uint8_t value);
18
+ GOSU_FFI_API uint32_t Gosu_Color_set_blue(uint32_t color, uint8_t value);
19
+
20
+ GOSU_FFI_API double Gosu_Color_hue(uint32_t color);
21
+ GOSU_FFI_API double Gosu_Color_saturation(uint32_t color);
22
+ GOSU_FFI_API double Gosu_Color_value(uint32_t color);
23
+ GOSU_FFI_API uint32_t Gosu_Color_set_hue(uint32_t color, double value);
24
+ GOSU_FFI_API uint32_t Gosu_Color_set_saturation(uint32_t color, double value);
25
+ GOSU_FFI_API uint32_t Gosu_Color_set_value(uint32_t color, double value);
26
+
27
+ GOSU_FFI_API uint32_t Gosu_Color_argb(uint32_t color);
28
+ GOSU_FFI_API uint32_t Gosu_Color_bgr(uint32_t color);
29
+ GOSU_FFI_API uint32_t Gosu_Color_abgr(uint32_t color);
30
+
31
+ GOSU_FFI_API uint32_t Gosu_Color_gl(uint32_t color);