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
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 2.0.0.pre6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-20 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2023-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
13
27
  description: |2
14
28
  2D game development library.
15
29
 
@@ -19,7 +33,7 @@ description: |2
19
33
  email: julian@raschke.de
20
34
  executables: []
21
35
  extensions:
22
- - ext/gosu/extconf.rb
36
+ - ext/gosu-ffi/extconf.rb
23
37
  extra_rdoc_files:
24
38
  - README.md
25
39
  - COPYING
@@ -167,37 +181,69 @@ files:
167
181
  - dependencies/utf8proc/utf8proc.c
168
182
  - dependencies/utf8proc/utf8proc.h
169
183
  - dependencies/utf8proc/utf8proc_data.h
170
- - ext/gosu/extconf.rb
184
+ - ext/gosu-ffi/extconf.rb
185
+ - ext/gosu-ffi/gosu-ffi.def
186
+ - ffi/Gosu.cpp
187
+ - ffi/Gosu.h
188
+ - ffi/Gosu_Channel.cpp
189
+ - ffi/Gosu_Channel.h
190
+ - ffi/Gosu_Color.cpp
191
+ - ffi/Gosu_Color.h
192
+ - ffi/Gosu_Constants.cpp
193
+ - ffi/Gosu_FFI.h
194
+ - ffi/Gosu_FFI_internal.h
195
+ - ffi/Gosu_Font.cpp
196
+ - ffi/Gosu_Font.h
197
+ - ffi/Gosu_Image.cpp
198
+ - ffi/Gosu_Image.h
199
+ - ffi/Gosu_Sample.cpp
200
+ - ffi/Gosu_Sample.h
201
+ - ffi/Gosu_Song.cpp
202
+ - ffi/Gosu_Song.h
203
+ - ffi/Gosu_TextInput.cpp
204
+ - ffi/Gosu_TextInput.h
205
+ - ffi/Gosu_Window.cpp
206
+ - ffi/Gosu_Window.h
171
207
  - include/Gosu/Audio.hpp
172
208
  - include/Gosu/Bitmap.hpp
209
+ - include/Gosu/Buffer.hpp
173
210
  - include/Gosu/Buttons.hpp
174
211
  - include/Gosu/Color.hpp
175
212
  - include/Gosu/Directories.hpp
213
+ - include/Gosu/Drawable.hpp
176
214
  - include/Gosu/Font.hpp
177
215
  - include/Gosu/Fwd.hpp
178
216
  - include/Gosu/Gosu.hpp
179
217
  - include/Gosu/Graphics.hpp
180
218
  - include/Gosu/GraphicsBase.hpp
181
- - include/Gosu/IO.hpp
182
219
  - include/Gosu/Image.hpp
183
- - include/Gosu/ImageData.hpp
184
220
  - include/Gosu/Input.hpp
185
- - include/Gosu/Inspection.hpp
186
221
  - include/Gosu/Math.hpp
187
222
  - include/Gosu/Platform.hpp
188
223
  - include/Gosu/Text.hpp
189
224
  - include/Gosu/TextInput.hpp
190
225
  - include/Gosu/Timing.hpp
226
+ - include/Gosu/Transform.hpp
191
227
  - include/Gosu/Utility.hpp
192
228
  - include/Gosu/Version.hpp
193
229
  - include/Gosu/Window.hpp
194
230
  - lib/SDL2.dll
195
231
  - lib/gosu.rb
232
+ - lib/gosu/channel.rb
233
+ - lib/gosu/color.rb
196
234
  - lib/gosu/compat.rb
197
- - lib/gosu/patches.rb
235
+ - lib/gosu/constants.rb
236
+ - lib/gosu/ffi.rb
237
+ - lib/gosu/font.rb
238
+ - lib/gosu/gl_tex_info.rb
239
+ - lib/gosu/gosu.rb
240
+ - lib/gosu/image.rb
241
+ - lib/gosu/numeric.rb
198
242
  - lib/gosu/preview.rb
199
- - lib/gosu/run.rb
200
- - lib/gosu/swig_patches.rb
243
+ - lib/gosu/sample.rb
244
+ - lib/gosu/song.rb
245
+ - lib/gosu/text_input.rb
246
+ - lib/gosu/window.rb
201
247
  - lib64/SDL2.dll
