gosu 0.14.6.pre1 → 1.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/COPYING +1 -1
- data/dependencies/SDL/include/SDL.h +138 -0
- data/dependencies/SDL/include/SDL_assert.h +293 -0
- data/dependencies/SDL/include/SDL_atomic.h +295 -0
- data/dependencies/SDL/include/SDL_audio.h +859 -0
- data/dependencies/SDL/include/SDL_bits.h +121 -0
- data/dependencies/SDL/include/SDL_blendmode.h +123 -0
- data/dependencies/SDL/include/SDL_clipboard.h +71 -0
- data/dependencies/SDL/include/SDL_config.h +55 -0
- data/dependencies/SDL/include/SDL_config_android.h +182 -0
- data/dependencies/SDL/include/SDL_config_iphoneos.h +207 -0
- data/dependencies/SDL/include/SDL_config_macosx.h +266 -0
- data/dependencies/SDL/include/SDL_config_minimal.h +85 -0
- data/dependencies/SDL/include/SDL_config_os2.h +188 -0
- data/dependencies/SDL/include/SDL_config_pandora.h +135 -0
- data/dependencies/SDL/include/SDL_config_psp.h +165 -0
- data/dependencies/SDL/include/SDL_config_windows.h +288 -0
- data/dependencies/SDL/include/SDL_config_winrt.h +243 -0
- data/dependencies/SDL/include/SDL_config_wiz.h +149 -0
- data/dependencies/SDL/include/SDL_copying.h +20 -0
- data/dependencies/SDL/include/SDL_cpuinfo.h +299 -0
- data/dependencies/SDL/include/SDL_egl.h +1676 -0
- data/dependencies/SDL/include/SDL_endian.h +263 -0
- data/dependencies/SDL/include/SDL_error.h +112 -0
- data/dependencies/SDL/include/SDL_events.h +827 -0
- data/dependencies/SDL/include/SDL_filesystem.h +136 -0
- data/dependencies/SDL/include/SDL_gamecontroller.h +541 -0
- data/dependencies/SDL/include/SDL_gesture.h +87 -0
- data/dependencies/SDL/include/SDL_haptic.h +1247 -0
- data/dependencies/SDL/include/SDL_hints.h +1578 -0
- data/dependencies/SDL/include/SDL_joystick.h +499 -0
- data/dependencies/SDL/include/SDL_keyboard.h +217 -0
- data/dependencies/SDL/include/SDL_keycode.h +351 -0
- data/dependencies/SDL/include/SDL_loadso.h +81 -0
- data/dependencies/SDL/include/SDL_locale.h +101 -0
- data/dependencies/SDL/include/SDL_log.h +211 -0
- data/dependencies/SDL/include/SDL_main.h +180 -0
- data/dependencies/SDL/include/SDL_messagebox.h +146 -0
- data/dependencies/SDL/include/SDL_metal.h +117 -0
- data/dependencies/SDL/include/SDL_misc.h +75 -0
- data/dependencies/SDL/include/SDL_mouse.h +302 -0
- data/dependencies/SDL/include/SDL_mutex.h +251 -0
- data/dependencies/SDL/include/SDL_name.h +33 -0
- data/dependencies/SDL/include/SDL_opengl.h +2183 -0
- data/dependencies/SDL/include/SDL_opengl_glext.h +11180 -0
- data/dependencies/SDL/include/SDL_opengles.h +39 -0
- data/dependencies/SDL/include/SDL_opengles2.h +52 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2.h +621 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +2050 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +30 -0
- data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +282 -0
- data/dependencies/SDL/include/SDL_pixels.h +479 -0
- data/dependencies/SDL/include/SDL_platform.h +198 -0
- data/dependencies/SDL/include/SDL_power.h +75 -0
- data/dependencies/SDL/include/SDL_quit.h +58 -0
- data/dependencies/SDL/include/SDL_rect.h +174 -0
- data/dependencies/SDL/include/SDL_render.h +1158 -0
- data/dependencies/SDL/include/SDL_revision.h +2 -0
- data/dependencies/SDL/include/SDL_rwops.h +283 -0
- data/dependencies/SDL/include/SDL_scancode.h +413 -0
- data/dependencies/SDL/include/SDL_sensor.h +267 -0
- data/dependencies/SDL/include/SDL_shape.h +144 -0
- data/dependencies/SDL/include/SDL_stdinc.h +647 -0
- data/dependencies/SDL/include/SDL_surface.h +563 -0
- data/dependencies/SDL/include/SDL_system.h +325 -0
- data/dependencies/SDL/include/SDL_syswm.h +354 -0
- data/dependencies/SDL/include/SDL_test.h +69 -0
- data/dependencies/SDL/include/SDL_test_assert.h +105 -0
- data/dependencies/SDL/include/SDL_test_common.h +218 -0
- data/dependencies/SDL/include/SDL_test_compare.h +69 -0
- data/dependencies/SDL/include/SDL_test_crc32.h +124 -0
- data/dependencies/SDL/include/SDL_test_font.h +81 -0
- data/dependencies/SDL/include/SDL_test_fuzzer.h +384 -0
- data/dependencies/SDL/include/SDL_test_harness.h +134 -0
- data/dependencies/SDL/include/SDL_test_images.h +78 -0
- data/dependencies/SDL/include/SDL_test_log.h +67 -0
- data/dependencies/SDL/include/SDL_test_md5.h +129 -0
- data/dependencies/SDL/include/SDL_test_memory.h +63 -0
- data/dependencies/SDL/include/SDL_test_random.h +115 -0
- data/dependencies/SDL/include/SDL_thread.h +366 -0
- data/dependencies/SDL/include/SDL_timer.h +115 -0
- data/dependencies/SDL/include/SDL_touch.h +102 -0
- data/dependencies/SDL/include/SDL_types.h +29 -0
- data/dependencies/SDL/include/SDL_version.h +162 -0
- data/dependencies/SDL/include/SDL_video.h +1282 -0
- data/dependencies/SDL/include/SDL_vulkan.h +276 -0
- data/dependencies/SDL/include/begin_code.h +166 -0
- data/dependencies/SDL/include/close_code.h +40 -0
- 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 +795 -0
- data/dependencies/SDL_sound/SDL_sound.h +725 -0
- data/dependencies/SDL_sound/SDL_sound_aiff.c +537 -0
- data/dependencies/SDL_sound/SDL_sound_au.c +352 -0
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +747 -0
- data/dependencies/SDL_sound/SDL_sound_flac.c +182 -0
- data/dependencies/SDL_sound/SDL_sound_internal.h +304 -0
- data/dependencies/SDL_sound/SDL_sound_modplug.c +228 -0
- data/dependencies/SDL_sound/SDL_sound_mp3.c +184 -0
- data/dependencies/SDL_sound/SDL_sound_raw.c +164 -0
- data/dependencies/SDL_sound/SDL_sound_shn.c +1309 -0
- data/dependencies/SDL_sound/SDL_sound_voc.c +550 -0
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +223 -0
- data/dependencies/SDL_sound/SDL_sound_wav.c +783 -0
- data/dependencies/SDL_sound/dr_flac.h +5906 -0
- data/dependencies/SDL_sound/dr_mp3.h +2832 -0
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1748 -0
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +1001 -0
- data/dependencies/SDL_sound/libmodplug/load_669.c +188 -0
- data/dependencies/SDL_sound/libmodplug/load_abc.c +4725 -0
- data/dependencies/SDL_sound/libmodplug/load_amf.c +403 -0
- data/dependencies/SDL_sound/libmodplug/load_ams.c +587 -0
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +357 -0
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +531 -0
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +232 -0
- data/dependencies/SDL_sound/libmodplug/load_far.c +253 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +796 -0
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +488 -0
- data/dependencies/SDL_sound/libmodplug/load_med.c +757 -0
- data/dependencies/SDL_sound/libmodplug/load_mid.c +1405 -0
- data/dependencies/SDL_sound/libmodplug/load_mod.c +269 -0
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +546 -0
- data/dependencies/SDL_sound/libmodplug/load_mtm.c +142 -0
- data/dependencies/SDL_sound/libmodplug/load_okt.c +192 -0
- data/dependencies/SDL_sound/libmodplug/load_pat.c +1143 -0
- data/dependencies/SDL_sound/libmodplug/load_pat.h +25 -0
- data/dependencies/SDL_sound/libmodplug/load_psm.c +350 -0
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +204 -0
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +325 -0
- data/dependencies/SDL_sound/libmodplug/load_stm.c +180 -0
- data/dependencies/SDL_sound/libmodplug/load_ult.c +206 -0
- data/dependencies/SDL_sound/libmodplug/load_umx.c +51 -0
- data/dependencies/SDL_sound/libmodplug/load_xm.c +554 -0
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +382 -0
- data/dependencies/SDL_sound/libmodplug/modplug.c +170 -0
- data/dependencies/SDL_sound/libmodplug/modplug.h +90 -0
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +301 -0
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +63 -0
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +2350 -0
- data/dependencies/SDL_sound/libmodplug/sndfile.c +1169 -0
- data/dependencies/SDL_sound/libmodplug/sndmix.c +1034 -0
- data/dependencies/SDL_sound/libmodplug/tables.h +371 -0
- data/{src/stb_vorbis.c → dependencies/SDL_sound/stb_vorbis.h} +128 -23
- data/dependencies/al_soft/AL/al.h +655 -0
- data/dependencies/al_soft/AL/alc.h +270 -0
- data/dependencies/al_soft/AL/alext.h +585 -0
- data/dependencies/al_soft/AL/efx-creative.h +3 -0
- data/dependencies/al_soft/AL/efx-presets.h +402 -0
- data/dependencies/al_soft/AL/efx.h +762 -0
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/{src → dependencies/stb}/stb_image.h +476 -176
- data/{src → dependencies/stb}/stb_image_write.h +253 -131
- data/{src → dependencies/stb}/stb_truetype.h +262 -104
- data/{src → dependencies/utf8proc}/utf8proc.c +47 -29
- data/{src → dependencies/utf8proc}/utf8proc.h +46 -24
- data/{src → dependencies/utf8proc}/utf8proc_data.h +10043 -9609
- data/ext/gosu/extconf.rb +53 -39
- data/{Gosu → include/Gosu}/Audio.hpp +6 -8
- data/include/Gosu/Bitmap.hpp +100 -0
- data/{Gosu → include/Gosu}/Buttons.hpp +104 -44
- data/include/Gosu/Channel.h +25 -0
- data/include/Gosu/Color.h +38 -0
- data/{Gosu → include/Gosu}/Color.hpp +0 -0
- data/{Gosu → include/Gosu}/Directories.hpp +0 -0
- data/include/Gosu/Font.h +36 -0
- data/{Gosu → include/Gosu}/Font.hpp +0 -0
- data/{Gosu → include/Gosu}/Fwd.hpp +0 -5
- data/include/Gosu/Gosu.h +82 -0
- data/{Gosu → include/Gosu}/Gosu.hpp +0 -0
- data/{Gosu → include/Gosu}/Graphics.hpp +0 -0
- data/{Gosu → include/Gosu}/GraphicsBase.hpp +0 -0
- data/{Gosu → include/Gosu}/IO.hpp +0 -0
- data/include/Gosu/Image.h +54 -0
- data/{Gosu → include/Gosu}/Image.hpp +7 -6
- data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
- data/{Gosu → include/Gosu}/Input.hpp +39 -51
- data/{Gosu → include/Gosu}/Inspection.hpp +0 -0
- data/{Gosu → include/Gosu}/Math.hpp +0 -0
- data/{Gosu → include/Gosu}/Platform.hpp +0 -0
- data/include/Gosu/Sample.h +19 -0
- data/include/Gosu/Song.h +24 -0
- data/{Gosu → include/Gosu}/Text.hpp +0 -0
- data/include/Gosu/TextInput.h +30 -0
- data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
- data/{Gosu → include/Gosu}/Timing.hpp +0 -0
- data/{Gosu → include/Gosu}/Utility.hpp +15 -4
- data/{Gosu → include/Gosu}/Version.hpp +3 -3
- data/include/Gosu/Window.h +63 -0
- data/{Gosu → include/Gosu}/Window.hpp +23 -25
- data/lib/OpenAL32.dll +0 -0
- data/lib/SDL2.dll +0 -0
- data/lib/gosu.rb +0 -3
- data/lib/gosu/compat.rb +9 -4
- data/lib/gosu/patches.rb +8 -11
- data/lib/gosu/swig_patches.rb +13 -6
- data/lib64/OpenAL32.dll +0 -0
- data/lib64/SDL2.dll +0 -0
- data/rdoc/gosu.rb +114 -21
- data/src/Audio.cpp +50 -224
- data/src/AudioFile.hpp +20 -37
- data/src/AudioFileAudioToolbox.cpp +237 -0
- data/src/AudioFileSDLSound.cpp +147 -0
- data/src/AudioImpl.cpp +3 -12
- data/src/AudioImpl.hpp +3 -1
- data/src/Bitmap.cpp +85 -83
- data/src/BitmapIO.cpp +52 -58
- data/src/ChannelWrapper.cpp +50 -0
- data/src/ColorWrapper.cpp +126 -0
- data/src/Constants.cpp +338 -0
- data/src/Font.cpp +4 -1
- data/src/FontWrapper.cpp +74 -0
- data/src/GosuWrapper.cpp +251 -0
- data/src/Graphics.cpp +11 -5
- data/src/GraphicsImpl.hpp +0 -1
- data/src/Image.cpp +13 -16
- data/src/ImageWrapper.cpp +168 -0
- data/src/Input.cpp +412 -164
- data/src/LargeImageData.cpp +2 -1
- data/src/MarkupParser.cpp +13 -4
- data/src/RubyGosu.cxx +502 -219
- data/src/RubyGosu.h +4 -2
- data/src/SampleWrapper.cpp +30 -0
- data/src/SongWrapper.cpp +52 -0
- data/src/TexChunk.cpp +29 -19
- data/src/Text.cpp +2 -0
- data/src/TextBuilder.cpp +6 -4
- data/src/TextInputWrapper.cpp +101 -0
- data/src/Texture.cpp +1 -1
- data/src/TrueTypeFont.cpp +2 -1
- data/src/Utility.cpp +11 -7
- data/src/Window.cpp +30 -39
- data/src/WindowWrapper.cpp +317 -0
- metadata +212 -42
- data/Gosu/AutoLink.hpp +0 -14
- data/Gosu/Bitmap.hpp +0 -113
- data/src/AudioToolboxFile.hpp +0 -210
- data/src/OggFile.hpp +0 -92
- data/src/SndFile.hpp +0 -174
- data/src/WinMain.cpp +0 -64
data/src/Font.cpp
CHANGED
@@ -6,10 +6,13 @@
|
|
6
6
|
#include <Gosu/Math.hpp>
|
7
7
|
#include <Gosu/Text.hpp>
|
8
8
|
#include <Gosu/Utility.hpp>
|
9
|
-
|
9
|
+
|
10
|
+
#include <utf8proc.h>
|
11
|
+
|
10
12
|
#include <array>
|
11
13
|
#include <cassert>
|
12
14
|
#include <map>
|
15
|
+
#include <stdexcept>
|
13
16
|
using namespace std;
|
14
17
|
|
15
18
|
static const int FONT_RENDER_SCALE = 2;
|
data/src/FontWrapper.cpp
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#include <Gosu/Gosu.hpp>
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
#include <Gosu/Image.h>
|
5
|
+
#include <Gosu/Font.h>
|
6
|
+
|
7
|
+
Gosu_Font *Gosu_Font_create(int height, const char *name, unsigned flags)
|
8
|
+
{
|
9
|
+
return reinterpret_cast<Gosu_Font *>(new Gosu::Font(height, name, flags));
|
10
|
+
}
|
11
|
+
|
12
|
+
const char *Gosu_Font_name(Gosu_Font *font)
|
13
|
+
{
|
14
|
+
return reinterpret_cast<Gosu::Font *>(font)->name().c_str();
|
15
|
+
}
|
16
|
+
|
17
|
+
int Gosu_Font_height(Gosu_Font *font)
|
18
|
+
{
|
19
|
+
return reinterpret_cast<Gosu::Font *>(font)->height();
|
20
|
+
}
|
21
|
+
|
22
|
+
unsigned Gosu_Font_flags(Gosu_Font *font)
|
23
|
+
{
|
24
|
+
return reinterpret_cast<Gosu::Font *>(font)->flags();
|
25
|
+
}
|
26
|
+
|
27
|
+
double Gosu_Font_text_width(Gosu_Font *font, const char *text)
|
28
|
+
{
|
29
|
+
return reinterpret_cast<Gosu::Font *>(font)->text_width(text);
|
30
|
+
}
|
31
|
+
|
32
|
+
double Gosu_Font_markup_width(Gosu_Font *font, const char *text)
|
33
|
+
{
|
34
|
+
return reinterpret_cast<Gosu::Font *>(font)->markup_width(text);
|
35
|
+
}
|
36
|
+
|
37
|
+
void Gosu_Font_draw_text(Gosu_Font *font, const char *text, double x, double y, double z,
|
38
|
+
double scale_x, double scale_y, unsigned c, unsigned mode)
|
39
|
+
{
|
40
|
+
reinterpret_cast<Gosu::Font *>(font)->draw_text(text, x, y, z, scale_x, scale_y, c, (Gosu::AlphaMode)mode);
|
41
|
+
}
|
42
|
+
|
43
|
+
void Gosu_Font_draw_markup(Gosu_Font *font, const char *text, double x, double y, double z,
|
44
|
+
double scale_x, double scale_y, unsigned c, unsigned mode)
|
45
|
+
{
|
46
|
+
reinterpret_cast<Gosu::Font *>(font)->draw_markup(text, x, y, z, scale_x, scale_y, c, (Gosu::AlphaMode)mode);
|
47
|
+
}
|
48
|
+
|
49
|
+
void Gosu_Font_draw_text_rel(Gosu_Font *font, const char *text, double x, double y, double z,
|
50
|
+
double rel_x, double rel_y, double scale_x, double scale_y,
|
51
|
+
unsigned c, unsigned mode)
|
52
|
+
{
|
53
|
+
reinterpret_cast<Gosu::Font *>(font)->draw_text_rel(text, x, y, z, rel_x, rel_y, scale_x, scale_y, c, (Gosu::AlphaMode)mode);
|
54
|
+
}
|
55
|
+
|
56
|
+
void Gosu_Font_draw_markup_rel(Gosu_Font *font, const char *text, double x, double y, double z,
|
57
|
+
double rel_x, double rel_y, double scale_x, double scale_y,
|
58
|
+
unsigned c, unsigned mode)
|
59
|
+
{
|
60
|
+
reinterpret_cast<Gosu::Font *>(font)->draw_markup_rel(text, x, y, z, rel_x, rel_y, scale_x, scale_y, c, (Gosu::AlphaMode)mode);
|
61
|
+
}
|
62
|
+
|
63
|
+
void Gosu_Font_set_image(Gosu_Font *font, const char *codepoint, unsigned font_flags, Gosu_Image *image)
|
64
|
+
{
|
65
|
+
|
66
|
+
const Gosu::Image *gosu_image = reinterpret_cast<Gosu::Image *>(image);
|
67
|
+
reinterpret_cast<Gosu::Font *>(font)->set_image(codepoint, font_flags, *gosu_image);
|
68
|
+
}
|
69
|
+
|
70
|
+
void Gosu_Font_destroy(Gosu_Font *font)
|
71
|
+
{
|
72
|
+
delete (reinterpret_cast<Gosu::Font *>(font));
|
73
|
+
}
|
74
|
+
}
|
data/src/GosuWrapper.cpp
ADDED
@@ -0,0 +1,251 @@
|
|
1
|
+
#include <Gosu/Gosu.hpp>
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
#include <Gosu/Gosu.h>
|
5
|
+
|
6
|
+
void Gosu_gl_z(double z, void function(void *data), void *data)
|
7
|
+
{
|
8
|
+
std::function<void ()> callback;
|
9
|
+
callback = [=]() { function(data); };
|
10
|
+
|
11
|
+
Gosu::Graphics::gl(z, callback);
|
12
|
+
}
|
13
|
+
|
14
|
+
void Gosu_gl(void function(void *data), void *data)
|
15
|
+
{
|
16
|
+
std::function<void ()> callback;
|
17
|
+
callback = [=]() { function(data); };
|
18
|
+
|
19
|
+
Gosu::Graphics::gl(callback);
|
20
|
+
}
|
21
|
+
|
22
|
+
Gosu_Image *Gosu_render(int width, int height, void function(void *data), void *data, unsigned image_flags)
|
23
|
+
{
|
24
|
+
std::function<void ()> callback;
|
25
|
+
callback = [=]() { function(data); };
|
26
|
+
|
27
|
+
return reinterpret_cast<Gosu_Image *>(new Gosu::Image(Gosu::Graphics::render(width, height, callback, image_flags)));
|
28
|
+
}
|
29
|
+
|
30
|
+
Gosu_Image *Gosu_record(int width, int height, void function(void *data), void *data)
|
31
|
+
{
|
32
|
+
std::function<void ()> callback;
|
33
|
+
callback = [=]() { function(data); };
|
34
|
+
return reinterpret_cast<Gosu_Image *>(new Gosu::Image(Gosu::Graphics::record(width, height, callback)));
|
35
|
+
}
|
36
|
+
|
37
|
+
void Gosu_flush()
|
38
|
+
{
|
39
|
+
Gosu::Graphics::flush();
|
40
|
+
}
|
41
|
+
|
42
|
+
void Gosu_transform(double m0, double m1, double m2, double m3, double m4, double m5, double m6,
|
43
|
+
double m7, double m8, double m9, double m10, double m11, double m12, double m13,
|
44
|
+
double m14, double m15, void function(void *data), void *data)
|
45
|
+
{
|
46
|
+
Gosu::Transform transform = {
|
47
|
+
m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15};
|
48
|
+
std::function<void ()> callback;
|
49
|
+
callback = [=]() { function(data); };
|
50
|
+
|
51
|
+
Gosu::Graphics::transform(transform, callback);
|
52
|
+
}
|
53
|
+
|
54
|
+
void Gosu_translate(double x, double y, void function(void *data), void *data)
|
55
|
+
{
|
56
|
+
std::function<void ()> callback;
|
57
|
+
callback = [=]() { function(data); };
|
58
|
+
|
59
|
+
Gosu::Graphics::transform(Gosu::translate(x, y), callback);
|
60
|
+
}
|
61
|
+
|
62
|
+
void Gosu_scale(double scale_x, double scale_y, double around_x, double around_y, void function(void *data), void *data)
|
63
|
+
{
|
64
|
+
std::function<void ()> callback;
|
65
|
+
callback = [=]() { function(data); };
|
66
|
+
|
67
|
+
Gosu::Graphics::transform(Gosu::scale(scale_x, scale_y, around_x, around_y), callback);
|
68
|
+
}
|
69
|
+
|
70
|
+
void Gosu_rotate(double angle, double around_x, double around_y, void function(void *data), void *data)
|
71
|
+
{
|
72
|
+
std::function<void ()> callback;
|
73
|
+
callback = [=]() { function(data); };
|
74
|
+
|
75
|
+
Gosu::Graphics::transform(Gosu::rotate(angle, around_x, around_y), callback);
|
76
|
+
}
|
77
|
+
|
78
|
+
void Gosu_clip_to(double x, double y, double width, double height, void function(void *data), void *data)
|
79
|
+
{
|
80
|
+
std::function<void ()> callback;
|
81
|
+
callback = [=]() { function(data); };
|
82
|
+
|
83
|
+
Gosu::Graphics::clip_to(x, y, width, height, callback);
|
84
|
+
}
|
85
|
+
|
86
|
+
void Gosu_draw_line(double x1, double y1, unsigned c1,
|
87
|
+
double x2, double y2, unsigned c2,
|
88
|
+
double z, unsigned mode)
|
89
|
+
{
|
90
|
+
Gosu::Graphics::draw_line(x1, y1, c1, x2, y2, c2, z, (Gosu::AlphaMode)mode);
|
91
|
+
}
|
92
|
+
|
93
|
+
void Gosu_draw_triangle(double x1, double y1, unsigned c1,
|
94
|
+
double x2, double y2, unsigned c2,
|
95
|
+
double x3, double y3, unsigned c3,
|
96
|
+
double z, unsigned mode)
|
97
|
+
{
|
98
|
+
Gosu::Graphics::draw_triangle(x1, y1, c1,
|
99
|
+
x2, y2, c2,
|
100
|
+
x3, y3, c3,
|
101
|
+
z, (Gosu::AlphaMode)mode);
|
102
|
+
}
|
103
|
+
|
104
|
+
void Gosu_draw_rect(double x, double y, double width, double height, unsigned c, double z, unsigned mode)
|
105
|
+
{
|
106
|
+
Gosu::Graphics::draw_rect(x, y, width, height, c, z, (Gosu::AlphaMode)mode);
|
107
|
+
}
|
108
|
+
|
109
|
+
void Gosu_draw_quad(double x1, double y1, unsigned c1,
|
110
|
+
double x2, double y2, unsigned c2,
|
111
|
+
double x3, double y3, unsigned c3,
|
112
|
+
double x4, double y4, unsigned c4,
|
113
|
+
double z, unsigned mode)
|
114
|
+
{
|
115
|
+
Gosu::Graphics::draw_quad(x1, y1, c1,
|
116
|
+
x2, y2, c2,
|
117
|
+
x3, y3, c3,
|
118
|
+
x4, y4, c4,
|
119
|
+
z, (Gosu::AlphaMode)mode);
|
120
|
+
}
|
121
|
+
|
122
|
+
double Gosu_distance(double x1, double y1, double x2, double y2)
|
123
|
+
{
|
124
|
+
return Gosu::distance(x1, y1, x2, y2);
|
125
|
+
}
|
126
|
+
|
127
|
+
double Gosu_angle(double from_x, double from_y, double to_x, double to_y)
|
128
|
+
{
|
129
|
+
return Gosu::angle(from_x, from_y, to_x, to_y);
|
130
|
+
}
|
131
|
+
|
132
|
+
double Gosu_angle_diff(double from, double to)
|
133
|
+
{
|
134
|
+
return Gosu::angle_diff(from, to);
|
135
|
+
}
|
136
|
+
|
137
|
+
double Gosu_offset_x(double angle, double radius)
|
138
|
+
{
|
139
|
+
return Gosu::offset_x(angle, radius);
|
140
|
+
}
|
141
|
+
|
142
|
+
double Gosu_offset_y(double angle, double radius)
|
143
|
+
{
|
144
|
+
return Gosu::offset_y(angle, radius);
|
145
|
+
}
|
146
|
+
|
147
|
+
double Gosu_random(double min, double max)
|
148
|
+
{
|
149
|
+
return Gosu::random(min, max);
|
150
|
+
}
|
151
|
+
|
152
|
+
unsigned Gosu_available_width(Gosu_Window *window)
|
153
|
+
{
|
154
|
+
Gosu::Window *gosu_window = nullptr;
|
155
|
+
if (window != nullptr) {
|
156
|
+
gosu_window = reinterpret_cast<Gosu::Window *>(window);
|
157
|
+
}
|
158
|
+
return Gosu::available_width(gosu_window);
|
159
|
+
}
|
160
|
+
|
161
|
+
unsigned Gosu_available_height(Gosu_Window *window)
|
162
|
+
{
|
163
|
+
Gosu::Window *gosu_window = nullptr;
|
164
|
+
if (window != nullptr) {
|
165
|
+
gosu_window = reinterpret_cast<Gosu::Window *>(window);
|
166
|
+
}
|
167
|
+
return Gosu::available_height(gosu_window);
|
168
|
+
}
|
169
|
+
|
170
|
+
unsigned Gosu_screen_width(Gosu_Window *window)
|
171
|
+
{
|
172
|
+
Gosu::Window *gosu_window = nullptr;
|
173
|
+
if (window != nullptr) {
|
174
|
+
gosu_window = reinterpret_cast<Gosu::Window *>(window);
|
175
|
+
}
|
176
|
+
return Gosu::screen_width(gosu_window);
|
177
|
+
}
|
178
|
+
|
179
|
+
unsigned Gosu_screen_height(Gosu_Window *window)
|
180
|
+
{
|
181
|
+
Gosu::Window *gosu_window = nullptr;
|
182
|
+
if (window != nullptr) {
|
183
|
+
gosu_window = reinterpret_cast<Gosu::Window *>(window);
|
184
|
+
}
|
185
|
+
return Gosu::screen_height(gosu_window);
|
186
|
+
}
|
187
|
+
|
188
|
+
int Gosu_button_down(int btn)
|
189
|
+
{
|
190
|
+
return Gosu::Input::down((Gosu::Button)btn);
|
191
|
+
}
|
192
|
+
|
193
|
+
const char *Gosu_button_id_to_char(int id)
|
194
|
+
{
|
195
|
+
static thread_local std::string button;
|
196
|
+
button = Gosu::Input::id_to_char((Gosu::Button)id);
|
197
|
+
|
198
|
+
return button.c_str();
|
199
|
+
}
|
200
|
+
|
201
|
+
unsigned Gosu_button_char_to_id(const char *btn)
|
202
|
+
{
|
203
|
+
return Gosu::Input::char_to_id(btn);
|
204
|
+
}
|
205
|
+
|
206
|
+
const char *Gosu_button_name(int btn)
|
207
|
+
{
|
208
|
+
static thread_local std::string name;
|
209
|
+
name = Gosu::Input::button_name((Gosu::Button)btn);
|
210
|
+
return name.empty() ? nullptr : name.c_str();
|
211
|
+
}
|
212
|
+
|
213
|
+
const char *Gosu_gamepad_name(int id)
|
214
|
+
{
|
215
|
+
static thread_local std::string name;
|
216
|
+
name = Gosu::Input::gamepad_name(id);
|
217
|
+
return name.empty() ? nullptr : name.c_str();
|
218
|
+
}
|
219
|
+
|
220
|
+
double Gosu_axis(int btn)
|
221
|
+
{
|
222
|
+
return Gosu::Input::axis((Gosu::Button)btn);
|
223
|
+
}
|
224
|
+
|
225
|
+
int Gosu_fps()
|
226
|
+
{
|
227
|
+
return Gosu::fps();
|
228
|
+
}
|
229
|
+
|
230
|
+
const char *Gosu_language()
|
231
|
+
{
|
232
|
+
static thread_local std::string language;
|
233
|
+
language = Gosu::language();
|
234
|
+
|
235
|
+
return language.c_str();
|
236
|
+
}
|
237
|
+
|
238
|
+
long Gosu_milliseconds()
|
239
|
+
{
|
240
|
+
return Gosu::milliseconds();
|
241
|
+
}
|
242
|
+
|
243
|
+
const char *Gosu_default_font_name()
|
244
|
+
{
|
245
|
+
static thread_local std::string name;
|
246
|
+
name = Gosu::default_font_name();
|
247
|
+
|
248
|
+
return name.c_str();
|
249
|
+
}
|
250
|
+
|
251
|
+
}
|
data/src/Graphics.cpp
CHANGED
@@ -68,7 +68,7 @@ struct Gosu::Graphics::Impl
|
|
68
68
|
{
|
69
69
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
70
70
|
glDisable(GL_BLEND);
|
71
|
-
// Reset the
|
71
|
+
// Reset the color to white to avoid surprises.
|
72
72
|
// https://www.libgosu.org/cgi-bin/mwf/topic_show.pl?pid=9115#pid9115
|
73
73
|
glColor4ubv(reinterpret_cast<const GLubyte*>(&Color::WHITE));
|
74
74
|
while (glGetError() != GL_NO_ERROR);
|
@@ -287,13 +287,20 @@ Gosu::Image Gosu::Graphics::render(int width, int height, const function<void ()
|
|
287
287
|
|
288
288
|
// This is the actual render-to-texture step.
|
289
289
|
Image result = OffScreenTarget(width, height, image_flags).render([&] {
|
290
|
+
#ifndef GOSU_IS_OPENGLES
|
291
|
+
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
292
|
+
#endif
|
290
293
|
glClearColor(0, 0, 0, 0);
|
291
294
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
295
|
+
glEnable(GL_BLEND);
|
292
296
|
queues.emplace_back(QM_RENDER_TO_TEXTURE);
|
293
297
|
f();
|
294
298
|
queues.back().perform_draw_ops_and_code();
|
295
299
|
queues.pop_back();
|
296
300
|
glFlush();
|
301
|
+
#ifndef GOSU_IS_OPENGLES
|
302
|
+
glPopAttrib();
|
303
|
+
#endif
|
297
304
|
});
|
298
305
|
|
299
306
|
// Restore previous matrix and glViewport.
|
@@ -431,7 +438,7 @@ unique_ptr<Gosu::ImageData> Gosu::Graphics::create_image(const Bitmap& src,
|
|
431
438
|
}
|
432
439
|
else {
|
433
440
|
Bitmap bmp(src_width, src_height);
|
434
|
-
bmp.insert(
|
441
|
+
bmp.insert(0, 0, src, src_x, src_y, src_width, src_height);
|
435
442
|
data = texture->try_alloc(bmp, 0);
|
436
443
|
}
|
437
444
|
|
@@ -442,14 +449,13 @@ unique_ptr<Gosu::ImageData> Gosu::Graphics::create_image(const Bitmap& src,
|
|
442
449
|
// Too large to fit on a single texture.
|
443
450
|
if (src_width > max_size - 2 || src_height > max_size - 2) {
|
444
451
|
Bitmap bmp(src_width, src_height);
|
445
|
-
bmp.insert(
|
452
|
+
bmp.insert(0, 0, src, src_x, src_y, src_width, src_height);
|
446
453
|
unique_ptr<ImageData> lidi;
|
447
454
|
lidi.reset(new LargeImageData(bmp, max_size - 2, max_size - 2, flags));
|
448
455
|
return lidi;
|
449
456
|
}
|
450
457
|
|
451
|
-
Bitmap bmp;
|
452
|
-
apply_border_flags(bmp, src, src_x, src_y, src_width, src_height, flags);
|
458
|
+
Bitmap bmp = apply_border_flags(flags, src, src_x, src_y, src_width, src_height);
|
453
459
|
|
454
460
|
// Try to put the bitmap into one of the already allocated textures.
|
455
461
|
for (const auto& texture : textures) {
|
data/src/GraphicsImpl.hpp
CHANGED
@@ -110,7 +110,6 @@ namespace Gosu
|
|
110
110
|
void ensure_current_context();
|
111
111
|
|
112
112
|
inline std::string escape_markup(const std::string& text) {
|
113
|
-
// Escape all markup and delegate to layout_markup.
|
114
113
|
auto markup = text;
|
115
114
|
for (std::string::size_type pos = 0; pos < markup.length(); ++pos) {
|
116
115
|
if (markup[pos] == '&') {
|
data/src/Image.cpp
CHANGED
@@ -13,32 +13,30 @@ Gosu::Image::Image()
|
|
13
13
|
{
|
14
14
|
}
|
15
15
|
|
16
|
-
Gosu::Image::Image(const string& filename, unsigned
|
16
|
+
Gosu::Image::Image(const string& filename, unsigned image_flags)
|
17
17
|
{
|
18
18
|
// Forward.
|
19
|
-
Bitmap
|
20
|
-
|
21
|
-
Image(bmp, flags).data_.swap(data_);
|
19
|
+
Bitmap bitmap = load_image_file(filename);
|
20
|
+
Image{bitmap, image_flags}.data_.swap(data_);
|
22
21
|
}
|
23
22
|
|
24
|
-
Gosu::Image::Image(const string& filename,
|
25
|
-
unsigned
|
23
|
+
Gosu::Image::Image(const string& filename, int src_x, int src_y, int src_width, int src_height,
|
24
|
+
unsigned image_flags)
|
26
25
|
{
|
27
26
|
// Forward.
|
28
|
-
Bitmap
|
29
|
-
|
30
|
-
Image(bmp, src_x, src_y, src_width, src_height, flags).data_.swap(data_);
|
27
|
+
Bitmap bitmap = load_image_file(filename);
|
28
|
+
Image{bitmap, src_x, src_y, src_width, src_height, image_flags}.data_.swap(data_);
|
31
29
|
}
|
32
30
|
|
33
|
-
Gosu::Image::Image(const Bitmap& source, unsigned
|
31
|
+
Gosu::Image::Image(const Bitmap& source, unsigned image_flags)
|
34
32
|
{
|
35
33
|
// Forward.
|
36
|
-
Image
|
34
|
+
Image{source, 0, 0, source.width(), source.height(), image_flags}.data_.swap(data_);
|
37
35
|
}
|
38
36
|
|
39
|
-
Gosu::Image::Image(const Bitmap& source,
|
40
|
-
unsigned
|
41
|
-
: data_(Graphics::create_image(source, src_x, src_y, src_width, src_height,
|
37
|
+
Gosu::Image::Image(const Bitmap& source, int src_x, int src_y, int src_width, int src_height,
|
38
|
+
unsigned image_flags)
|
39
|
+
: data_(Graphics::create_image(source, src_x, src_y, src_width, src_height, image_flags))
|
42
40
|
{
|
43
41
|
}
|
44
42
|
|
@@ -141,7 +139,6 @@ vector<Gosu::Image> Gosu::load_tiles(const Bitmap& bmp, int tile_width, int tile
|
|
141
139
|
vector<Gosu::Image> Gosu::load_tiles(const string& filename, int tile_width, int tile_height,
|
142
140
|
unsigned flags)
|
143
141
|
{
|
144
|
-
Bitmap bmp;
|
145
|
-
load_image_file(bmp, filename);
|
142
|
+
Bitmap bmp = load_image_file(filename);
|
146
143
|
return load_tiles(bmp, tile_width, tile_height, flags);
|
147
144
|
}
|