gosu 1.3.0 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +108 -14
- data/dependencies/SDL/include/SDL_assert.h +81 -50
- data/dependencies/SDL/include/SDL_atomic.h +135 -35
- data/dependencies/SDL/include/SDL_audio.h +960 -355
- data/dependencies/SDL/include/SDL_bits.h +11 -6
- data/dependencies/SDL/include/SDL_blendmode.h +91 -14
- data/dependencies/SDL/include/SDL_clipboard.h +30 -7
- data/dependencies/SDL/include/SDL_config.h +277 -27
- data/dependencies/SDL/include/SDL_config_android.h +13 -38
- data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
- data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
- data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
- data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
- data/dependencies/SDL/include/SDL_config_psp.h +16 -37
- data/dependencies/SDL/include/SDL_config_windows.h +28 -91
- data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
- data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
- data/dependencies/SDL/include/SDL_copying.h +1 -1
- data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
- data/dependencies/SDL/include/SDL_egl.h +906 -280
- data/dependencies/SDL/include/SDL_endian.h +101 -47
- data/dependencies/SDL/include/SDL_error.h +70 -19
- data/dependencies/SDL/include/SDL_events.h +387 -79
- data/dependencies/SDL/include/SDL_filesystem.h +73 -64
- data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
- data/dependencies/SDL/include/SDL_gesture.h +36 -6
- data/dependencies/SDL/include/SDL_haptic.h +304 -210
- data/dependencies/SDL/include/SDL_hidapi.h +451 -0
- data/dependencies/SDL/include/SDL_hints.h +1286 -897
- data/dependencies/SDL/include/SDL_joystick.h +577 -130
- data/dependencies/SDL/include/SDL_keyboard.h +162 -63
- data/dependencies/SDL/include/SDL_keycode.h +7 -5
- data/dependencies/SDL/include/SDL_loadso.h +42 -8
- data/dependencies/SDL/include/SDL_locale.h +34 -32
- data/dependencies/SDL/include/SDL_log.h +212 -19
- data/dependencies/SDL/include/SDL_main.h +72 -17
- data/dependencies/SDL/include/SDL_messagebox.h +70 -23
- data/dependencies/SDL/include/SDL_metal.h +27 -32
- data/dependencies/SDL/include/SDL_misc.h +19 -15
- data/dependencies/SDL/include/SDL_mouse.h +262 -110
- data/dependencies/SDL/include/SDL_mutex.h +286 -66
- data/dependencies/SDL/include/SDL_name.h +1 -1
- data/dependencies/SDL/include/SDL_opengl.h +1 -1
- data/dependencies/SDL/include/SDL_opengles.h +1 -1
- data/dependencies/SDL/include/SDL_opengles2.h +2 -2
- data/dependencies/SDL/include/SDL_pixels.h +199 -34
- data/dependencies/SDL/include/SDL_platform.h +39 -2
- data/dependencies/SDL/include/SDL_power.h +23 -10
- data/dependencies/SDL/include/SDL_quit.h +1 -1
- data/dependencies/SDL/include/SDL_rect.h +78 -28
- data/dependencies/SDL/include/SDL_render.h +1204 -472
- data/dependencies/SDL/include/SDL_revision.h +2 -2
- data/dependencies/SDL/include/SDL_rwops.h +605 -33
- data/dependencies/SDL/include/SDL_scancode.h +1 -1
- data/dependencies/SDL/include/SDL_sensor.h +76 -42
- data/dependencies/SDL/include/SDL_shape.h +38 -27
- data/dependencies/SDL/include/SDL_stdinc.h +96 -24
- data/dependencies/SDL/include/SDL_surface.h +571 -139
- data/dependencies/SDL/include/SDL_system.h +339 -101
- data/dependencies/SDL/include/SDL_syswm.h +50 -20
- data/dependencies/SDL/include/SDL_test.h +1 -1
- data/dependencies/SDL/include/SDL_test_assert.h +2 -2
- data/dependencies/SDL/include/SDL_test_common.h +23 -6
- data/dependencies/SDL/include/SDL_test_compare.h +1 -1
- data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
- data/dependencies/SDL/include/SDL_test_font.h +3 -3
- data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
- data/dependencies/SDL/include/SDL_test_harness.h +6 -6
- data/dependencies/SDL/include/SDL_test_images.h +1 -1
- data/dependencies/SDL/include/SDL_test_log.h +1 -1
- data/dependencies/SDL/include/SDL_test_md5.h +1 -1
- data/dependencies/SDL/include/SDL_test_memory.h +1 -1
- data/dependencies/SDL/include/SDL_test_random.h +2 -2
- data/dependencies/SDL/include/SDL_thread.h +226 -128
- data/dependencies/SDL/include/SDL_timer.h +129 -22
- data/dependencies/SDL/include/SDL_touch.h +48 -8
- data/dependencies/SDL/include/SDL_types.h +1 -1
- data/dependencies/SDL/include/SDL_version.h +72 -46
- data/dependencies/SDL/include/SDL_video.h +1266 -460
- data/dependencies/SDL/include/SDL_vulkan.h +100 -161
- data/dependencies/SDL/include/begin_code.h +22 -1
- data/dependencies/SDL/include/close_code.h +1 -1
- 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 +104 -70
- data/dependencies/SDL_sound/SDL_sound.h +6 -6
- data/dependencies/SDL_sound/SDL_sound_aiff.c +32 -32
- data/dependencies/SDL_sound/SDL_sound_au.c +14 -14
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +6 -7
- data/dependencies/SDL_sound/SDL_sound_flac.c +28 -30
- data/dependencies/SDL_sound/SDL_sound_internal.h +21 -14
- data/dependencies/SDL_sound/SDL_sound_modplug.c +26 -28
- data/dependencies/SDL_sound/SDL_sound_mp3.c +20 -36
- data/dependencies/SDL_sound/SDL_sound_raw.c +15 -16
- data/dependencies/SDL_sound/SDL_sound_shn.c +11 -10
- data/dependencies/SDL_sound/SDL_sound_voc.c +20 -18
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +11 -9
- data/dependencies/SDL_sound/SDL_sound_wav.c +49 -43
- data/dependencies/SDL_sound/dr_flac.h +10925 -4466
- data/dependencies/SDL_sound/dr_mp3.h +2802 -844
- data/dependencies/SDL_sound/libmodplug/fastmix.c +63 -64
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
- data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
- data/dependencies/SDL_sound/libmodplug/load_amf.c +12 -7
- data/dependencies/SDL_sound/libmodplug/load_ams.c +103 -44
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
- data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
- data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +61 -61
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +94 -58
- data/dependencies/SDL_sound/libmodplug/load_med.c +20 -11
- data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +50 -19
- data/dependencies/SDL_sound/libmodplug/load_okt.c +59 -28
- data/dependencies/SDL_sound/libmodplug/load_psm.c +104 -79
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
- data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
- data/dependencies/SDL_sound/libmodplug/load_ult.c +4 -3
- data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
- data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
- data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
- data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +32 -19
- data/dependencies/SDL_sound/libmodplug/sndfile.c +76 -160
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
- data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
- data/dependencies/SDL_sound/stb_vorbis.h +504 -329
- data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
- data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
- data/dependencies/mojoAL/mojoal.c +4848 -0
- data/dependencies/stb/stb_image.h +208 -73
- data/dependencies/stb/stb_image_write.h +57 -23
- data/dependencies/stb/stb_truetype.h +345 -279
- data/dependencies/utf8proc/utf8proc.c +37 -18
- data/dependencies/utf8proc/utf8proc.h +17 -5
- data/dependencies/utf8proc/utf8proc_data.h +12012 -10089
- data/ext/gosu/extconf.rb +29 -30
- data/include/Gosu/Audio.hpp +70 -85
- data/include/Gosu/Buttons.hpp +103 -103
- data/include/Gosu/Color.hpp +19 -11
- data/include/Gosu/Directories.hpp +31 -24
- data/include/Gosu/Font.hpp +42 -44
- data/include/Gosu/Gosu.hpp +5 -8
- data/include/Gosu/Graphics.hpp +58 -71
- data/include/Gosu/GraphicsBase.hpp +26 -33
- data/include/Gosu/IO.hpp +0 -3
- data/include/Gosu/Image.hpp +56 -62
- data/include/Gosu/ImageData.hpp +23 -27
- data/include/Gosu/Inspection.hpp +1 -4
- data/include/Gosu/Math.hpp +0 -3
- data/include/Gosu/TextInput.hpp +34 -40
- data/include/Gosu/Timing.hpp +2 -8
- data/include/Gosu/Version.hpp +2 -2
- data/include/Gosu/Window.hpp +71 -70
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/compat.rb +24 -37
- data/lib/gosu.rb +2 -2
- data/lib64/SDL2.dll +0 -0
- data/src/Audio.cpp +88 -86
- data/src/AudioFile.hpp +6 -6
- data/src/AudioFileAudioToolbox.cpp +1 -1
- data/src/AudioFileSDLSound.cpp +1 -1
- data/src/AudioImpl.cpp +0 -7
- data/src/AudioImpl.hpp +6 -8
- data/src/BitmapIO.cpp +23 -22
- data/src/BlockAllocator.cpp +2 -1
- data/src/Channel.cpp +22 -20
- data/src/Color.cpp +12 -9
- data/src/DirectoriesApple.cpp +25 -24
- data/src/DirectoriesUnix.cpp +14 -12
- data/src/DirectoriesWin.cpp +26 -30
- data/src/EmptyImageData.hpp +15 -17
- data/src/FileUnix.cpp +1 -1
- data/src/FileWin.cpp +1 -1
- data/src/Font.cpp +59 -54
- data/src/Graphics.cpp +135 -143
- data/src/Image.cpp +41 -47
- data/src/Input.cpp +1 -1
- data/src/InputUIKit.cpp +1 -1
- data/src/LargeImageData.cpp +108 -101
- data/src/LargeImageData.hpp +17 -15
- data/src/Log.hpp +6 -6
- data/src/Macro.cpp +35 -37
- data/src/Macro.hpp +11 -11
- data/src/Math.cpp +8 -1
- data/src/Resolution.cpp +12 -7
- data/src/RubyGosu.cxx +11 -39
- data/src/TexChunk.cpp +50 -41
- data/src/TexChunk.hpp +22 -22
- data/src/Text.cpp +37 -37
- data/src/TextBuilder.cpp +60 -57
- data/src/TextBuilder.hpp +20 -20
- data/src/TextInput.cpp +127 -135
- data/src/TimingApple.cpp +1 -7
- data/src/TimingUnix.cpp +0 -6
- data/src/TimingWin.cpp +0 -6
- data/src/TrueTypeFont.cpp +107 -107
- data/src/TrueTypeFont.hpp +39 -38
- data/src/TrueTypeFontApple.cpp +19 -22
- data/src/TrueTypeFontUnix.cpp +21 -26
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Window.cpp +97 -87
- data/src/WindowUIKit.cpp +46 -49
- metadata +7 -17
- data/dependencies/SDL/include/SDL_config_os2.h +0 -188
- data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
- data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
- data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
- data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
- data/dependencies/al_soft/AL/alext.h +0 -585
- data/dependencies/al_soft/AL/efx-creative.h +0 -3
- data/dependencies/al_soft/AL/efx-presets.h +0 -402
- data/dependencies/al_soft/AL/efx.h +0 -762
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/lib/OpenAL32.dll +0 -0
- data/lib64/OpenAL32.dll +0 -0
data/src/Macro.cpp
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#include "Macro.hpp"
|
2
|
-
#include "DrawOpQueue.hpp"
|
3
2
|
#include <Gosu/Image.hpp>
|
3
|
+
#include <Gosu/Utility.hpp>
|
4
|
+
#include "DrawOpQueue.hpp"
|
4
5
|
#include <stdexcept>
|
5
|
-
using namespace std;
|
6
6
|
|
7
|
-
struct Gosu::Macro::Impl
|
7
|
+
struct Gosu::Macro::Impl : Gosu::Noncopyable
|
8
8
|
{
|
9
9
|
VertexArrays vertex_arrays;
|
10
10
|
int width, height;
|
@@ -13,8 +13,8 @@ struct Gosu::Macro::Impl
|
|
13
13
|
// (a11 a12) (x1) = (b1)
|
14
14
|
// (a21 a22) (x2) = (b2)
|
15
15
|
// x1, x2 are output parameters. Returns false if the matrix is singular.
|
16
|
-
static bool solve_2x2(double a11, double a12, double a21, double a22,
|
17
|
-
double& x1, double& x2)
|
16
|
+
static bool solve_2x2(double a11, double a12, double a21, double a22, //
|
17
|
+
double b1, double b2, double& x1, double& x2)
|
18
18
|
{
|
19
19
|
const double det = a11 * a22 - a21 * a12;
|
20
20
|
if (det == 0) return false;
|
@@ -23,8 +23,8 @@ struct Gosu::Macro::Impl
|
|
23
23
|
return true;
|
24
24
|
}
|
25
25
|
|
26
|
-
Transform find_transform_for_target(double x1, double y1, double x2, double y2,
|
27
|
-
|
26
|
+
Transform find_transform_for_target(double x1, double y1, double x2, double y2, //
|
27
|
+
double x3, double y3, double x4, double y4) const
|
28
28
|
{
|
29
29
|
// Transformation logic follows a discussion on the ImageMagick mailing
|
30
30
|
// list (on which ImageMagick's perspective_transform.pl is based).
|
@@ -100,37 +100,35 @@ struct Gosu::Macro::Impl
|
|
100
100
|
// 0, 0, 0, 0, 0, 0, 0, 1 | qy
|
101
101
|
|
102
102
|
double c[8];
|
103
|
-
c[0] = (x2 - x1) / width
|
103
|
+
c[0] = (x2 - x1) / width + qx * x2;
|
104
104
|
c[1] = (x3 - x1) / height + qy * x3;
|
105
105
|
c[2] = x1;
|
106
|
-
c[3] = (y2 - y1) / width
|
106
|
+
c[3] = (y2 - y1) / width + qx * y2;
|
107
107
|
c[4] = (y3 - y1) / height + qy * y3;
|
108
108
|
c[5] = y1;
|
109
109
|
c[6] = qx;
|
110
110
|
c[7] = qy;
|
111
111
|
|
112
|
-
Transform result = {{
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
c[2], c[5], 0, 1
|
117
|
-
}};
|
112
|
+
Transform result = {{c[0], c[3], 0, c[6], //
|
113
|
+
c[1], c[4], 0, c[7], //
|
114
|
+
0, 0, 1, 0, //
|
115
|
+
c[2], c[5], 0, 1}};
|
118
116
|
return result;
|
119
117
|
}
|
120
118
|
|
121
|
-
void draw_vertex_arrays(double x1, double y1, double x2, double y2,
|
122
|
-
|
119
|
+
void draw_vertex_arrays(double x1, double y1, double x2, double y2, //
|
120
|
+
double x3, double y3, double x4, double y4) const
|
123
121
|
{
|
124
122
|
// TODO: Macros should not be split up just because they have different transforms.
|
125
123
|
// They should be premultiplied and have the same transform by definition. Then the
|
126
124
|
// transformation only has to be performed once.
|
127
|
-
|
128
|
-
|
125
|
+
|
126
|
+
#ifndef GOSU_IS_OPENGLES
|
129
127
|
glEnable(GL_BLEND);
|
130
128
|
glMatrixMode(GL_MODELVIEW);
|
131
|
-
|
129
|
+
|
132
130
|
Transform transform = find_transform_for_target(x1, y1, x2, y2, x3, y3, x4, y4);
|
133
|
-
|
131
|
+
|
134
132
|
for (const auto& vertex_array : vertex_arrays) {
|
135
133
|
glPushMatrix();
|
136
134
|
vertex_array.render_state.apply();
|
@@ -139,7 +137,7 @@ struct Gosu::Macro::Impl
|
|
139
137
|
glDrawArrays(GL_QUADS, 0, (GLsizei) vertex_array.vertices.size());
|
140
138
|
glPopMatrix();
|
141
139
|
}
|
142
|
-
|
140
|
+
#endif
|
143
141
|
}
|
144
142
|
};
|
145
143
|
|
@@ -161,15 +159,16 @@ int Gosu::Macro::height() const
|
|
161
159
|
return pimpl->height;
|
162
160
|
}
|
163
161
|
|
164
|
-
void Gosu::Macro::draw(double x1, double y1, Color c1, double x2, double y2, Color c2,
|
165
|
-
|
162
|
+
void Gosu::Macro::draw(double x1, double y1, Color c1, double x2, double y2, Color c2, //
|
163
|
+
double x3, double y3, Color c3, double x4, double y4, Color c4, //
|
164
|
+
ZPos z, BlendMode mode) const
|
166
165
|
{
|
167
166
|
if (c1 != Color::WHITE || c2 != Color::WHITE || c3 != Color::WHITE || c4 != Color::WHITE) {
|
168
|
-
throw invalid_argument
|
167
|
+
throw std::invalid_argument{"Macros cannot be tinted with colors"};
|
169
168
|
}
|
170
|
-
|
169
|
+
|
171
170
|
normalize_coordinates(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
|
172
|
-
|
171
|
+
|
173
172
|
Gosu::Graphics::gl(z, [=] { pimpl->draw_vertex_arrays(x1, y1, x2, y2, x3, y3, x4, y4); });
|
174
173
|
}
|
175
174
|
|
@@ -180,21 +179,20 @@ const Gosu::GLTexInfo* Gosu::Macro::gl_tex_info() const
|
|
180
179
|
|
181
180
|
Gosu::Bitmap Gosu::Macro::to_bitmap() const
|
182
181
|
{
|
183
|
-
|
184
|
-
draw(0,
|
185
|
-
pimpl->width,
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
}).data().to_bitmap();
|
182
|
+
const auto render_this = [this] {
|
183
|
+
draw(0, 0, Color::WHITE, pimpl->width, 0, Color::WHITE, 0, pimpl->height, Color::WHITE,
|
184
|
+
pimpl->width, pimpl->height, Color::WHITE, 0, BM_DEFAULT);
|
185
|
+
};
|
186
|
+
|
187
|
+
return Gosu::Graphics::render(pimpl->width, pimpl->height, render_this).data().to_bitmap();
|
190
188
|
}
|
191
189
|
|
192
|
-
unique_ptr<Gosu::ImageData> Gosu::Macro::subimage(int x, int y, int width, int height) const
|
190
|
+
std::unique_ptr<Gosu::ImageData> Gosu::Macro::subimage(int x, int y, int width, int height) const
|
193
191
|
{
|
194
|
-
return unique_ptr<ImageData>
|
192
|
+
return std::unique_ptr<ImageData>{};
|
195
193
|
}
|
196
194
|
|
197
195
|
void Gosu::Macro::insert(const Bitmap& bitmap, int x, int y)
|
198
196
|
{
|
199
|
-
throw logic_error
|
197
|
+
throw std::logic_error{"Gosu::Macro cannot be updated with a Gosu::Bitmap yet"};
|
200
198
|
}
|
data/src/Macro.hpp
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
-
#include "GraphicsImpl.hpp"
|
4
3
|
#include <Gosu/Fwd.hpp>
|
5
4
|
#include <Gosu/ImageData.hpp>
|
5
|
+
#include "GraphicsImpl.hpp"
|
6
6
|
#include <memory>
|
7
7
|
|
8
8
|
class Gosu::Macro : public Gosu::ImageData
|
9
9
|
{
|
10
10
|
struct Impl;
|
11
11
|
std::shared_ptr<Impl> pimpl;
|
12
|
-
|
12
|
+
|
13
13
|
public:
|
14
14
|
Macro(DrawOpQueue& queue, int width, int height);
|
15
|
-
|
15
|
+
|
16
16
|
int width() const override;
|
17
17
|
int height() const override;
|
18
|
-
|
19
|
-
void draw(double x1, double y1, Color c1, double x2, double y2, Color c2,
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
|
19
|
+
void draw(double x1, double y1, Color c1, double x2, double y2, Color c2, //
|
20
|
+
double x3, double y3, Color c3, double x4, double y4, Color c4, //
|
21
|
+
ZPos z, BlendMode mode) const override;
|
22
|
+
|
23
23
|
const Gosu::GLTexInfo* gl_tex_info() const override;
|
24
|
-
|
24
|
+
|
25
25
|
Gosu::Bitmap to_bitmap() const override;
|
26
|
-
|
26
|
+
|
27
27
|
std::unique_ptr<ImageData> subimage(int x, int y, int width, int height) const override;
|
28
|
-
|
28
|
+
|
29
29
|
void insert(const Bitmap& bitmap, int x, int y) override;
|
30
30
|
};
|
data/src/Math.cpp
CHANGED
@@ -23,7 +23,14 @@ double Gosu::angle(double from_x, double from_y, double to_x, double to_y, doubl
|
|
23
23
|
double dist_x = to_x - from_x;
|
24
24
|
double dist_y = to_y - from_y;
|
25
25
|
|
26
|
-
if (dist_x == 0
|
26
|
+
if (dist_x == 0) {
|
27
|
+
// Special-case these values so that for a result of 0°/360° we never
|
28
|
+
// run into subtle precision errors by converting from radian to angles.
|
29
|
+
if (dist_y < 0) return 0;
|
30
|
+
if (dist_y > 0) return 180;
|
31
|
+
// dist_y == 0
|
32
|
+
return 0;
|
33
|
+
}
|
27
34
|
|
28
35
|
return normalize_angle(radians_to_gosu(atan2(dist_y, dist_x)));
|
29
36
|
}
|
data/src/Resolution.cpp
CHANGED
@@ -7,8 +7,9 @@
|
|
7
7
|
|
8
8
|
static SDL_DisplayMode display_mode(Gosu::Window* window)
|
9
9
|
{
|
10
|
-
static struct VideoSubsystem
|
11
|
-
|
10
|
+
static struct VideoSubsystem
|
11
|
+
{
|
12
|
+
VideoSubsystem() { SDL_InitSubSystem(SDL_INIT_VIDEO); };
|
12
13
|
~VideoSubsystem() { SDL_QuitSubSystem(SDL_INIT_VIDEO); };
|
13
14
|
} subsystem;
|
14
15
|
|
@@ -40,7 +41,8 @@ static SDL_Rect max_window_size(Gosu::Window* window)
|
|
40
41
|
style = NSWindowStyleMaskBorderless;
|
41
42
|
}
|
42
43
|
else {
|
43
|
-
style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
44
|
+
style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
45
|
+
NSWindowStyleMaskMiniaturizable;
|
44
46
|
}
|
45
47
|
if (window && window->resizable()) {
|
46
48
|
style |= NSWindowStyleMaskResizable;
|
@@ -61,10 +63,10 @@ static SDL_Rect max_window_size(Gosu::Window* window)
|
|
61
63
|
|
62
64
|
// TODO: Remove this implementation and remove ifdef for GOSU_IS_X once WIN_GetWindowBordersSize is patched
|
63
65
|
#ifdef GOSU_IS_WIN
|
64
|
-
#include <windows.h>
|
65
66
|
#include <SDL_syswm.h>
|
66
67
|
#include <dwmapi.h>
|
67
|
-
#
|
68
|
+
#include <windows.h>
|
69
|
+
#pragma comment(lib, "Dwmapi.lib")
|
68
70
|
|
69
71
|
static SDL_Rect max_window_size(Gosu::Window* window)
|
70
72
|
{
|
@@ -72,7 +74,8 @@ static SDL_Rect max_window_size(Gosu::Window* window)
|
|
72
74
|
// until it's patched to ignore the window drop shadow (window border is 1px but with drop shadow it's reported as 8px)
|
73
75
|
// REF: https://github.com/libsdl-org/SDL/issues/3835
|
74
76
|
|
75
|
-
static struct VideoSubsystem
|
77
|
+
static struct VideoSubsystem
|
78
|
+
{
|
76
79
|
VideoSubsystem() { SDL_InitSubSystem(SDL_INIT_VIDEO); };
|
77
80
|
~VideoSubsystem() { SDL_QuitSubSystem(SDL_INIT_VIDEO); };
|
78
81
|
} subsystem;
|
@@ -136,7 +139,8 @@ static SDL_Rect max_window_size(Gosu::Window* window)
|
|
136
139
|
#ifdef GOSU_IS_X
|
137
140
|
static SDL_Rect max_window_size(Gosu::Window* window)
|
138
141
|
{
|
139
|
-
static struct VideoSubsystem
|
142
|
+
static struct VideoSubsystem
|
143
|
+
{
|
140
144
|
VideoSubsystem() { SDL_InitSubSystem(SDL_INIT_VIDEO); };
|
141
145
|
~VideoSubsystem() { SDL_QuitSubSystem(SDL_INIT_VIDEO); };
|
142
146
|
} subsystem;
|
@@ -163,4 +167,5 @@ int Gosu::available_height(Window* window)
|
|
163
167
|
{
|
164
168
|
return max_window_size(window).h;
|
165
169
|
}
|
170
|
+
|
166
171
|
#endif
|
data/src/RubyGosu.cxx
CHANGED
@@ -2806,6 +2806,7 @@ SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_0(Gosu::Window &window,std::string co
|
|
2806
2806
|
SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_1(int height,VALUE options=0){
|
2807
2807
|
std::string font_name = Gosu::default_font_name();
|
2808
2808
|
unsigned font_flags = 0;
|
2809
|
+
unsigned image_flags = 0;
|
2809
2810
|
|
2810
2811
|
if (options) {
|
2811
2812
|
Check_Type(options, T_HASH);
|
@@ -2831,6 +2832,9 @@ SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_1(int height,VALUE options=0){
|
|
2831
2832
|
else if (!strcmp(key_string, "underline")) {
|
2832
2833
|
if (RTEST(value)) font_flags |= Gosu::FF_UNDERLINE;
|
2833
2834
|
}
|
2835
|
+
else if (!strcmp(key_string, "retro")) {
|
2836
|
+
if (RTEST(value)) image_flags |= Gosu::IF_RETRO;
|
2837
|
+
}
|
2834
2838
|
else {
|
2835
2839
|
static bool issued_warning = false;
|
2836
2840
|
if (!issued_warning) {
|
@@ -2841,7 +2845,7 @@ SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_1(int height,VALUE options=0){
|
|
2841
2845
|
}
|
2842
2846
|
}
|
2843
2847
|
|
2844
|
-
return new Gosu::Font(height, font_name, font_flags);
|
2848
|
+
return new Gosu::Font(height, font_name, font_flags, image_flags);
|
2845
2849
|
}
|
2846
2850
|
SWIGINTERN double Gosu_Font_text_width(Gosu::Font *self,std::string const &markup,double scale_x=1.0){
|
2847
2851
|
static bool issued_warning = false;
|
@@ -5258,37 +5262,6 @@ fail:
|
|
5258
5262
|
}
|
5259
5263
|
|
5260
5264
|
|
5261
|
-
SWIGINTERN VALUE
|
5262
|
-
_wrap_Font_flags(int argc, VALUE *argv, VALUE self) {
|
5263
|
-
Gosu::Font *arg1 = (Gosu::Font *) 0 ;
|
5264
|
-
void *argp1 = 0 ;
|
5265
|
-
int res1 = 0 ;
|
5266
|
-
unsigned int result;
|
5267
|
-
VALUE vresult = Qnil;
|
5268
|
-
|
5269
|
-
if ((argc < 0) || (argc > 0)) {
|
5270
|
-
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
5271
|
-
}
|
5272
|
-
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Font, 0 | 0 );
|
5273
|
-
if (!SWIG_IsOK(res1)) {
|
5274
|
-
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Font const *","flags", 1, self ));
|
5275
|
-
}
|
5276
|
-
arg1 = reinterpret_cast< Gosu::Font * >(argp1);
|
5277
|
-
{
|
5278
|
-
try {
|
5279
|
-
result = (unsigned int)((Gosu::Font const *)arg1)->flags();
|
5280
|
-
}
|
5281
|
-
catch (const std::exception& e) {
|
5282
|
-
SWIG_exception(SWIG_RuntimeError, e.what());
|
5283
|
-
}
|
5284
|
-
}
|
5285
|
-
vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
|
5286
|
-
return vresult;
|
5287
|
-
fail:
|
5288
|
-
return Qnil;
|
5289
|
-
}
|
5290
|
-
|
5291
|
-
|
5292
5265
|
SWIGINTERN VALUE
|
5293
5266
|
_wrap_Font_draw_text(int argc, VALUE *argv, VALUE self) {
|
5294
5267
|
Gosu::Font *arg1 = (Gosu::Font *) 0 ;
|
@@ -8217,8 +8190,8 @@ fail:
|
|
8217
8190
|
SWIGINTERN VALUE
|
8218
8191
|
_wrap_Sample_play(int argc, VALUE *argv, VALUE self) {
|
8219
8192
|
Gosu::Sample *arg1 = (Gosu::Sample *) 0 ;
|
8220
|
-
double arg2 = (double) 1 ;
|
8221
|
-
double arg3 = (double) 1 ;
|
8193
|
+
double arg2 = (double) 1.0 ;
|
8194
|
+
double arg3 = (double) 1.0 ;
|
8222
8195
|
bool arg4 = (bool) false ;
|
8223
8196
|
void *argp1 = 0 ;
|
8224
8197
|
int res1 = 0 ;
|
@@ -8279,8 +8252,8 @@ SWIGINTERN VALUE
|
|
8279
8252
|
_wrap_Sample_play_pan(int argc, VALUE *argv, VALUE self) {
|
8280
8253
|
Gosu::Sample *arg1 = (Gosu::Sample *) 0 ;
|
8281
8254
|
double arg2 ;
|
8282
|
-
double arg3 = (double) 1 ;
|
8283
|
-
double arg4 = (double) 1 ;
|
8255
|
+
double arg3 = (double) 1.0 ;
|
8256
|
+
double arg4 = (double) 1.0 ;
|
8284
8257
|
bool arg5 = (bool) false ;
|
8285
8258
|
void *argp1 = 0 ;
|
8286
8259
|
int res1 = 0 ;
|
@@ -12485,8 +12458,8 @@ SWIGEXPORT void Init_gosu(void) {
|
|
12485
12458
|
rb_define_const(mGosu, "VERSION", SWIG_From_std_string(static_cast< std::string >(Gosu::VERSION)));
|
12486
12459
|
rb_define_const(mGosu, "LICENSES", SWIG_From_std_string(static_cast< std::string >(Gosu::LICENSES)));
|
12487
12460
|
rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(1)));
|
12488
|
-
rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(
|
12489
|
-
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(
|
12461
|
+
rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(4)));
|
12462
|
+
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(3)));
|
12490
12463
|
rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
|
12491
12464
|
rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
|
12492
12465
|
rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
|
@@ -12544,7 +12517,6 @@ SWIGEXPORT void Init_gosu(void) {
|
|
12544
12517
|
rb_define_method(SwigClassFont.klass, "initialize", VALUEFUNC(_wrap_new_Font), -1);
|
12545
12518
|
rb_define_method(SwigClassFont.klass, "name", VALUEFUNC(_wrap_Font_name), -1);
|
12546
12519
|
rb_define_method(SwigClassFont.klass, "height", VALUEFUNC(_wrap_Font_height), -1);
|
12547
|
-
rb_define_method(SwigClassFont.klass, "flags", VALUEFUNC(_wrap_Font_flags), -1);
|
12548
12520
|
rb_define_method(SwigClassFont.klass, "draw_text", VALUEFUNC(_wrap_Font_draw_text), -1);
|
12549
12521
|
rb_define_method(SwigClassFont.klass, "draw_markup", VALUEFUNC(_wrap_Font_draw_markup), -1);
|
12550
12522
|
rb_define_method(SwigClassFont.klass, "draw_text_rel", VALUEFUNC(_wrap_Font_draw_text_rel), -1);
|
data/src/TexChunk.cpp
CHANGED
@@ -1,57 +1,66 @@
|
|
1
1
|
#include "TexChunk.hpp"
|
2
|
-
#include "DrawOpQueue.hpp"
|
3
|
-
#include "Texture.hpp"
|
4
2
|
#include <Gosu/Bitmap.hpp>
|
5
3
|
#include <Gosu/Graphics.hpp>
|
4
|
+
#include "DrawOpQueue.hpp"
|
5
|
+
#include "Texture.hpp"
|
6
6
|
#include <stdexcept>
|
7
7
|
|
8
|
-
using namespace std;
|
9
|
-
|
10
8
|
void Gosu::TexChunk::set_tex_info()
|
11
9
|
{
|
12
|
-
double width =
|
10
|
+
double width = m_texture->width(), height = m_texture->height();
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
m_info.tex_name = m_texture->tex_name();
|
13
|
+
m_info.left = m_x / width;
|
14
|
+
m_info.top = m_y / height;
|
15
|
+
m_info.right = (m_x + m_w) / width;
|
16
|
+
m_info.bottom = (m_y + m_h) / height;
|
19
17
|
}
|
20
18
|
|
21
|
-
Gosu::TexChunk::TexChunk(shared_ptr<Texture> texture, int x, int y, int w, int h, int padding)
|
22
|
-
:
|
19
|
+
Gosu::TexChunk::TexChunk(std::shared_ptr<Texture> texture, int x, int y, int w, int h, int padding)
|
20
|
+
: m_texture{move(texture)},
|
21
|
+
m_x{x},
|
22
|
+
m_y{y},
|
23
|
+
m_w{w},
|
24
|
+
m_h{h},
|
25
|
+
m_padding{padding}
|
23
26
|
{
|
24
27
|
set_tex_info();
|
25
28
|
}
|
26
29
|
|
27
30
|
Gosu::TexChunk::TexChunk(const TexChunk& parent, int x, int y, int w, int h)
|
28
|
-
:
|
31
|
+
: m_texture{parent.m_texture},
|
32
|
+
m_x{parent.m_x + x},
|
33
|
+
m_y{parent.m_y + y},
|
34
|
+
m_w{w},
|
35
|
+
m_h{h},
|
36
|
+
m_padding{0}
|
29
37
|
{
|
30
|
-
if (x < 0 || y < 0 || x + w > parent.
|
31
|
-
throw invalid_argument
|
38
|
+
if (x < 0 || y < 0 || x + w > parent.m_w || y + h > parent.m_h) {
|
39
|
+
throw std::invalid_argument{"subimage bounds exceed those of its parent"};
|
32
40
|
}
|
33
41
|
if (w <= 0 || h <= 0) {
|
34
|
-
throw invalid_argument
|
42
|
+
throw std::invalid_argument{"cannot create empty image"};
|
35
43
|
}
|
36
|
-
|
44
|
+
|
37
45
|
set_tex_info();
|
38
|
-
|
46
|
+
m_texture->block(m_x, m_y, m_w, m_h);
|
39
47
|
}
|
40
48
|
|
41
49
|
Gosu::TexChunk::~TexChunk()
|
42
50
|
{
|
43
|
-
|
51
|
+
m_texture->free(m_x - m_padding, m_y - m_padding, m_w + 2 * m_padding, m_h + 2 * m_padding);
|
44
52
|
}
|
45
53
|
|
46
|
-
void Gosu::TexChunk::draw(double x1, double y1, Color c1, double x2, double y2, Color c2,
|
47
|
-
|
54
|
+
void Gosu::TexChunk::draw(double x1, double y1, Color c1, double x2, double y2, Color c2, //
|
55
|
+
double x3, double y3, Color c3, double x4, double y4, Color c4, //
|
56
|
+
ZPos z, BlendMode mode) const
|
48
57
|
{
|
49
58
|
DrawOp op;
|
50
|
-
op.render_state.texture =
|
59
|
+
op.render_state.texture = m_texture;
|
51
60
|
op.render_state.mode = mode;
|
52
|
-
|
61
|
+
|
53
62
|
normalize_coordinates(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
|
54
|
-
|
63
|
+
|
55
64
|
op.vertices_or_block_index = 4;
|
56
65
|
op.vertices[0] = DrawOp::Vertex(x1, y1, c1);
|
57
66
|
op.vertices[1] = DrawOp::Vertex(x2, y2, c2);
|
@@ -63,34 +72,34 @@ void Gosu::TexChunk::draw(double x1, double y1, Color c1, double x2, double y2,
|
|
63
72
|
op.vertices[3] = DrawOp::Vertex(x3, y3, c3);
|
64
73
|
op.vertices[2] = DrawOp::Vertex(x4, y4, c4);
|
65
74
|
#endif
|
66
|
-
op.left =
|
67
|
-
op.top =
|
68
|
-
op.right =
|
69
|
-
op.bottom =
|
70
|
-
|
75
|
+
op.left = m_info.left;
|
76
|
+
op.top = m_info.top;
|
77
|
+
op.right = m_info.right;
|
78
|
+
op.bottom = m_info.bottom;
|
79
|
+
|
71
80
|
op.z = z;
|
72
81
|
Graphics::schedule_draw_op(op);
|
73
82
|
}
|
74
83
|
|
75
|
-
unique_ptr<Gosu::ImageData> Gosu::TexChunk::subimage(int x, int y, int width, int height) const
|
84
|
+
std::unique_ptr<Gosu::ImageData> Gosu::TexChunk::subimage(int x, int y, int width, int height) const
|
76
85
|
{
|
77
|
-
return unique_ptr<Gosu::ImageData>(new TexChunk(*this, x, y, width, height));
|
86
|
+
return std::unique_ptr<Gosu::ImageData>(new TexChunk(*this, x, y, width, height));
|
78
87
|
}
|
79
88
|
|
80
89
|
Gosu::Bitmap Gosu::TexChunk::to_bitmap() const
|
81
90
|
{
|
82
|
-
return
|
91
|
+
return m_texture->to_bitmap(m_x, m_y, m_w, m_h);
|
83
92
|
}
|
84
93
|
|
85
94
|
void Gosu::TexChunk::insert(const Bitmap& original_bitmap, int x, int y)
|
86
95
|
{
|
87
96
|
Bitmap clipped_bitmap;
|
88
97
|
const Bitmap* bitmap = &original_bitmap;
|
89
|
-
|
98
|
+
|
90
99
|
// If inserting the bitmap at the given position exceeds the boundaries of the space allocated
|
91
100
|
// for this image on the texture, we need to clip the bitmap and insert the clipped version
|
92
101
|
// instead.
|
93
|
-
if (x < 0 || y < 0 || x + original_bitmap.width() >
|
102
|
+
if (x < 0 || y < 0 || x + original_bitmap.width() > m_w || y + original_bitmap.height() > m_h) {
|
94
103
|
// How many pixels to remove at the top and left sides.
|
95
104
|
int clip_left = 0, clip_top = 0;
|
96
105
|
// How large the clipped version needs to be.
|
@@ -109,22 +118,22 @@ void Gosu::TexChunk::insert(const Bitmap& original_bitmap, int x, int y)
|
|
109
118
|
y = 0;
|
110
119
|
}
|
111
120
|
// Clip away pixels on the right side, if necessary.
|
112
|
-
if (x + clipped_width >
|
113
|
-
clipped_width = (
|
121
|
+
if (x + clipped_width > m_w) {
|
122
|
+
clipped_width = (m_w - x);
|
114
123
|
}
|
115
124
|
// Clip away pixels on the bottom, if necessary.
|
116
|
-
if (y + clipped_height >
|
117
|
-
clipped_height = (
|
125
|
+
if (y + clipped_height > m_h) {
|
126
|
+
clipped_height = (m_h - y);
|
118
127
|
}
|
119
128
|
|
120
129
|
if (clipped_width <= 0 || clipped_height <= 0) return;
|
121
|
-
|
130
|
+
|
122
131
|
clipped_bitmap.resize(clipped_width, clipped_height);
|
123
132
|
clipped_bitmap.insert(-clip_left, -clip_top, original_bitmap);
|
124
133
|
bitmap = &clipped_bitmap;
|
125
134
|
}
|
126
|
-
|
135
|
+
|
127
136
|
glBindTexture(GL_TEXTURE_2D, tex_name());
|
128
|
-
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
137
|
+
glTexSubImage2D(GL_TEXTURE_2D, 0, m_x + x, m_y + y, bitmap->width(), bitmap->height(),
|
129
138
|
Color::GL_FORMAT, GL_UNSIGNED_BYTE, bitmap->data());
|
130
139
|
}
|
data/src/TexChunk.hpp
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
-
#include "GraphicsImpl.hpp"
|
4
3
|
#include <Gosu/Fwd.hpp>
|
5
4
|
#include <Gosu/ImageData.hpp>
|
5
|
+
#include "GraphicsImpl.hpp"
|
6
6
|
#include <memory>
|
7
7
|
#include <stdexcept>
|
8
8
|
|
9
9
|
class Gosu::TexChunk : public Gosu::ImageData
|
10
10
|
{
|
11
|
-
std::shared_ptr<Texture>
|
12
|
-
int
|
13
|
-
|
14
|
-
GLTexInfo
|
15
|
-
|
11
|
+
std::shared_ptr<Texture> m_texture;
|
12
|
+
int m_x, m_y, m_w, m_h, m_padding;
|
13
|
+
|
14
|
+
GLTexInfo m_info;
|
15
|
+
|
16
16
|
void set_tex_info();
|
17
|
-
|
17
|
+
|
18
18
|
public:
|
19
19
|
TexChunk(std::shared_ptr<Texture> texture, int x, int y, int w, int h, int padding);
|
20
20
|
TexChunk(const TexChunk& parent, int x, int y, int w, int h);
|
21
21
|
~TexChunk() override;
|
22
22
|
|
23
|
-
int width() const override
|
24
|
-
int height() const override { return
|
25
|
-
|
26
|
-
GLuint tex_name() const { return
|
27
|
-
|
28
|
-
void draw(double x1, double y1, Color c1,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
const GLTexInfo* gl_tex_info() const override { return &
|
35
|
-
|
23
|
+
int width() const override { return m_w; }
|
24
|
+
int height() const override { return m_h; }
|
25
|
+
|
26
|
+
GLuint tex_name() const { return m_info.tex_name; }
|
27
|
+
|
28
|
+
void draw(double x1, double y1, Color c1, //
|
29
|
+
double x2, double y2, Color c2, //
|
30
|
+
double x3, double y3, Color c3, //
|
31
|
+
double x4, double y4, Color c4, //
|
32
|
+
ZPos z, BlendMode mode) const override;
|
33
|
+
|
34
|
+
const GLTexInfo* gl_tex_info() const override { return &m_info; }
|
35
|
+
|
36
36
|
std::unique_ptr<ImageData> subimage(int x, int y, int width, int height) const override;
|
37
|
-
|
37
|
+
|
38
38
|
Gosu::Bitmap to_bitmap() const override;
|
39
|
-
|
39
|
+
|
40
40
|
void insert(const Bitmap& bitmap, int x, int y) override;
|
41
41
|
};
|