202
248
  - rdoc/gosu.rb
203
249
  - src/Audio.cpp
@@ -206,21 +252,21 @@ files:
206
252
  - src/AudioFileSDLSound.cpp
207
253
  - src/AudioImpl.cpp
208
254
  - src/AudioImpl.hpp
255
+ - src/BinPacker.cpp
256
+ - src/BinPacker.hpp
209
257
  - src/Bitmap.cpp
210
258
  - src/BitmapIO.cpp
211
- - src/BlockAllocator.cpp
212
- - src/BlockAllocator.hpp
259
+ - src/Buffer.cpp
213
260
  - src/Channel.cpp
214
261
  - src/ClipRectStack.hpp
215
262
  - src/Color.cpp
216
- - src/DirectoriesApple.cpp
217
- - src/DirectoriesUnix.cpp
218
- - src/DirectoriesWin.cpp
263
+ - src/Directories.cpp
264
+ - src/DirectoriesUIKit.cpp
219
265
  - src/DrawOp.hpp
220
266
  - src/DrawOpQueue.hpp
221
- - src/EmptyImageData.hpp
222
- - src/FileUnix.cpp
223
- - src/FileWin.cpp
267
+ - src/Drawable.cpp
268
+ - src/EmptyDrawable.hpp
269
+ - src/FPS.cpp
224
270
  - src/Font.cpp
225
271
  - src/GosuGLView.cpp
226
272
  - src/GosuGLView.hpp
@@ -228,15 +274,9 @@ files:
228
274
  - src/GosuViewController.hpp
229
275
  - src/Graphics.cpp
230
276
  - src/GraphicsImpl.hpp
231
- - src/IO.cpp
232
- - src/Iconv.hpp
233
277
  - src/Image.cpp
234
278
  - src/Input.cpp
235
279
  - src/InputUIKit.cpp
236
- - src/Inspection.cpp
237
- - src/LargeImageData.cpp
238
- - src/LargeImageData.hpp
239
- - src/Log.hpp
240
280
  - src/Macro.cpp
241
281
  - src/Macro.hpp
242
282
  - src/MarkupParser.cpp
@@ -244,10 +284,10 @@ files:
244
284
  - src/Math.cpp
245
285
  - src/OffScreenTarget.cpp
246
286
  - src/OffScreenTarget.hpp
287
+ - src/OpenGLContext.cpp
288
+ - src/OpenGLContext.hpp
247
289
  - src/RenderState.hpp
248
290
  - src/Resolution.cpp
249
- - src/RubyGosu.cxx
250
- - src/RubyGosu.h
251
291
  - src/TexChunk.cpp
252
292
  - src/TexChunk.hpp
253
293
  - src/Text.cpp
@@ -256,6 +296,8 @@ files:
256
296
  - src/TextInput.cpp
257
297
  - src/Texture.cpp
258
298
  - src/Texture.hpp
299
+ - src/TiledDrawable.cpp
300
+ - src/TiledDrawable.hpp
259
301
  - src/TimingApple.cpp
260
302
  - src/TimingUnix.cpp
261
303
  - src/TimingWin.cpp
@@ -267,9 +309,8 @@ files:
267
309
  - src/TrueTypeFontUnix.cpp
268
310
  - src/TrueTypeFontWin.cpp
269
311
  - src/Utility.cpp
312
+ - src/UtilityWin.cpp
270
313
  - src/Version.cpp
271
- - src/WinUtility.cpp
272
- - src/WinUtility.hpp
273
314
  - src/Window.cpp
274
315
  - src/WindowUIKit.cpp
275
316
  homepage: https://www.libgosu.org/
@@ -291,9 +332,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
291
332
  version: 2.5.0
292
333
  required_rubygems_version: !ruby/object:Gem::Requirement
293
334
  requirements:
294
- - - ">="
335
+ - - ">"
295
336
  - !ruby/object:Gem::Version
296
- version: '0'
337
+ version: 1.3.1
297
338
  requirements: []
298
339
  rubygems_version: 3.4.3
299
340
  signing_key:
