gosu 1.5.0 → 2.0.0.pre6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +233 -0
- data/dependencies/SDL/include/SDL_assert.h +320 -0
- data/dependencies/SDL/include/SDL_atomic.h +414 -0
- data/dependencies/SDL/include/SDL_audio.h +1500 -0
- data/dependencies/SDL/include/{SDL3/SDL_bits.h → SDL_bits.h} +27 -47
- data/dependencies/SDL/include/{SDL3/SDL_blendmode.h → SDL_blendmode.h} +55 -59
- data/dependencies/SDL/include/SDL_clipboard.h +141 -0
- data/dependencies/SDL/include/SDL_config.h +331 -0
- data/dependencies/SDL/include/SDL_cpuinfo.h +594 -0
- data/dependencies/SDL/include/{SDL3/SDL_egl.h → SDL_egl.h} +8 -11
- data/dependencies/SDL/include/SDL_endian.h +348 -0
- data/dependencies/SDL/include/SDL_error.h +163 -0
- data/dependencies/SDL/include/SDL_events.h +1166 -0
- data/dependencies/SDL/include/SDL_filesystem.h +149 -0
- data/dependencies/SDL/include/SDL_gamecontroller.h +1074 -0
- data/dependencies/SDL/include/SDL_gesture.h +117 -0
- data/dependencies/SDL/include/SDL_guid.h +100 -0
- data/dependencies/SDL/include/SDL_haptic.h +1341 -0
- data/dependencies/SDL/include/SDL_hidapi.h +451 -0
- data/dependencies/SDL/include/SDL_hints.h +2613 -0
- data/dependencies/SDL/include/SDL_joystick.h +1069 -0
- data/dependencies/SDL/include/SDL_keyboard.h +353 -0
- data/dependencies/SDL/include/SDL_keycode.h +358 -0
- data/dependencies/SDL/include/SDL_loadso.h +115 -0
- data/dependencies/SDL/include/{SDL3/SDL_locale.h → SDL_locale.h} +24 -40
- data/dependencies/SDL/include/SDL_log.h +404 -0
- data/dependencies/SDL/include/SDL_main.h +282 -0
- data/dependencies/SDL/include/{SDL3/SDL_messagebox.h → SDL_messagebox.h} +48 -85
- data/dependencies/SDL/include/{SDL3/SDL_metal.h → SDL_metal.h} +29 -29
- data/dependencies/SDL/include/{SDL3/SDL_misc.h → SDL_misc.h} +12 -13
- data/dependencies/SDL/include/SDL_mouse.h +464 -0
- data/dependencies/SDL/include/SDL_mutex.h +545 -0
- data/dependencies/SDL/include/SDL_name.h +33 -0
- data/dependencies/SDL/include/{SDL3/SDL_opengl.h → SDL_opengl.h} +252 -1221
- data/dependencies/SDL/include/{SDL3/SDL_opengles.h → SDL_opengles.h} +7 -6
- data/dependencies/SDL/include/{SDL3/SDL_opengles2.h → SDL_opengles2.h} +11 -10
- data/dependencies/SDL/include/SDL_pixels.h +644 -0
- data/dependencies/SDL/include/SDL_platform.h +261 -0
- data/dependencies/SDL/include/{SDL3/SDL_power.h → SDL_power.h} +19 -40
- data/dependencies/SDL/include/SDL_quit.h +58 -0
- data/dependencies/SDL/include/SDL_rect.h +376 -0
- data/dependencies/SDL/include/SDL_render.h +1924 -0
- data/dependencies/SDL/include/SDL_revision.h +7 -0
- data/dependencies/SDL/include/SDL_rwops.h +841 -0
- data/dependencies/SDL/include/{SDL3/SDL_scancode.h → SDL_scancode.h} +68 -60
- data/dependencies/SDL/include/SDL_sensor.h +322 -0
- data/dependencies/SDL/include/SDL_shape.h +155 -0
- data/dependencies/SDL/include/SDL_stdinc.h +838 -0
- data/dependencies/SDL/include/SDL_surface.h +997 -0
- data/dependencies/SDL/include/SDL_system.h +623 -0
- data/dependencies/SDL/include/SDL_syswm.h +386 -0
- data/dependencies/SDL/include/{SDL3/SDL_test.h → SDL_test.h} +22 -16
- data/dependencies/SDL/include/{SDL3/SDL_test_assert.h → SDL_test_assert.h} +34 -27
- data/dependencies/SDL/include/{SDL3/SDL_test_common.h → SDL_test_common.h} +52 -109
- data/dependencies/SDL/include/{SDL3/SDL_test_compare.h → SDL_test_compare.h} +14 -22
- data/dependencies/SDL/include/{SDL3/SDL_test_crc32.h → SDL_test_crc32.h} +30 -27
- data/dependencies/SDL/include/{SDL3/SDL_test_font.h → SDL_test_font.h} +49 -50
- data/dependencies/SDL/include/{SDL3/SDL_test_fuzzer.h → SDL_test_fuzzer.h} +79 -64
- data/dependencies/SDL/include/{SDL3/SDL_test_harness.h → SDL_test_harness.h} +30 -47
- data/dependencies/SDL/include/SDL_test_images.h +78 -0
- data/dependencies/SDL/include/{SDL3/SDL_platform.h → SDL_test_log.h} +26 -25
- data/dependencies/SDL/include/{SDL3/SDL_test_md5.h → SDL_test_md5.h} +28 -21
- data/dependencies/SDL/include/{SDL3/SDL_test_memory.h → SDL_test_memory.h} +16 -19
- data/dependencies/SDL/include/SDL_test_random.h +115 -0
- data/dependencies/SDL/include/SDL_thread.h +464 -0
- data/dependencies/SDL/include/SDL_timer.h +222 -0
- data/dependencies/SDL/include/SDL_touch.h +150 -0
- data/dependencies/SDL/include/{SDL3/SDL_copying.h → SDL_types.h} +9 -2
- data/dependencies/SDL/include/SDL_version.h +204 -0
- data/dependencies/SDL/include/SDL_video.h +2178 -0
- data/dependencies/SDL/include/SDL_vulkan.h +215 -0
- data/dependencies/SDL/include/begin_code.h +187 -0
- data/dependencies/SDL/include/{SDL3/SDL_close_code.h → close_code.h} +6 -7
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.c +215 -136
- data/dependencies/SDL_sound/SDL_sound.h +725 -0
- data/dependencies/SDL_sound/SDL_sound_aiff.c +54 -55
- data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +41 -24
- data/dependencies/SDL_sound/SDL_sound_flac.c +12 -32
- data/dependencies/SDL_sound/SDL_sound_internal.h +48 -33
- data/dependencies/SDL_sound/SDL_sound_modplug.c +29 -21
- data/dependencies/SDL_sound/SDL_sound_mp3.c +13 -35
- data/dependencies/SDL_sound/SDL_sound_raw.c +15 -14
- data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
- data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +25 -34
- data/dependencies/SDL_sound/SDL_sound_wav.c +82 -86
- data/dependencies/SDL_sound/dr_flac.h +1281 -1845
- data/dependencies/SDL_sound/dr_mp3.h +617 -1035
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +4 -5
- data/dependencies/SDL_sound/libmodplug/load_ams.c +3 -6
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +1 -2
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
- data/dependencies/SDL_sound/libmodplug/modplug.h +1 -2
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
- data/dependencies/SDL_sound/libmodplug/sndfile.c +0 -3
- data/dependencies/SDL_sound/libmodplug/sndmix.c +3 -7
- data/dependencies/SDL_sound/stb_vorbis.h +343 -397
- data/dependencies/mojoAL/AL/alc.h +2 -2
- data/dependencies/mojoAL/mojoal.c +1878 -2113
- data/dependencies/stb/stb_image.h +1381 -1192
- data/dependencies/stb/stb_image_write.h +129 -329
- data/dependencies/stb/stb_truetype.h +60 -304
- data/dependencies/utf8proc/utf8proc.c +75 -133
- data/dependencies/utf8proc/utf8proc.h +50 -131
- data/dependencies/utf8proc/utf8proc_data.h +15658 -16213
- data/ext/gosu-ffi/extconf.rb +28 -11
- data/ext/gosu-ffi/gosu-ffi.def +0 -3
- data/ffi/Gosu.cpp +29 -52
- data/ffi/Gosu.h +4 -4
- data/ffi/Gosu_Color.cpp +36 -80
- data/ffi/Gosu_FFI_internal.h +13 -12
- data/ffi/Gosu_Font.cpp +11 -16
- data/ffi/Gosu_Font.h +4 -4
- data/ffi/Gosu_Image.cpp +36 -69
- data/ffi/Gosu_Image.h +5 -16
- data/include/Gosu/Bitmap.hpp +1 -1
- data/include/Gosu/Color.hpp +4 -5
- data/include/Gosu/Graphics.hpp +0 -2
- data/include/Gosu/Image.hpp +1 -1
- data/include/Gosu/Math.hpp +5 -5
- data/include/Gosu/Utility.hpp +1 -27
- data/include/Gosu/Version.hpp +2 -2
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/channel.rb +0 -1
- data/lib/gosu/color.rb +13 -36
- data/lib/gosu/compat.rb +14 -106
- data/lib/gosu/constants.rb +24 -24
- data/lib/gosu/ffi.rb +13 -24
- data/lib/gosu/font.rb +13 -19
- data/lib/gosu/gosu.rb +61 -101
- data/lib/gosu/image.rb +34 -72
- data/lib/gosu/sample.rb +0 -1
- data/lib/gosu/song.rb +0 -1
- data/lib/gosu/text_input.rb +1 -15
- data/lib/gosu/window.rb +10 -31
- data/lib64/SDL2.dll +0 -0
- data/rdoc/gosu.rb +0 -2
- data/src/Audio.cpp +16 -22
- data/src/AudioFileSDLSound.cpp +5 -5
- data/src/BinPacker.cpp +4 -5
- data/src/Bitmap.cpp +9 -16
- data/src/Buffer.cpp +14 -5
- data/src/ClipRectStack.hpp +83 -17
- data/src/Directories.cpp +1 -1
- data/src/DrawOp.hpp +17 -14
- data/src/DrawOpQueue.hpp +31 -25
- data/src/Font.cpp +1 -1
- data/src/GosuGLView.cpp +7 -1
- data/src/Graphics.cpp +25 -32
- data/src/GraphicsImpl.hpp +24 -0
- data/src/Image.cpp +2 -2
- data/src/Input.cpp +70 -66
- data/src/Macro.cpp +26 -43
- data/src/Macro.hpp +16 -22
- data/src/Math.cpp +7 -20
- data/src/OffScreenTarget.cpp +10 -3
- data/src/OpenGLContext.cpp +8 -7
- data/src/OpenGLContext.hpp +2 -2
- data/src/RenderState.hpp +54 -30
- data/src/Resolution.cpp +38 -48
- data/src/TexChunk.cpp +2 -2
- data/src/TextInput.cpp +9 -9
- data/src/Texture.cpp +1 -1
- data/src/TiledDrawable.cpp +7 -6
- data/src/TrueTypeFontUnix.cpp +9 -12
- data/src/Utility.cpp +26 -39
- data/src/UtilityWin.cpp +2 -6
- data/src/Window.cpp +34 -54
- metadata +93 -99
- data/dependencies/SDL/include/SDL3/SDL.h +0 -91
- data/dependencies/SDL/include/SDL3/SDL_assert.h +0 -710
- data/dependencies/SDL/include/SDL3/SDL_asyncio.h +0 -550
- data/dependencies/SDL/include/SDL3/SDL_atomic.h +0 -692
- data/dependencies/SDL/include/SDL3/SDL_audio.h +0 -2382
- data/dependencies/SDL/include/SDL3/SDL_begin_code.h +0 -553
- data/dependencies/SDL/include/SDL3/SDL_camera.h +0 -535
- data/dependencies/SDL/include/SDL3/SDL_clipboard.h +0 -331
- data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +0 -374
- data/dependencies/SDL/include/SDL3/SDL_dialog.h +0 -343
- data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +0 -234
- data/dependencies/SDL/include/SDL3/SDL_endian.h +0 -645
- data/dependencies/SDL/include/SDL3/SDL_error.h +0 -226
- data/dependencies/SDL/include/SDL3/SDL_events.h +0 -1651
- data/dependencies/SDL/include/SDL3/SDL_filesystem.h +0 -537
- data/dependencies/SDL/include/SDL3/SDL_gamepad.h +0 -1657
- data/dependencies/SDL/include/SDL3/SDL_gpu.h +0 -4637
- data/dependencies/SDL/include/SDL3/SDL_guid.h +0 -106
- data/dependencies/SDL/include/SDL3/SDL_haptic.h +0 -1461
- data/dependencies/SDL/include/SDL3/SDL_hidapi.h +0 -571
- data/dependencies/SDL/include/SDL3/SDL_hints.h +0 -5041
- data/dependencies/SDL/include/SDL3/SDL_init.h +0 -508
- data/dependencies/SDL/include/SDL3/SDL_intrin.h +0 -410
- data/dependencies/SDL/include/SDL3/SDL_iostream.h +0 -1379
- data/dependencies/SDL/include/SDL3/SDL_joystick.h +0 -1385
- data/dependencies/SDL/include/SDL3/SDL_keyboard.h +0 -615
- data/dependencies/SDL/include/SDL3/SDL_keycode.h +0 -348
- data/dependencies/SDL/include/SDL3/SDL_loadso.h +0 -145
- data/dependencies/SDL/include/SDL3/SDL_log.h +0 -541
- data/dependencies/SDL/include/SDL3/SDL_main.h +0 -704
- data/dependencies/SDL/include/SDL3/SDL_main_impl.h +0 -149
- data/dependencies/SDL/include/SDL3/SDL_mouse.h +0 -813
- data/dependencies/SDL/include/SDL3/SDL_mutex.h +0 -1117
- data/dependencies/SDL/include/SDL3/SDL_oldnames.h +0 -1339
- data/dependencies/SDL/include/SDL3/SDL_pen.h +0 -198
- data/dependencies/SDL/include/SDL3/SDL_pixels.h +0 -1441
- data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +0 -497
- data/dependencies/SDL/include/SDL3/SDL_process.h +0 -441
- data/dependencies/SDL/include/SDL3/SDL_properties.h +0 -572
- data/dependencies/SDL/include/SDL3/SDL_rect.h +0 -528
- data/dependencies/SDL/include/SDL3/SDL_render.h +0 -3034
- data/dependencies/SDL/include/SDL3/SDL_revision.h +0 -56
- data/dependencies/SDL/include/SDL3/SDL_sensor.h +0 -321
- data/dependencies/SDL/include/SDL3/SDL_stdinc.h +0 -6186
- data/dependencies/SDL/include/SDL3/SDL_storage.h +0 -686
- data/dependencies/SDL/include/SDL3/SDL_surface.h +0 -1769
- data/dependencies/SDL/include/SDL3/SDL_system.h +0 -840
- data/dependencies/SDL/include/SDL3/SDL_test_log.h +0 -83
- data/dependencies/SDL/include/SDL3/SDL_thread.h +0 -602
- data/dependencies/SDL/include/SDL3/SDL_time.h +0 -249
- data/dependencies/SDL/include/SDL3/SDL_timer.h +0 -454
- data/dependencies/SDL/include/SDL3/SDL_touch.h +0 -184
- data/dependencies/SDL/include/SDL3/SDL_tray.h +0 -544
- data/dependencies/SDL/include/SDL3/SDL_version.h +0 -198
- data/dependencies/SDL/include/SDL3/SDL_video.h +0 -3497
- data/dependencies/SDL/include/SDL3/SDL_vulkan.h +0 -287
- data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
- data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +0 -755
- data/lib/SDL3.dll +0 -0
- data/lib64/SDL3.dll +0 -0
- data/src/ClipRectStack.cpp +0 -38
- /data/dependencies/SDL/include/{SDL3/SDL_opengl_glext.h → SDL_opengl_glext.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2.h → SDL_opengles2_gl2.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2ext.h → SDL_opengles2_gl2ext.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2platform.h → SDL_opengles2_gl2platform.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_khrplatform.h → SDL_opengles2_khrplatform.h} +0 -0
data/src/Audio.cpp
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include <Gosu/Audio.hpp>
|
|
2
2
|
#include <Gosu/Buffer.hpp>
|
|
3
|
+
#include <Gosu/Math.hpp>
|
|
3
4
|
#include "AudioFile.hpp"
|
|
4
5
|
#include "AudioImpl.hpp"
|
|
5
6
|
#include <algorithm>
|
|
@@ -17,11 +18,11 @@ struct Gosu::Sample::Impl : private Gosu::Noncopyable
|
|
|
17
18
|
ALuint buffer;
|
|
18
19
|
|
|
19
20
|
explicit Impl(AudioFile&& audio_file)
|
|
20
|
-
|
|
21
|
+
: buffer{}
|
|
21
22
|
{
|
|
22
23
|
al_initialize();
|
|
23
24
|
alGenBuffers(1, &buffer);
|
|
24
|
-
alBufferData(buffer, audio_file.format(), audio_file.decoded_data().
|
|
25
|
+
alBufferData(buffer, audio_file.format(), &audio_file.decoded_data().front(),
|
|
25
26
|
static_cast<ALsizei>(audio_file.decoded_data().size()),
|
|
26
27
|
static_cast<ALsizei>(audio_file.sample_rate()));
|
|
27
28
|
}
|
|
@@ -30,9 +31,7 @@ struct Gosu::Sample::Impl : private Gosu::Noncopyable
|
|
|
30
31
|
{
|
|
31
32
|
// It's hard to free things in the right order in Ruby/Gosu.
|
|
32
33
|
// Make sure buffer isn't deleted after the context/device are shut down.
|
|
33
|
-
if (!al_initialized())
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
34
|
+
if (!al_initialized()) return;
|
|
36
35
|
|
|
37
36
|
alDeleteBuffers(1, &buffer);
|
|
38
37
|
}
|
|
@@ -59,16 +58,12 @@ Gosu::Channel Gosu::Sample::play(double volume, double speed, bool looping) cons
|
|
|
59
58
|
|
|
60
59
|
Gosu::Channel Gosu::Sample::play_pan(double pan, double volume, double speed, bool looping) const
|
|
61
60
|
{
|
|
62
|
-
if (!m_impl) {
|
|
63
|
-
return Channel();
|
|
64
|
-
}
|
|
61
|
+
if (!m_impl) return Channel{};
|
|
65
62
|
|
|
66
63
|
Channel channel = allocate_channel();
|
|
67
64
|
|
|
68
65
|
// Couldn't allocate a free channel.
|
|
69
|
-
if (channel.current_channel() == NO_CHANNEL)
|
|
70
|
-
return channel;
|
|
71
|
-
}
|
|
66
|
+
if (channel.current_channel() == NO_CHANNEL) return channel;
|
|
72
67
|
|
|
73
68
|
ALuint source = al_source_for_channel(channel.current_channel());
|
|
74
69
|
alSourcei(source, AL_BUFFER, static_cast<ALint>(m_impl->buffer));
|
|
@@ -106,7 +101,7 @@ private:
|
|
|
106
101
|
|
|
107
102
|
public:
|
|
108
103
|
explicit Impl(const std::string& filename)
|
|
109
|
-
: m_buffers
|
|
104
|
+
: m_buffers {},
|
|
110
105
|
m_file(new AudioFile(filename))
|
|
111
106
|
{
|
|
112
107
|
al_initialize();
|
|
@@ -114,7 +109,7 @@ public:
|
|
|
114
109
|
}
|
|
115
110
|
|
|
116
111
|
explicit Impl(Buffer buffer)
|
|
117
|
-
: m_buffers
|
|
112
|
+
: m_buffers {},
|
|
118
113
|
m_file(new AudioFile(std::move(buffer)))
|
|
119
114
|
{
|
|
120
115
|
al_initialize();
|
|
@@ -125,9 +120,7 @@ public:
|
|
|
125
120
|
{
|
|
126
121
|
// It's hard to free things in the right order in Ruby/Gosu.
|
|
127
122
|
// Make sure buffers aren't deleted after the context/device are shut down.
|
|
128
|
-
if (!al_initialized())
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
123
|
+
if (!al_initialized()) return;
|
|
131
124
|
|
|
132
125
|
alDeleteBuffers(2, m_buffers);
|
|
133
126
|
}
|
|
@@ -199,9 +192,7 @@ public:
|
|
|
199
192
|
for (int i = 0; i < processed; ++i) {
|
|
200
193
|
alSourceUnqueueBuffers(source, 1, &buffer);
|
|
201
194
|
active = stream_to_buffer(buffer);
|
|
202
|
-
if (active)
|
|
203
|
-
alSourceQueueBuffers(source, 1, &buffer);
|
|
204
|
-
}
|
|
195
|
+
if (active) alSourceQueueBuffers(source, 1, &buffer);
|
|
205
196
|
}
|
|
206
197
|
|
|
207
198
|
ALint state;
|
|
@@ -225,7 +216,10 @@ public:
|
|
|
225
216
|
}
|
|
226
217
|
}
|
|
227
218
|
|
|
228
|
-
double volume() const
|
|
219
|
+
double volume() const
|
|
220
|
+
{
|
|
221
|
+
return m_volume;
|
|
222
|
+
}
|
|
229
223
|
|
|
230
224
|
void set_volume(double volume)
|
|
231
225
|
{
|
|
@@ -235,12 +229,12 @@ public:
|
|
|
235
229
|
};
|
|
236
230
|
|
|
237
231
|
Gosu::Song::Song(const std::string& filename)
|
|
238
|
-
|
|
232
|
+
: m_impl(new Impl(filename))
|
|
239
233
|
{
|
|
240
234
|
}
|
|
241
235
|
|
|
242
236
|
Gosu::Song::Song(Buffer buffer)
|
|
243
|
-
|
|
237
|
+
: m_impl(new Impl(std::move(buffer)))
|
|
244
238
|
{
|
|
245
239
|
}
|
|
246
240
|
|
data/src/AudioFileSDLSound.cpp
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include "AudioFile.hpp"
|
|
7
7
|
#include "AudioImpl.hpp"
|
|
8
|
-
#include <
|
|
8
|
+
#include <SDL_sound.h>
|
|
9
9
|
#include <algorithm>
|
|
10
10
|
#include <cstdlib>
|
|
11
11
|
#include <cstring>
|
|
@@ -36,12 +36,12 @@ Gosu::AudioFile::AudioFile(const std::string& filename)
|
|
|
36
36
|
{
|
|
37
37
|
// We need to set a "desired" audio format, otherwise we may encounter data formats such as
|
|
38
38
|
// floating-point samples that Apple's OpenAL implementation does not support.
|
|
39
|
-
|
|
39
|
+
Sound_AudioInfo desired;
|
|
40
40
|
// Prefer 16-bit signed data which is supported by all versions of OpenAL.
|
|
41
|
-
desired.format =
|
|
41
|
+
desired.format = AUDIO_S16;
|
|
42
42
|
// 0 means "use whatever we have" (see SDL_sound.c, init_sample).
|
|
43
43
|
desired.channels = 0;
|
|
44
|
-
desired.
|
|
44
|
+
desired.rate = 0;
|
|
45
45
|
|
|
46
46
|
pimpl->sample.reset(Sound_NewSampleFromFile(filename.c_str(), &desired, 4096),
|
|
47
47
|
Sound_FreeSample);
|
|
@@ -97,7 +97,7 @@ ALenum Gosu::AudioFile::format() const
|
|
|
97
97
|
|
|
98
98
|
ALuint Gosu::AudioFile::sample_rate() const
|
|
99
99
|
{
|
|
100
|
-
return pimpl->sample->actual.
|
|
100
|
+
return pimpl->sample->actual.rate;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
void Gosu::AudioFile::rewind()
|
data/src/BinPacker.cpp
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
Gosu::BinPacker::BinPacker(int width, int height)
|
|
10
10
|
: m_width(width),
|
|
11
11
|
m_height(height),
|
|
12
|
-
m_free_rects { Rect
|
|
12
|
+
m_free_rects { Rect { 0, 0, width, height } }
|
|
13
13
|
{
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -27,9 +27,8 @@ std::shared_ptr<const Gosu::Rect> Gosu::BinPacker::alloc(int width, int height)
|
|
|
27
27
|
// We found a free area, place the result in the top left corner of it.
|
|
28
28
|
// (Also make sure that the pointer's deleter returns the rectangle. Note: Even though
|
|
29
29
|
// shared_ptr may call its deleter with a nullptr in general, it will not do so here.)
|
|
30
|
-
std::shared_ptr<const Rect> result(
|
|
31
|
-
|
|
32
|
-
[this](const Rect* p) { add_free_rect(*p); });
|
|
30
|
+
std::shared_ptr<const Rect> result(new Rect { best_rect->x, best_rect->y, width, height },
|
|
31
|
+
[this](const Rect* p) { add_free_rect(*p); });
|
|
33
32
|
|
|
34
33
|
// We need to split the remaining rectangle into two. We use the axis with the longer side.
|
|
35
34
|
// (Called "Longer Axis Split Rule", "-LAS" in the paper.)
|
|
@@ -137,7 +136,7 @@ void Gosu::BinPacker::merge_neighbors(int index)
|
|
|
137
136
|
// ┃ ┣━━┻━┫
|
|
138
137
|
// ┗━┻━━━━┛
|
|
139
138
|
// In this case, the texture gets stuck in this fragmented state. We assume that this is not an
|
|
140
|
-
// issue in practice, just like
|
|
139
|
+
// issue in practice, just like memory
|
|
141
140
|
|
|
142
141
|
// Merge any of the other rectangles in the list into the one with the given index if they share
|
|
143
142
|
// any of their four sides.
|
data/src/Bitmap.cpp
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
#include <stdexcept> // for std::invalid_argument
|
|
7
7
|
#include <utility> // for std::move, std::swap
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Gosu::Bitmap::Bitmap(int width, int height, Color c)
|
|
10
|
+
: m_width(width),
|
|
11
|
+
m_height(height)
|
|
10
12
|
{
|
|
11
13
|
if (width < 0 || height < 0) {
|
|
12
14
|
throw std::invalid_argument("Negative Gosu::Bitmap size");
|
|
@@ -16,30 +18,21 @@ static void check_bitmap_size(int width, int height)
|
|
|
16
18
|
if (height != 0 && width > std::numeric_limits<int>::max() / height) {
|
|
17
19
|
throw std::invalid_argument("Gosu::Bitmap size out of bounds");
|
|
18
20
|
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
Gosu::Bitmap::Bitmap(int width, int height, Color c)
|
|
22
|
-
: m_width(width),
|
|
23
|
-
m_height(height)
|
|
24
|
-
{
|
|
25
|
-
check_bitmap_size(width, height);
|
|
26
21
|
|
|
27
22
|
const int size = width * height;
|
|
28
23
|
m_pixels = Buffer(size * sizeof(Color));
|
|
29
24
|
std::fill_n(data(), size, c);
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
Gosu::Bitmap::Bitmap(int width, int height, Buffer&& buffer)
|
|
27
|
+
Gosu::Bitmap::Bitmap(int width, int height, Gosu::Buffer&& buffer)
|
|
33
28
|
: m_width(width),
|
|
34
29
|
m_height(height),
|
|
35
30
|
m_pixels(std::move(buffer))
|
|
36
31
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const int size = width * height;
|
|
40
|
-
if (static_cast<std::size_t>(size) * sizeof(Color) != m_pixels.size()) {
|
|
32
|
+
int pixels = width * height;
|
|
33
|
+
if (static_cast<std::size_t>(pixels) * sizeof(Color) != m_pixels.size()) {
|
|
41
34
|
throw std::length_error("Gosu::Bitmap given Gosu::Buffer of wrong size, expected "
|
|
42
|
-
+ std::to_string(
|
|
35
|
+
+ std::to_string(pixels * sizeof(Color)) + ", given "
|
|
43
36
|
+ std::to_string(m_pixels.size()));
|
|
44
37
|
}
|
|
45
38
|
}
|
|
@@ -89,7 +82,7 @@ void Gosu::Bitmap::insert(const Bitmap& source, int x, int y, Rect source_rect)
|
|
|
89
82
|
source_rect.clip_to(Rect::covering(source), &x, &y);
|
|
90
83
|
|
|
91
84
|
// Set up the target area and make sure that it does not exceed this image.
|
|
92
|
-
Rect target_rect =
|
|
85
|
+
Rect target_rect { .x = x, .y = y, .width = source_rect.width, .height = source_rect.height };
|
|
93
86
|
// If we need to move the target_rect origin, then also move the source_rect origin.
|
|
94
87
|
target_rect.clip_to(Rect::covering(*this), &source_rect.x, &source_rect.y);
|
|
95
88
|
|
|
@@ -116,7 +109,7 @@ void Gosu::Bitmap::insert(const Bitmap& source, int x, int y, Rect source_rect)
|
|
|
116
109
|
}
|
|
117
110
|
}
|
|
118
111
|
|
|
119
|
-
bool Gosu::Bitmap::operator==(const Bitmap& other) const
|
|
112
|
+
bool Gosu::Bitmap::operator==(const Gosu::Bitmap& other) const
|
|
120
113
|
{
|
|
121
114
|
int pixels = width() * height();
|
|
122
115
|
return pixels == other.width() * other.height()
|
data/src/Buffer.cpp
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
#include <filesystem>
|
|
9
9
|
#include <fstream>
|
|
10
10
|
#else
|
|
11
|
-
#include <
|
|
11
|
+
#include <SDL.h>
|
|
12
12
|
#endif
|
|
13
13
|
|
|
14
14
|
Gosu::Buffer::Buffer(void* buffer, std::size_t size, std::function<void(void*)> deleter)
|
|
@@ -135,12 +135,21 @@ Gosu::Buffer Gosu::load_file(const std::string& filename)
|
|
|
135
135
|
|
|
136
136
|
void Gosu::save_file(const Buffer& buffer, const std::string& filename)
|
|
137
137
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
struct RWopsDeleter
|
|
139
|
+
{
|
|
140
|
+
void operator()(SDL_RWops* p) const
|
|
141
|
+
{
|
|
142
|
+
// SDL_RWclose will crash if given nullptr.
|
|
143
|
+
if (p) {
|
|
144
|
+
SDL_RWclose(p);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
std::unique_ptr<SDL_RWops, RWopsDeleter> rwops(SDL_RWFromFile(filename.c_str(), "w"));
|
|
149
|
+
if (rwops == nullptr) {
|
|
141
150
|
throw std::runtime_error("Could not open '" + filename + "', error: " + SDL_GetError());
|
|
142
151
|
}
|
|
143
|
-
std::size_t written =
|
|
152
|
+
std::size_t written = SDL_RWwrite(rwops.get(), buffer.data(), buffer.size(), 1);
|
|
144
153
|
// GCOV_EXCL_START: It is hard to set up a file where opening works but writing doesn't.
|
|
145
154
|
if (written == 0) {
|
|
146
155
|
throw std::runtime_error("Could not write to '" + filename + "', error: " + SDL_GetError());
|
data/src/ClipRectStack.hpp
CHANGED
|
@@ -1,24 +1,90 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <Gosu/Utility.hpp>
|
|
4
3
|
#include "GraphicsImpl.hpp"
|
|
5
|
-
#include <
|
|
6
|
-
#include <optional>
|
|
7
|
-
#include <stdexcept>
|
|
4
|
+
#include <cassert>
|
|
8
5
|
#include <vector>
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
class Gosu::ClipRectStack
|
|
11
8
|
{
|
|
12
|
-
|
|
9
|
+
std::vector<ClipRect> stack;
|
|
10
|
+
bool has_effective_rect; // is effective_rect valid?
|
|
11
|
+
ClipRect effective_rect;
|
|
12
|
+
|
|
13
|
+
void update_effective_rect()
|
|
13
14
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
// Nothing to do, no clipping in place.
|
|
16
|
+
if (stack.empty()) {
|
|
17
|
+
has_effective_rect = false;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ClipRect result = { 0.0, 0.0, 1e10, 1e10 };
|
|
22
|
+
for (std::size_t i = 0, end = stack.size(); i < end; ++i) {
|
|
23
|
+
const ClipRect& rect = stack[i];
|
|
24
|
+
int result_right = std::min(result.x + result.width, rect.x + rect.width);
|
|
25
|
+
int result_bottom = std::min(result.y + result.height, rect.y + rect.height);
|
|
26
|
+
result.x = std::max(result.x, rect.x);
|
|
27
|
+
result.y = std::max(result.y, rect.y);
|
|
28
|
+
|
|
29
|
+
if (result.x >= result_right || result.y >= result_bottom) {
|
|
30
|
+
// We have clipped the world away!
|
|
31
|
+
has_effective_rect = false;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
result.width = result_right - result.x;
|
|
36
|
+
result.height = result_bottom - result.y;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// On the iPhone, we may have to multiply everything by 2 for Retina displays.
|
|
40
|
+
// TODO: Doesn't this affect Retina Macs as well?
|
|
41
|
+
// TODO: This should be handled by a global transform.
|
|
42
|
+
int fac = clip_rect_base_factor();
|
|
43
|
+
result.x *= fac;
|
|
44
|
+
result.y *= fac;
|
|
45
|
+
result.width *= fac;
|
|
46
|
+
result.height *= fac;
|
|
47
|
+
|
|
48
|
+
// Normal clipping.
|
|
49
|
+
effective_rect = result;
|
|
50
|
+
has_effective_rect = true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
ClipRectStack()
|
|
55
|
+
: has_effective_rect(false)
|
|
56
|
+
{
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void clear()
|
|
60
|
+
{
|
|
61
|
+
stack.clear();
|
|
62
|
+
has_effective_rect = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void begin_clipping(double x, double y, double width, double height)
|
|
66
|
+
{
|
|
67
|
+
ClipRect rect = { x, y, width, height };
|
|
68
|
+
stack.push_back(rect);
|
|
69
|
+
update_effective_rect();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void end_clipping()
|
|
73
|
+
{
|
|
74
|
+
assert (!stack.empty());
|
|
75
|
+
stack.pop_back();
|
|
76
|
+
update_effective_rect();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const ClipRect* maybe_effective_rect() const
|
|
80
|
+
{
|
|
81
|
+
return has_effective_rect ? &effective_rect : 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
bool clipped_world_away() const
|
|
85
|
+
{
|
|
86
|
+
// When we have no effective rect but the stack is not empty, we have clipped
|
|
87
|
+
// the whole world away and don't need to render things.
|
|
88
|
+
return !has_effective_rect && !stack.empty();
|
|
89
|
+
}
|
|
90
|
+
};
|
data/src/Directories.cpp
CHANGED
data/src/DrawOp.hpp
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
#include "TexChunk.hpp"
|
|
6
6
|
#include <Gosu/Color.hpp>
|
|
7
7
|
#include <Gosu/GraphicsBase.hpp>
|
|
8
|
-
#include <algorithm>
|
|
9
8
|
#include <cassert>
|
|
10
9
|
|
|
11
10
|
namespace Gosu
|
|
@@ -16,15 +15,15 @@ namespace Gosu
|
|
|
16
15
|
ZPos z;
|
|
17
16
|
|
|
18
17
|
RenderState render_state;
|
|
19
|
-
// Only
|
|
20
|
-
GLfloat top
|
|
18
|
+
// Only valid if render_state.tex_name != NO_TEXTURE
|
|
19
|
+
GLfloat top, left, bottom, right;
|
|
21
20
|
// Used to keep TexChunk rectangles on shared textures alive until the end of the frame.
|
|
22
21
|
std::shared_ptr<const Rect> rect_handle;
|
|
23
22
|
|
|
24
23
|
// TODO: Merge with Gosu::ArrayVertex.
|
|
25
24
|
struct Vertex
|
|
26
25
|
{
|
|
27
|
-
float x
|
|
26
|
+
float x, y;
|
|
28
27
|
Color c;
|
|
29
28
|
Vertex() {}
|
|
30
29
|
Vertex(float x, float y, Color c) : x(x), y(y), c(c) {}
|
|
@@ -140,17 +139,15 @@ namespace Gosu
|
|
|
140
139
|
// frame anyway.
|
|
141
140
|
ArrayVertex result[4];
|
|
142
141
|
for (int i = 0; i < 4; ++i) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
double x =
|
|
148
|
-
double y =
|
|
142
|
+
result[i].vertices[0] = vertices[i].x;
|
|
143
|
+
result[i].vertices[1] = vertices[i].y;
|
|
144
|
+
result[i].vertices[2] = 0;
|
|
145
|
+
result[i].color = vertices[i].c.abgr();
|
|
146
|
+
double x = result[i].vertices[0];
|
|
147
|
+
double y = result[i].vertices[1];
|
|
149
148
|
render_state.transform->apply(x, y);
|
|
150
149
|
result[i].vertices[0] = static_cast<float>(x);
|
|
151
150
|
result[i].vertices[1] = static_cast<float>(y);
|
|
152
|
-
result[i].vertices[2] = 0;
|
|
153
|
-
result[i].color = vertex.c.abgr();
|
|
154
151
|
}
|
|
155
152
|
RenderState va_render_state = render_state;
|
|
156
153
|
va_render_state.transform = 0;
|
|
@@ -164,11 +161,17 @@ namespace Gosu
|
|
|
164
161
|
result[3].tex_coords[0] = left;
|
|
165
162
|
result[3].tex_coords[1] = bottom;
|
|
166
163
|
|
|
167
|
-
if (vas.empty() || vas.back().render_state
|
|
168
|
-
vas.
|
|
164
|
+
if (vas.empty() || !(vas.back().render_state == va_render_state)) {
|
|
165
|
+
vas.push_back(VertexArray());
|
|
166
|
+
vas.back().render_state = va_render_state;
|
|
169
167
|
}
|
|
170
168
|
|
|
171
169
|
vas.back().vertices.insert(vas.back().vertices.end(), result, result + 4);
|
|
172
170
|
}
|
|
171
|
+
|
|
172
|
+
bool operator<(const DrawOp& other) const
|
|
173
|
+
{
|
|
174
|
+
return z < other.z;
|
|
175
|
+
}
|
|
173
176
|
};
|
|
174
177
|
}
|
data/src/DrawOpQueue.hpp
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
#include <cmath>
|
|
10
10
|
#include <functional>
|
|
11
11
|
#include <map>
|
|
12
|
-
#include <utility>
|
|
13
12
|
#include <vector>
|
|
14
13
|
|
|
15
14
|
class Gosu::DrawOpQueue
|
|
@@ -23,7 +22,7 @@ class Gosu::DrawOpQueue
|
|
|
23
22
|
std::vector<std::function<void ()>> gl_blocks;
|
|
24
23
|
|
|
25
24
|
public:
|
|
26
|
-
|
|
25
|
+
DrawOpQueue(QueueMode mode)
|
|
27
26
|
: queue_mode(mode)
|
|
28
27
|
{
|
|
29
28
|
}
|
|
@@ -35,31 +34,39 @@ public:
|
|
|
35
34
|
|
|
36
35
|
void schedule_draw_op(DrawOp op)
|
|
37
36
|
{
|
|
38
|
-
|
|
37
|
+
if (clip_rect_stack.clipped_world_away()) return;
|
|
38
|
+
|
|
39
|
+
#ifdef GOSU_IS_OPENGLES
|
|
39
40
|
// No triangles, no lines supported
|
|
40
|
-
assert(op.vertices_or_block_index == 4);
|
|
41
|
-
#endif
|
|
41
|
+
assert (op.vertices_or_block_index == 4);
|
|
42
|
+
#endif
|
|
42
43
|
|
|
43
44
|
op.render_state.transform = &transform_stack.current();
|
|
44
|
-
|
|
45
|
+
if (const ClipRect* cr = clip_rect_stack.maybe_effective_rect()) {
|
|
46
|
+
op.render_state.clip_rect = *cr;
|
|
47
|
+
}
|
|
45
48
|
ops.push_back(op);
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
void gl(std::function<void ()> gl_block, ZPos z)
|
|
49
52
|
{
|
|
53
|
+
// TODO: Document this case: Clipped-away GL blocks are *not* being run.
|
|
54
|
+
if (clip_rect_stack.clipped_world_away()) return;
|
|
55
|
+
|
|
50
56
|
int complement_of_block_index = ~(int)gl_blocks.size();
|
|
51
|
-
gl_blocks.push_back(
|
|
57
|
+
gl_blocks.push_back(gl_block);
|
|
52
58
|
|
|
53
59
|
DrawOp op;
|
|
54
60
|
op.vertices_or_block_index = complement_of_block_index;
|
|
55
61
|
op.render_state.transform = &transform_stack.current();
|
|
56
|
-
|
|
62
|
+
if (const ClipRect* cr = clip_rect_stack.maybe_effective_rect()) {
|
|
63
|
+
op.render_state.clip_rect = *cr;
|
|
64
|
+
}
|
|
57
65
|
op.z = z;
|
|
58
66
|
ops.push_back(op);
|
|
59
67
|
}
|
|
60
68
|
|
|
61
|
-
void begin_clipping(double x, double y, double width, double height,
|
|
62
|
-
std::optional<int> viewport_height)
|
|
69
|
+
void begin_clipping(double x, double y, double width, double height, double screen_height)
|
|
63
70
|
{
|
|
64
71
|
if (mode() == QM_RECORD_MACRO) {
|
|
65
72
|
throw std::logic_error("Clipping is not allowed while creating a macro");
|
|
@@ -73,21 +80,21 @@ public:
|
|
|
73
80
|
transform_stack.current().apply(left, top);
|
|
74
81
|
transform_stack.current().apply(right, bottom);
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
83
|
+
double phys_x = std::min(left, right);
|
|
84
|
+
double phys_y = std::min(top, bottom);
|
|
85
|
+
double phys_width = std::abs(left - right);
|
|
86
|
+
double phys_height = std::abs(top - bottom);
|
|
87
|
+
|
|
82
88
|
// Adjust for OpenGL having the wrong idea of where y=0 is.
|
|
83
|
-
|
|
84
|
-
clip_rect.y = *viewport_height - clip_rect.y - clip_rect.height;
|
|
85
|
-
}
|
|
89
|
+
phys_y = screen_height - phys_y - phys_height;
|
|
86
90
|
|
|
87
|
-
clip_rect_stack.
|
|
91
|
+
clip_rect_stack.begin_clipping(phys_x, phys_y, phys_width, phys_height);
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
void end_clipping()
|
|
94
|
+
void end_clipping()
|
|
95
|
+
{
|
|
96
|
+
clip_rect_stack.end_clipping();
|
|
97
|
+
}
|
|
91
98
|
|
|
92
99
|
void set_base_transform(const Transform& base_transform)
|
|
93
100
|
{
|
|
@@ -111,8 +118,7 @@ public:
|
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
// Apply Z-Ordering.
|
|
114
|
-
std::stable_sort(ops.begin(), ops.end()
|
|
115
|
-
[](const DrawOp& lhs, const DrawOp& rhs) { return lhs.z < rhs.z; });
|
|
121
|
+
std::stable_sort(ops.begin(), ops.end());
|
|
116
122
|
|
|
117
123
|
RenderStateManager manager;
|
|
118
124
|
|
|
@@ -138,7 +144,7 @@ public:
|
|
|
138
144
|
assert (block_index >= 0);
|
|
139
145
|
assert (block_index < gl_blocks.size());
|
|
140
146
|
gl_blocks[block_index]();
|
|
141
|
-
manager.
|
|
147
|
+
manager.enforce_after_untrusted_gL();
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
150
|
#endif
|
|
@@ -150,7 +156,7 @@ public:
|
|
|
150
156
|
throw std::logic_error("Custom OpenGL code cannot be recorded as a macro");
|
|
151
157
|
}
|
|
152
158
|
|
|
153
|
-
std::stable_sort(ops.begin(), ops.end()
|
|
159
|
+
std::stable_sort(ops.begin(), ops.end());
|
|
154
160
|
for (const auto& op : ops) {
|
|
155
161
|
op.compile_to(vas);
|
|
156
162
|
}
|
data/src/Font.cpp
CHANGED
|
@@ -79,7 +79,7 @@ struct Gosu::Font::Impl : private Gosu::Noncopyable
|
|
|
79
79
|
std::swap(resized_bitmap, bitmap);
|
|
80
80
|
Gosu::draw_text(bitmap, 0, 0, Color::WHITE, string, name, scaled_height, font_flags);
|
|
81
81
|
}
|
|
82
|
-
const Rect source_rect
|
|
82
|
+
const Rect source_rect { 0, 0, required_width, bitmap.height() };
|
|
83
83
|
|
|
84
84
|
return glyphs[key] = Image(bitmap, source_rect, image_flags);
|
|
85
85
|
}
|
data/src/GosuGLView.cpp
CHANGED
|
@@ -28,6 +28,12 @@ namespace Gosu
|
|
|
28
28
|
{
|
|
29
29
|
// Don't bother unsetting anything.
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
int clip_rect_base_factor()
|
|
33
|
+
{
|
|
34
|
+
static int result = [UIScreen mainScreen].scale;
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
@implementation GosuGLView
|
|
@@ -91,7 +97,7 @@ namespace Gosu
|
|
|
91
97
|
[EAGLContext setCurrentContext:_context];
|
|
92
98
|
[self destroyFramebuffer];
|
|
93
99
|
[self createFramebuffer];
|
|
94
|
-
self.contentScaleFactor =
|
|
100
|
+
self.contentScaleFactor = Gosu::clip_rect_base_factor();
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
- (BOOL)createFramebuffer
|