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.
- checksums.yaml +4 -4
- data/COPYING +2 -1
- data/dependencies/SDL/include/SDL_atomic.h +2 -3
- data/dependencies/SDL/include/SDL_audio.h +7 -7
- data/dependencies/SDL/include/SDL_blendmode.h +1 -1
- data/dependencies/SDL/include/SDL_endian.h +3 -3
- data/dependencies/SDL/include/SDL_gamecontroller.h +4 -4
- data/dependencies/SDL/include/SDL_hints.h +72 -28
- data/dependencies/SDL/include/SDL_joystick.h +8 -5
- data/dependencies/SDL/include/SDL_keycode.h +1 -1
- data/dependencies/SDL/include/SDL_main.h +7 -0
- data/dependencies/SDL/include/SDL_mouse.h +6 -7
- data/dependencies/SDL/include/SDL_mutex.h +79 -5
- data/dependencies/SDL/include/SDL_opengl_glext.h +5 -1
- data/dependencies/SDL/include/SDL_power.h +7 -8
- data/dependencies/SDL/include/SDL_render.h +5 -0
- data/dependencies/SDL/include/SDL_revision.h +2 -2
- data/dependencies/SDL/include/SDL_sensor.h +1 -1
- data/dependencies/SDL/include/SDL_stdinc.h +19 -11
- data/dependencies/SDL/include/SDL_thread.h +2 -2
- data/dependencies/SDL/include/SDL_version.h +2 -2
- data/dependencies/SDL/include/SDL_video.h +30 -2
- data/dependencies/SDL/include/begin_code.h +7 -7
- data/dependencies/SDL/include/close_code.h +2 -2
- 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.h +1 -1
- data/dependencies/SDL_sound/dr_flac.h +48 -23
- data/dependencies/SDL_sound/dr_mp3.h +34 -14
- data/dependencies/SDL_sound/stb_vorbis.h +3 -2
- data/dependencies/mojoAL/mojoal.c +1 -1
- data/ext/{gosu → gosu-ffi}/extconf.rb +34 -33
- data/ext/gosu-ffi/gosu-ffi.def +464 -0
- data/ffi/Gosu.cpp +307 -0
- data/ffi/Gosu.h +84 -0
- data/ffi/Gosu_Channel.cpp +62 -0
- data/ffi/Gosu_Channel.h +17 -0
- data/ffi/Gosu_Color.cpp +132 -0
- data/ffi/Gosu_Color.h +31 -0
- data/ffi/Gosu_Constants.cpp +334 -0
- data/ffi/Gosu_FFI.h +34 -0
- data/ffi/Gosu_FFI_internal.h +161 -0
- data/ffi/Gosu_Font.cpp +92 -0
- data/ffi/Gosu_Font.h +32 -0
- data/ffi/Gosu_Image.cpp +206 -0
- data/ffi/Gosu_Image.h +60 -0
- data/ffi/Gosu_Sample.cpp +29 -0
- data/ffi/Gosu_Sample.h +14 -0
- data/ffi/Gosu_Song.cpp +69 -0
- data/ffi/Gosu_Song.h +18 -0
- data/ffi/Gosu_TextInput.cpp +94 -0
- data/ffi/Gosu_TextInput.h +25 -0
- data/ffi/Gosu_Window.cpp +314 -0
- data/ffi/Gosu_Window.h +78 -0
- data/include/Gosu/Audio.hpp +6 -11
- data/include/Gosu/Bitmap.hpp +38 -53
- data/include/Gosu/Buffer.hpp +54 -0
- data/include/Gosu/Color.hpp +27 -35
- data/include/Gosu/Directories.hpp +25 -28
- data/include/Gosu/Drawable.hpp +58 -0
- data/include/Gosu/Font.hpp +6 -5
- data/include/Gosu/Fwd.hpp +4 -6
- data/include/Gosu/Gosu.hpp +5 -5
- data/include/Gosu/Graphics.hpp +51 -61
- data/include/Gosu/GraphicsBase.hpp +1 -11
- data/include/Gosu/Image.hpp +11 -14
- data/include/Gosu/Math.hpp +50 -72
- data/include/Gosu/Transform.hpp +32 -0
- data/include/Gosu/Utility.hpp +51 -1
- data/include/Gosu/Version.hpp +3 -3
- data/include/Gosu/Window.hpp +15 -9
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/channel.rb +49 -0
- data/lib/gosu/color.rb +150 -0
- data/lib/gosu/compat.rb +29 -8
- data/lib/gosu/constants.rb +386 -0
- data/lib/gosu/ffi.rb +258 -0
- data/lib/gosu/font.rb +56 -0
- data/lib/gosu/gl_tex_info.rb +33 -0
- data/lib/gosu/gosu.rb +210 -0
- data/lib/gosu/image.rb +141 -0
- data/lib/gosu/numeric.rb +17 -0
- data/lib/gosu/preview.rb +6 -6
- data/lib/gosu/sample.rb +24 -0
- data/lib/gosu/song.rb +56 -0
- data/lib/gosu/text_input.rb +69 -0
- data/lib/gosu/window.rb +228 -0
- data/lib/gosu.rb +29 -8
- data/lib64/SDL2.dll +0 -0
- data/rdoc/gosu.rb +0 -2
- data/src/Audio.cpp +12 -12
- data/src/AudioFile.hpp +5 -4
- data/src/AudioFileAudioToolbox.cpp +8 -8
- data/src/AudioFileSDLSound.cpp +7 -10
- data/src/BinPacker.cpp +187 -0
- data/src/BinPacker.hpp +55 -0
- data/src/Bitmap.cpp +166 -144
- data/src/BitmapIO.cpp +60 -86
- data/src/Buffer.cpp +159 -0
- data/src/Color.cpp +75 -80
- data/src/Directories.cpp +47 -0
- data/src/DirectoriesUIKit.cpp +50 -0
- data/src/DrawOp.hpp +9 -4
- data/src/DrawOpQueue.hpp +2 -2
- data/src/Drawable.cpp +95 -0
- data/src/EmptyDrawable.hpp +38 -0
- data/src/FPS.cpp +31 -0
- data/src/Font.cpp +104 -74
- data/src/GosuGLView.cpp +14 -6
- data/src/GosuViewController.cpp +2 -10
- data/src/Graphics.cpp +60 -126
- data/src/GraphicsImpl.hpp +17 -47
- data/src/Image.cpp +41 -35
- data/src/Input.cpp +7 -8
- data/src/Macro.cpp +6 -6
- data/src/Macro.hpp +4 -4
- data/src/MarkupParser.cpp +5 -5
- data/src/Math.cpp +35 -22
- data/src/OffScreenTarget.cpp +53 -49
- data/src/OffScreenTarget.hpp +13 -11
- data/src/OpenGLContext.cpp +117 -0
- data/src/OpenGLContext.hpp +41 -0
- data/src/RenderState.hpp +21 -19
- data/src/Resolution.cpp +23 -21
- data/src/TexChunk.cpp +35 -80
- data/src/TexChunk.hpp +44 -35
- data/src/Text.cpp +1 -1
- data/src/TextBuilder.cpp +35 -21
- data/src/TextBuilder.hpp +6 -9
- data/src/Texture.cpp +62 -80
- data/src/Texture.hpp +25 -23
- data/src/TiledDrawable.cpp +150 -0
- data/src/TiledDrawable.hpp +47 -0
- data/src/TimingApple.cpp +1 -1
- data/src/Transform.cpp +45 -50
- data/src/TransformStack.hpp +16 -16
- data/src/TrueTypeFont.cpp +59 -51
- data/src/TrueTypeFont.hpp +6 -7
- data/src/TrueTypeFontApple.cpp +28 -19
- data/src/TrueTypeFontUnix.cpp +27 -23
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Utility.cpp +84 -21
- data/src/UtilityWin.cpp +45 -0
- data/src/Window.cpp +92 -142
- data/src/WindowUIKit.cpp +14 -14
- metadata +72 -31
- data/include/Gosu/IO.hpp +0 -254
- data/include/Gosu/ImageData.hpp +0 -53
- data/include/Gosu/Inspection.hpp +0 -7
- data/lib/gosu/patches.rb +0 -66
- data/lib/gosu/run.rb +0 -20
- data/lib/gosu/swig_patches.rb +0 -110
- data/src/BlockAllocator.cpp +0 -131
- data/src/BlockAllocator.hpp +0 -32
- data/src/DirectoriesApple.cpp +0 -69
- data/src/DirectoriesUnix.cpp +0 -46
- data/src/DirectoriesWin.cpp +0 -65
- data/src/EmptyImageData.hpp +0 -52
- data/src/FileUnix.cpp +0 -99
- data/src/FileWin.cpp +0 -88
- data/src/IO.cpp +0 -60
- data/src/Iconv.hpp +0 -51
- data/src/Inspection.cpp +0 -27
- data/src/LargeImageData.cpp +0 -215
- data/src/LargeImageData.hpp +0 -39
- data/src/Log.hpp +0 -19
- data/src/RubyGosu.cxx +0 -13100
- data/src/RubyGosu.h +0 -49
- data/src/WinUtility.cpp +0 -61
- data/src/WinUtility.hpp +0 -27
data/src/Font.cpp
CHANGED
@@ -1,74 +1,94 @@
|
|
1
1
|
#include <Gosu/Font.hpp>
|
2
|
-
#include <Gosu/Graphics.hpp>
|
3
2
|
#include <Gosu/Image.hpp>
|
4
|
-
#include <Gosu/Math.hpp>
|
5
3
|
#include <Gosu/Text.hpp>
|
6
4
|
#include <Gosu/Utility.hpp>
|
7
5
|
#include "GraphicsImpl.hpp"
|
8
6
|
#include "MarkupParser.hpp"
|
9
|
-
#include <
|
10
|
-
#include <
|
7
|
+
#include <cmath> // for std::ceil
|
8
|
+
#include <mutex>
|
11
9
|
#include <stdexcept>
|
12
|
-
#include <
|
13
|
-
|
14
|
-
static const int FONT_RENDER_SCALE = 2;
|
10
|
+
#include <unordered_map>
|
15
11
|
|
16
12
|
struct Gosu::Font::Impl : private Gosu::Noncopyable
|
17
13
|
{
|
18
|
-
|
19
|
-
|
20
|
-
unsigned base_flags;
|
21
|
-
unsigned image_flags;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
std::array<std::map<utf8proc_int32_t, Image>, FF_COMBINATIONS> other_glyphs;
|
29
|
-
|
30
|
-
Image& image(char32_t codepoint, unsigned font_flags)
|
14
|
+
const int height;
|
15
|
+
const std::string name;
|
16
|
+
const unsigned base_flags;
|
17
|
+
const unsigned image_flags;
|
18
|
+
|
19
|
+
Impl(int height, std::string_view name, unsigned base_flags, unsigned image_flags)
|
20
|
+
: height(height),
|
21
|
+
name(name),
|
22
|
+
base_flags(base_flags),
|
23
|
+
image_flags(image_flags)
|
31
24
|
{
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
}
|
26
|
+
|
27
|
+
struct GlyphKey
|
28
|
+
{
|
29
|
+
char32_t codepoint;
|
30
|
+
unsigned font_flags;
|
31
|
+
bool operator==(const GlyphKey&) const = default;
|
32
|
+
};
|
33
|
+
|
34
|
+
struct GlyphKeyHasher
|
35
|
+
{
|
36
|
+
std::size_t operator()(const GlyphKey& key) const noexcept
|
37
|
+
{
|
38
|
+
// The highest legal Unicode code point is 0x10FFFF, which is a 21-bit value, so we do
|
39
|
+
// not have to worry about overwriting any of the higher bits.
|
40
|
+
// This only works if unordered_map uses prime table sizes (which it should):
|
41
|
+
// https://www.reddit.com/r/cpp_questions/comments/us3nyb/comment/i937ulb/
|
42
|
+
return key.codepoint | (key.font_flags << 24);
|
35
43
|
}
|
36
|
-
|
37
|
-
|
44
|
+
};
|
45
|
+
|
46
|
+
// Font implements copying through its shared_ptr, not by making a true copy. However, Fonts are
|
47
|
+
// not immutable: Glyphs are created and cashed on demand, and set_image() enables modifications
|
48
|
+
// to the shared data of a font. Having multiple references to the same object, but not being
|
49
|
+
// able to use it from two threads, seems counterintuitive, so introduce a mutex here, even
|
50
|
+
// though most Gosu games/programs will never really require it.
|
51
|
+
// (Could be a shared_mutex, but doesn't seem to be worth the trouble.)
|
52
|
+
std::mutex glyphs_mutex;
|
53
|
+
std::unordered_map<GlyphKey, Image, GlyphKeyHasher> glyphs;
|
54
|
+
|
55
|
+
const Image& image(char32_t codepoint, unsigned font_flags)
|
56
|
+
{
|
57
|
+
const GlyphKey key { codepoint, font_flags };
|
58
|
+
if (const auto iterator = glyphs.find(key); iterator != glyphs.end()) {
|
59
|
+
return iterator->second;
|
38
60
|
}
|
39
61
|
|
40
62
|
// If this codepoint has not been rendered before, do it now.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
auto required_width = ceil(Gosu::draw_text(bitmap, 0, 0, Color::WHITE, string, name,
|
50
|
-
scaled_height, font_flags));
|
51
|
-
if (required_width > bitmap.width()) {
|
52
|
-
// If the character was wider than high, we need to render it again.
|
53
|
-
Bitmap(required_width, scaled_height).swap(bitmap);
|
54
|
-
Gosu::draw_text(bitmap, 0, 0, Color::WHITE, string, name, scaled_height,
|
55
|
-
font_flags);
|
56
|
-
}
|
63
|
+
// By default, render each glyph at 200% its size so that we have some wiggle room for
|
64
|
+
// changing the font size dynamically without it appearing too blurry.
|
65
|
+
auto scaled_height = height * 2;
|
66
|
+
// Optimization: Don't render higher-resolution versions if we use
|
67
|
+
// next neighbor interpolation anyway.
|
68
|
+
if (image_flags & IF_RETRO) {
|
69
|
+
scaled_height = height;
|
70
|
+
}
|
57
71
|
|
58
|
-
|
72
|
+
std::u32string string(1, codepoint);
|
73
|
+
Bitmap bitmap(scaled_height, scaled_height);
|
74
|
+
const int required_width = static_cast<int>(std::ceil(
|
75
|
+
Gosu::draw_text(bitmap, 0, 0, Color::WHITE, string, name, scaled_height, font_flags)));
|
76
|
+
if (required_width > bitmap.width()) {
|
77
|
+
// If the character was wider than high, we need to render it again.
|
78
|
+
Bitmap resized_bitmap(required_width, scaled_height);
|
79
|
+
std::swap(resized_bitmap, bitmap);
|
80
|
+
Gosu::draw_text(bitmap, 0, 0, Color::WHITE, string, name, scaled_height, font_flags);
|
59
81
|
}
|
82
|
+
const Rect source_rect { 0, 0, required_width, bitmap.height() };
|
60
83
|
|
61
|
-
return
|
84
|
+
return glyphs[key] = Image(bitmap, source_rect, image_flags);
|
62
85
|
}
|
63
86
|
};
|
64
87
|
|
65
|
-
Gosu::Font::Font(int font_height,
|
66
|
-
|
88
|
+
Gosu::Font::Font(int font_height, std::string_view font_name, unsigned font_flags,
|
89
|
+
unsigned image_flags)
|
90
|
+
: m_impl(new Impl(font_height, font_name, font_flags, image_flags))
|
67
91
|
{
|
68
|
-
m_impl->name = font_name;
|
69
|
-
m_impl->height = font_height;
|
70
|
-
m_impl->base_flags = font_flags;
|
71
|
-
m_impl->image_flags = image_flags;
|
72
92
|
}
|
73
93
|
|
74
94
|
const std::string& Gosu::Font::name() const
|
@@ -98,15 +118,17 @@ double Gosu::Font::text_width(const std::string& text) const
|
|
98
118
|
|
99
119
|
double Gosu::Font::markup_width(const std::string& markup) const
|
100
120
|
{
|
121
|
+
const std::unique_lock lock(m_impl->glyphs_mutex);
|
122
|
+
|
101
123
|
double width = 0;
|
102
124
|
|
103
125
|
// Split the text into lines (split_words = false) because Font doesn't implement word-wrapping.
|
104
|
-
MarkupParser parser(m_impl->base_flags, false, [&](std::vector<FormattedString
|
126
|
+
MarkupParser parser(m_impl->base_flags, false, [&](const std::vector<FormattedString>& line) {
|
105
127
|
double line_width = 0;
|
106
|
-
for (auto& part : line) {
|
107
|
-
for (auto codepoint : part.text) {
|
108
|
-
auto& image = m_impl->image(codepoint, part.flags);
|
109
|
-
double image_scale = 1.0 * height() / image.height();
|
128
|
+
for (const auto& part : line) {
|
129
|
+
for (const auto codepoint : part.text) {
|
130
|
+
const auto& image = m_impl->image(codepoint, part.flags);
|
131
|
+
double image_scale = image.height() ? 1.0 * height() / image.height() : 1.0;
|
110
132
|
line_width += image_scale * image.width();
|
111
133
|
}
|
112
134
|
}
|
@@ -126,15 +148,17 @@ void Gosu::Font::draw_text(const std::string& text, double x, double y, ZPos z,
|
|
126
148
|
void Gosu::Font::draw_markup(const std::string& markup, double x, double y, ZPos z, //
|
127
149
|
double scale_x, double scale_y, Color c, BlendMode mode) const
|
128
150
|
{
|
151
|
+
const std::unique_lock lock(m_impl->glyphs_mutex);
|
152
|
+
|
129
153
|
double current_y = y;
|
130
154
|
|
131
155
|
// Split the text into lines (split_words = false) because Font doesn't implement word-wrapping.
|
132
|
-
MarkupParser parser(m_impl->base_flags, false, [&](std::vector<FormattedString
|
156
|
+
MarkupParser parser(m_impl->base_flags, false, [&](const std::vector<FormattedString>& line) {
|
133
157
|
double current_x = x;
|
134
|
-
for (auto& part : line) {
|
135
|
-
for (auto codepoint : part.text) {
|
136
|
-
auto& image = m_impl->image(codepoint, part.flags);
|
137
|
-
double image_scale = 1.0 * height() / image.height();
|
158
|
+
for (const auto& part : line) {
|
159
|
+
for (const auto codepoint : part.text) {
|
160
|
+
const auto& image = m_impl->image(codepoint, part.flags);
|
161
|
+
double image_scale = image.height() ? 1.0 * height() / image.height() : 1.0;
|
138
162
|
image.draw(current_x, current_y, z, image_scale * scale_x, image_scale * scale_y,
|
139
163
|
multiply(c, part.color), mode);
|
140
164
|
current_x += image_scale * scale_x * image.width();
|
@@ -145,12 +169,16 @@ void Gosu::Font::draw_markup(const std::string& markup, double x, double y, ZPos
|
|
145
169
|
parser.parse(markup);
|
146
170
|
}
|
147
171
|
|
148
|
-
void Gosu::Font::draw_text_rel(const std::string& text, double x, double y, ZPos z,
|
172
|
+
void Gosu::Font::draw_text_rel(const std::string& text, double x, double y, ZPos z, //
|
149
173
|
double rel_x, double rel_y, double scale_x, double scale_y, //
|
150
174
|
Color c, BlendMode mode) const
|
151
175
|
{
|
152
|
-
if (rel_x
|
153
|
-
|
176
|
+
if (rel_x != 0) {
|
177
|
+
x -= text_width(text) * scale_x * rel_x;
|
178
|
+
}
|
179
|
+
if (rel_y != 0) {
|
180
|
+
y -= height() * scale_y * rel_y;
|
181
|
+
}
|
154
182
|
|
155
183
|
draw_text(text, x, y, z, scale_x, scale_y, c, mode);
|
156
184
|
}
|
@@ -159,28 +187,30 @@ void Gosu::Font::draw_markup_rel(const std::string& markup, double x, double y,
|
|
159
187
|
double rel_x, double rel_y, double scale_x, double scale_y,
|
160
188
|
Color c, BlendMode mode) const
|
161
189
|
{
|
162
|
-
if (rel_x
|
163
|
-
|
190
|
+
if (rel_x != 0) {
|
191
|
+
x -= markup_width(markup) * scale_x * rel_x;
|
192
|
+
}
|
193
|
+
if (rel_y != 0) {
|
194
|
+
y -= height() * scale_y * rel_y;
|
195
|
+
}
|
164
196
|
|
165
197
|
draw_markup(markup, x, y, z, scale_x, scale_y, c, mode);
|
166
198
|
}
|
167
199
|
|
168
|
-
void Gosu::Font::set_image(std::
|
200
|
+
void Gosu::Font::set_image(std::string_view codepoint, unsigned font_flags,
|
201
|
+
const Gosu::Image& image)
|
169
202
|
{
|
170
|
-
|
203
|
+
const std::u32string utc4 = utf8_to_composed_utc4(codepoint);
|
171
204
|
if (utc4.length() != 1) {
|
172
|
-
throw std::invalid_argument
|
205
|
+
throw std::invalid_argument("Could not compose '" + std::string(codepoint)
|
206
|
+
+ "' into single codepoint");
|
173
207
|
}
|
174
208
|
|
175
|
-
|
176
|
-
|
177
|
-
}
|
178
|
-
else {
|
179
|
-
m_impl->other_glyphs[font_flags][utc4[0]] = image;
|
180
|
-
}
|
209
|
+
const std::unique_lock lock(m_impl->glyphs_mutex);
|
210
|
+
m_impl->glyphs.insert_or_assign({ .codepoint = utc4[0], .font_flags = font_flags }, image);
|
181
211
|
}
|
182
212
|
|
183
|
-
void Gosu::Font::set_image(std::
|
213
|
+
void Gosu::Font::set_image(std::string_view codepoint, const Gosu::Image& image)
|
184
214
|
{
|
185
215
|
for (unsigned font_flags = 0; font_flags < FF_COMBINATIONS; ++font_flags) {
|
186
216
|
set_image(codepoint, font_flags, image);
|
data/src/GosuGLView.cpp
CHANGED
@@ -1,25 +1,33 @@
|
|
1
1
|
#include <Gosu/Platform.hpp>
|
2
2
|
#if defined(GOSU_IS_IPHONE)
|
3
3
|
|
4
|
-
#import "GosuGLView.hpp"
|
5
4
|
#import <Gosu/Input.hpp>
|
6
5
|
#import <Gosu/TextInput.hpp>
|
7
|
-
|
6
|
+
#import "GosuGLView.hpp"
|
7
|
+
#import "GraphicsImpl.hpp"
|
8
|
+
#import "OpenGLContext.hpp"
|
8
9
|
#import <OpenGLES/EAGL.h>
|
9
10
|
#import <OpenGLES/EAGLDrawable.h>
|
10
|
-
#import <OpenGLES/ES1/gl.h>
|
11
|
-
#import <OpenGLES/ES1/glext.h>
|
12
11
|
#import <QuartzCore/QuartzCore.h>
|
13
12
|
|
14
|
-
|
15
13
|
static EAGLContext __weak* globalContext;
|
16
14
|
|
17
15
|
namespace Gosu
|
18
16
|
{
|
19
|
-
|
17
|
+
OpenGLContext::OpenGLContext(bool)
|
20
18
|
{
|
19
|
+
// Gosu does not support multithreading on iOS.
|
20
|
+
if (![NSThread isMainThread]) {
|
21
|
+
throw std::logic_error("Multi-threaded OpenGL access is not supported on iOS");
|
22
|
+
}
|
23
|
+
|
21
24
|
[EAGLContext setCurrentContext:globalContext];
|
22
25
|
}
|
26
|
+
|
27
|
+
OpenGLContext::~OpenGLContext()
|
28
|
+
{
|
29
|
+
// Don't bother unsetting anything.
|
30
|
+
}
|
23
31
|
|
24
32
|
int clip_rect_base_factor()
|
25
33
|
{
|
data/src/GosuViewController.cpp
CHANGED
@@ -10,14 +10,6 @@
|
|
10
10
|
#import <AudioToolbox/AudioSession.h>
|
11
11
|
#import <OpenAL/alc.h>
|
12
12
|
|
13
|
-
namespace Gosu
|
14
|
-
{
|
15
|
-
namespace FPS
|
16
|
-
{
|
17
|
-
void register_frame();
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
13
|
static void handle_audio_interruption(void* unused, UInt32 inInterruptionState)
|
22
14
|
{
|
23
15
|
if (inInterruptionState == kAudioSessionBeginInterruption) {
|
@@ -180,9 +172,9 @@ static void handle_audio_interruption(void* unused, UInt32 inInterruptionState)
|
|
180
172
|
|
181
173
|
if (window.needs_redraw()) {
|
182
174
|
[(GosuGLView*)self.view redrawGL:^{
|
183
|
-
window.
|
175
|
+
window.viewport().frame([&window] {
|
184
176
|
window.draw();
|
185
|
-
Gosu::
|
177
|
+
Gosu::register_frame();
|
186
178
|
});
|
187
179
|
}];
|
188
180
|
}
|