data/include/Gosu/IO.hpp DELETED
@@ -1,254 +0,0 @@
1
- #pragma once
2
-
3
- #include <Gosu/Platform.hpp>
4
- #include <algorithm>
5
- #include <cstddef>
6
- #include <memory>
7
- #include <string>
8
- #include <vector>
9
-
10
- namespace Gosu
11
- {
12
- class Resource;
13
-
14
- enum ByteOrder { BO_LITTLE, BO_BIG, BO_DONT_CARE };
15
- #ifdef __BIG_ENDIAN__
16
- const ByteOrder BO_NATIVE = BO_BIG, BO_OTHER = BO_LITTLE;
17
- #else
18
- const ByteOrder BO_NATIVE = BO_LITTLE, BO_OTHER = BO_BIG;
19
- #endif
20
-
21
- //! Utility class that points to a specific position in a resource
22
- //! and offers an interface for sequential reading.
23
- class Reader
24
- {
25
- const Resource* res;
26
- std::size_t pos;
27
-
28
- public:
29
- Reader(const Resource& resource, std::size_t position)
30
- : res(&resource), pos(position)
31
- {
32
- }
33
-
34
- const Resource& resource() const
35
- {
36
- return *res;
37
- }
38
-
39
- std::size_t position() const
40
- {
41
- return pos;
42
- }
43
-
44
- void set_position(std::size_t value)
45
- {
46
- // TODO: Check?
47
- pos = value;
48
- }
49
-
50
- void seek(std::ptrdiff_t offset)
51
- {
52
- // TODO: Check?
53
- pos += offset;
54
- }
55
-
56
- void read(void* dest_buffer, std::size_t length);
57
-
58
- //! Convenience function; equivalent to read(&t, sizeof t).
59
- template<typename T>
60
- void read_pod(T& t, ByteOrder bo = BO_DONT_CARE)
61
- {
62
- read(&t, sizeof t);
63
- if (bo == BO_OTHER) {
64
- char* begin = reinterpret_cast<char*>(&t);
65
- std::reverse(begin, begin + sizeof t);
66
- }
67
- }
68
-
69
- //! Similar to read_pod(T&), but returns the read value instead.
70
- template<typename T>
71
- T get_pod(ByteOrder bo = BO_DONT_CARE)
72
- {
73
- T t;
74
- read_pod<T>(t, bo);
75
- return t;
76
- }
77
- };
78
-
79
- //! Utility class that points to a specific position in a resource
80
- //! and offers an interface for sequential writing.
81
- class Writer
82
- {
83
- Resource* res;
84
- std::size_t pos;
85
-
86
- public:
87
- Writer(Resource& resource, std::size_t position)
88
- : res(&resource), pos(position)
89
- {
90
- }
91
-
92
- Resource& resource() const
93
- {
94
- return *res;
95
- }
96
-
97
- std::size_t position() const
98
- {
99
- return pos;
100
- }
101
-
102
- void set_position(std::size_t value)
103
- {
104
- // TODO: Check?
105
- pos = value;
106
- }
107
-
108
- void seek(std::ptrdiff_t offset)
109
- {
110
- // TODO: Check?
111
- pos += offset;
112
- }
113
-
114
- void write(const void* source_buffer, std::size_t length);
115
-
116
- //! Convenience function; equivalent to write(&t, sizeof t).
117
- template<typename T>
118
- void write_pod(const T& t, ByteOrder bo = BO_DONT_CARE)
119
- {
120
- if (bo == BO_OTHER) {
121
- char buf[sizeof t];
122
- const char* begin = reinterpret_cast<const char*>(&t);
123
- std::reverse_copy(begin, begin + sizeof t, buf);
124
- write(buf, sizeof buf);
125
- }
126
- else {
127
- write(&t, sizeof t);
128
- }
129
- }
130
- };
131
-
132
- //! Base class for resources. A resource in Gosu is nothing more but a
133
- //! piece of binary data that can be read or written, for example files
134
- //! or simply areas of allocated memory.
135
- //! A resource always knows its size and can resize itself, thereby either
136
- //! truncating its content or allocating room for more data.
137
- class Resource
138
- {
139
- // Non-copyable and non-movable to avoid slicing.
140
- Resource(const Resource&) = delete;
141
- Resource& operator=(const Resource&) = delete;
142
- Resource(Resource&&) = delete;
143
- Resource& operator=(Resource&&) = delete;
144
-
145
- public:
146
- Resource()
147
- {
148
- }
149
-
150
- virtual ~Resource()
151
- {
152
- }
153
-
154
- //! Convenience: Creates a new Reader that reads from the start of
155
- //! the resource.
156
- Reader front_reader() const
157
- {
158
- return Reader(*this, 0);
159
- }
160
-
161
- //! Convenience: Creates a new Writer that appends data at the
162
- //! end of the resource.
163
- Writer back_writer()
164
- {
165
- return Writer(*this, size());
166
- }
167
-
168
- virtual std::size_t size() const = 0;
169
-
170
- virtual void resize(std::size_t new_size) = 0;
171
-
172
- virtual void read(std::size_t offset, std::size_t length, void* dest_buffer) const = 0;
173
-
174
- virtual void write(std::size_t offset, std::size_t length, const void* source_buffer) = 0;
175
- };
176
-
177
- //! Piece of memory with the Resource interface.
178
- class Buffer : public Resource
179
- {
180
- std::vector<char> buf;
181
-
182
- public:
183
- Buffer()
184
- {
185
- }
186
-
187
- Buffer(const Buffer& other)
188
- : Resource()
189
- , buf(other.buf)
190
- {
191
- }
192
-
193
- Buffer& operator=(const Buffer& other)
194
- {
195
- buf = other.buf;
196
- return *this;
197
- }
198
-
199
- std::size_t size() const override;
200
-
201
- void resize(std::size_t new_size) override;
202
-
203
- void read(std::size_t offset, std::size_t length, void* dest_buffer) const override;
204
-
205
- void write(std::size_t offset, std::size_t length, const void* source_buffer) override;
206
-
207
- const void* data() const
208
- {
209
- return &buf[0];
210
- }
211
-
212
- void* data()
213
- {
214
- return &buf[0];
215
- }
216
- };
217
-
218
- enum FileMode
219
- {
220
- //! Opens an existing file for reading; throws an exception if the file
221
- //! cannot be found.
222
- FM_READ,
223
- //! Writes data to a file. If the file already exists, is emptied on
224
- //! opening. If the file does not exist, it is created.
225
- FM_REPLACE,
226
- //! Opens or creates a file with writing access, but does not clear
227
- //! existing contents.
228
- FM_ALTER
229
- };
230
-
231
- //! File with the Resource interface.
232
- class File : public Resource
233
- {
234
- struct Impl;
235
- const std::unique_ptr<Impl> pimpl;
236
-
237
- public:
238
- explicit File(const std::string& filename, FileMode mode = FM_READ);
239
- ~File();
240
-
241
- std::size_t size() const override;
242
-
243
- void resize(std::size_t new_size) override;
244
-
245
- void read(std::size_t offset, std::size_t length, void* dest_buffer) const override;
246
-
247
- void write(std::size_t offset, std::size_t length, const void* source_buffer) override;
248
- };
249
-
250
- //! Loads a whole file into a buffer.
251
- void load_file(Buffer& buffer, const std::string& filename);
252
- //! Creates or overwrites a file with the contents of a buffer.
253
- void save_file(const Buffer& buffer, const std::string& filename);
254
- }
@@ -1,53 +0,0 @@
1
- #pragma once
2
-
3
- #include <Gosu/Fwd.hpp>
4
- #include <Gosu/Color.hpp>
5
- #include <Gosu/GraphicsBase.hpp>
6
- #include <Gosu/Platform.hpp>
7
- #include <memory>
8
-
9
- namespace Gosu
10
- {
11
- /// Contains information about the underlying OpenGL texture and the u/v space used for image
12
- /// data. Can be retrieved from some images to use them in OpenGL operations.
13
- struct GLTexInfo
14
- {
15
- int tex_name;
16
- double left, right, top, bottom;
17
- };
18
-
19
- /// The ImageData class is an abstract base class for drawable images.
20
- /// Instances of classes derived by ImageData are usually returned by Graphics::create_image and
21
- /// usually only used to implement drawing primitives like Image, which then provide a more
22
- /// specialized and intuitive drawing interface.
23
- class ImageData
24
- {
25
- public:
26
- // Classes inside a hierarchy should not be copyable to avoid slicing.
27
- ImageData(const ImageData&) = delete;
28
- ImageData(ImageData&&) = delete;
29
- ImageData& operator=(const ImageData&) = delete;
30
- ImageData& operator=(ImageData&&) = delete;
31
-
32
- ImageData() = default;
33
- virtual ~ImageData() = default;
34
-
35
- virtual int width() const = 0;
36
-
37
- virtual int height() const = 0;
38
-
39
- virtual void draw(double x1, double y1, Color c1, //
40
- double x2, double y2, Color c2, //
41
- double x3, double y3, Color c3, //
42
- double x4, double y4, Color c4, //
43
- ZPos z, BlendMode mode) const = 0;
44
-
45
- virtual const GLTexInfo* gl_tex_info() const = 0;
46
-
47
- virtual Bitmap to_bitmap() const = 0;
48
-
49
- virtual std::unique_ptr<ImageData> subimage(int x, int y, int width, int height) const = 0;
50
-
51
- virtual void insert(const Bitmap& bitmap, int x, int y) = 0;
52
- };
53
- }
@@ -1,7 +0,0 @@
1
- #pragma once
2
-
3
- namespace Gosu
4
- {
5
- /// Returns the current framerate.
6
- int fps();
7
- }
data/lib/gosu/patches.rb DELETED
@@ -1,66 +0,0 @@
1
- # Extend Numeric with simple angle conversion methods,
2
- # for easier integration with Chipmunk.
3
- class ::Numeric
4
- def degrees_to_radians
5
- self * Math::PI / 180.0
6
- end
7
-
8
- def radians_to_degrees
9
- self * 180.0 / Math::PI
10
- end
11
-
12
- def gosu_to_radians
13
- (self - 90) * Math::PI / 180.0
14
- end
15
-
16
- def radians_to_gosu
17
- self * 180.0 / Math::PI + 90
18
- end
19
- end
20
-
21
- class Gosu::Image
22
- BlobHelper = Struct.new(:columns, :rows, :to_blob)
23
-
24
- def self.from_blob(width, height, rgba = "\0\0\0\0" * (width * height))
25
- self.new(BlobHelper.new(width, height, rgba))
26
- end
27
- end
28
-
29
- # Color constants.
30
- # This is cleaner than having SWIG define them.
31
- module Gosu
32
- class ImmutableColor < Color
33
- private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
34
- end
35
-
36
- class Color
37
- NONE = Gosu::ImmutableColor.new(0x00_000000)
38
- BLACK = Gosu::ImmutableColor.new(0xff_000000)
39
- GRAY = Gosu::ImmutableColor.new(0xff_808080)
40
- WHITE = Gosu::ImmutableColor.new(0xff_ffffff)
41
- AQUA = Gosu::ImmutableColor.new(0xff_00ffff)
42
- RED = Gosu::ImmutableColor.new(0xff_ff0000)
43
- GREEN = Gosu::ImmutableColor.new(0xff_00ff00)
44
- BLUE = Gosu::ImmutableColor.new(0xff_0000ff)
45
- YELLOW = Gosu::ImmutableColor.new(0xff_ffff00)
46
- FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
47
- CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
48
-
49
- alias_method :hash, :gl
50
- def eql?(other)
51
- gl == other.gl
52
- end
53
- end
54
- end
55
-
56
- class Gosu::Window
57
- # Call Thread.pass every tick, which may or may not be necessary for friendly co-existence with
58
- # Ruby's Thread class.
59
-
60
- alias_method :_tick, :tick
61
-
62
- def tick
63
- Thread.pass
64
- _tick
65
- end
66
- end
data/lib/gosu/run.rb DELETED
@@ -1,20 +0,0 @@
1
- # This script is used by Ruby.app: https://github.com/gosu/ruby_app
2
-
3
- # Replace the load path.
4
- $LOAD_PATH.clear
5
- $LOAD_PATH << File.dirname(__FILE__)[0..-6]
6
- $LOAD_PATH << $LOAD_PATH[0] + '/lib'
7
-
8
- # Ruby portions of Gosu.
9
- require 'gosu/patches'
10
- require 'gosu/swig_patches'
11
-
12
- # Let the application know it is being run from the Mac app wrapper.
13
- OSX_EXECUTABLE = true
14
-
15
- # Main application.
16
- begin
17
- require 'Main'
18
- rescue LoadError
19
- require 'main'
20
- end