gosu 0.15.2 → 1.0.0.pre1
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 +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} +143 -78
- 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 +330 -127
- data/{src → dependencies/stb}/stb_image_write.h +156 -85
- data/{src → dependencies/stb}/stb_truetype.h +192 -69
- data/{src → dependencies/utf8proc}/utf8proc.c +0 -0
- data/{src → dependencies/utf8proc}/utf8proc.h +0 -0
- data/{src → dependencies/utf8proc}/utf8proc_data.h +0 -0
- data/ext/gosu/extconf.rb +56 -22
- data/{Gosu → include/Gosu}/Audio.hpp +6 -8
- data/{Gosu → include/Gosu}/AutoLink.hpp +0 -0
- data/include/Gosu/Bitmap.hpp +100 -0
- data/{Gosu → include/Gosu}/Buttons.hpp +94 -35
- data/{Gosu → include/Gosu}/Channel.h +0 -0
- data/{Gosu → include/Gosu}/Color.h +0 -0
- data/{Gosu → include/Gosu}/Color.hpp +0 -0
- data/{Gosu → include/Gosu}/Directories.hpp +0 -0
- data/{Gosu → include/Gosu}/Font.h +0 -0
- data/{Gosu → include/Gosu}/Font.hpp +0 -0
- data/{Gosu → include/Gosu}/Fwd.hpp +0 -0
- data/{Gosu → include/Gosu}/Gosu.h +3 -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/{Gosu → include/Gosu}/Image.h +0 -0
- data/{Gosu → include/Gosu}/Image.hpp +7 -6
- data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
- data/{Gosu → include/Gosu}/Input.hpp +30 -15
- 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/{Gosu → include/Gosu}/Sample.h +0 -0
- data/{Gosu → include/Gosu}/Song.h +0 -0
- data/{Gosu → include/Gosu}/Text.hpp +0 -0
- data/{Gosu → include/Gosu}/TextInput.h +0 -0
- data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
- data/{Gosu → include/Gosu}/Timing.hpp +0 -0
- data/{Gosu → include/Gosu}/Utility.hpp +1 -1
- data/{Gosu → include/Gosu}/Version.hpp +0 -0
- data/{Gosu → include/Gosu}/Window.h +2 -0
- data/{Gosu → include/Gosu}/Window.hpp +21 -13
- data/lib/OpenAL32.dll +0 -0
- data/lib/SDL2.dll +0 -0
- data/lib/gosu.rb +0 -3
- data/lib/gosu/patches.rb +0 -9
- data/lib/gosu/swig_patches.rb +3 -2
- data/lib/libmpg123.dll +0 -0
- data/lib/libsndfile.dll +0 -0
- data/lib64/OpenAL32.dll +0 -0
- data/lib64/SDL2.dll +0 -0
- data/lib64/libmpg123.dll +0 -0
- data/lib64/libsndfile.dll +0 -0
- data/rdoc/gosu.rb +95 -20
- data/src/Audio.cpp +50 -224
- data/src/AudioFile.hpp +17 -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/Constants.cpp +80 -33
- data/src/Font.cpp +3 -1
- data/src/GosuWrapper.cpp +19 -0
- data/src/Graphics.cpp +7 -4
- data/src/Image.cpp +13 -16
- data/src/Input.cpp +408 -159
- data/src/LargeImageData.cpp +1 -1
- data/src/MarkupParser.cpp +2 -1
- data/src/RubyGosu.cxx +349 -83
- data/src/RubyGosu.h +4 -2
- data/src/TexChunk.cpp +1 -1
- data/src/TextBuilder.cpp +3 -1
- data/src/Texture.cpp +1 -1
- data/src/TrueTypeFont.cpp +1 -1
- data/src/Utility.cpp +11 -7
- data/src/Window.cpp +30 -39
- data/src/WindowWrapper.cpp +28 -0
- metadata +207 -52
- 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
File without changes
|
File without changes
|
File without changes
|
data/ext/gosu/extconf.rb
CHANGED
@@ -1,36 +1,60 @@
|
|
1
|
-
|
1
|
+
require "rbconfig"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
case RbConfig::CONFIG["host_os"]
|
4
|
+
when /^mingw/
|
5
|
+
windows = true
|
6
|
+
when /^darwin/
|
7
|
+
macos = true
|
8
|
+
when /linux/
|
9
|
+
linux = true
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
puts '
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
if macos or linux
|
13
|
+
puts 'The Gosu gem requires some libraries to be installed system-wide.'
|
14
|
+
puts 'See the following site for a list:'
|
15
|
+
if macos
|
16
|
+
puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X'
|
17
|
+
else
|
18
|
+
puts 'https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux'
|
19
|
+
end
|
17
20
|
end
|
18
21
|
|
19
22
|
require 'mkmf'
|
20
23
|
require 'fileutils'
|
21
24
|
|
22
|
-
# Silence internal deprecation warnings in Gosu
|
25
|
+
# Silence internal deprecation warnings in Gosu.
|
23
26
|
$CFLAGS << " -DGOSU_DEPRECATED="
|
24
27
|
|
28
|
+
# Disable assertions in C code.
|
29
|
+
$CFLAGS << " -DNDEBUG"
|
30
|
+
|
25
31
|
$CXXFLAGS ||= ""
|
26
|
-
|
32
|
+
# Enable C++17, but at the same time make the compiler more permissive to avoid this error:
|
33
|
+
# https://stackoverflow.com/a/31899029 (triggered by ruby.h, which uses register variables)
|
34
|
+
# The "register" macro can be removed when support for Ruby 2.6 and older has been dropped.
|
35
|
+
$CXXFLAGS << " -std=gnu++17 -Dregister="
|
36
|
+
|
37
|
+
# Make Gosu's own header files and all of its dependencies available to C++ source files.
|
38
|
+
$INCFLAGS << " -I../../include -I../../dependencies/stb -I../../dependencies/utf8proc -I../../dependencies/SDL_sound"
|
39
|
+
|
40
|
+
if windows
|
41
|
+
# We statically compile utf8proc into the Gosu binary.
|
42
|
+
# This macro is required to avoid errors about dllexport/dllimport mismatches.
|
43
|
+
$CFLAGS << " -DUTF8PROC_STATIC"
|
44
|
+
$CXXFLAGS << " -DUTF8PROC_STATIC"
|
27
45
|
|
28
|
-
#
|
29
|
-
$
|
46
|
+
# Define UNICODE to use the Unicode-aware variants of all Win32 API functions.
|
47
|
+
$CXXFLAGS << " -DUNICODE"
|
30
48
|
|
31
|
-
|
32
|
-
|
33
|
-
|
49
|
+
# Use the bundled versions of SDL 2 and open_al.
|
50
|
+
$INCFLAGS << " -I../../dependencies/al_soft -I../../dependencies/SDL/include"
|
51
|
+
if RbConfig::CONFIG['arch'] =~ /x64-/
|
52
|
+
$LDFLAGS << " -L../../dependencies/al_soft/x64 -L../../dependencies/SDL/lib/x64"
|
53
|
+
else
|
54
|
+
$LDFLAGS << " -L../../dependencies/al_soft/x86 -L../../dependencies/SDL/lib/x86"
|
55
|
+
end
|
56
|
+
$LDFLAGS << " -lgdi32 -lwinmm -lOpenGL32 -lOpenAL32 -lSDL2"
|
57
|
+
elsif macos
|
34
58
|
# Compile all C++ files as Objective C++ on macOS since mkmf does not support .mm files.
|
35
59
|
$CXXFLAGS << " -x objective-c++ -fobjc-arc -DNDEBUG"
|
36
60
|
# Prevents issues with Apple's pre-installed Ruby 2.3 on macOS 10.13.
|
@@ -43,6 +67,7 @@ if `uname`.chomp == 'Darwin'
|
|
43
67
|
$CXXFLAGS << " -stdlib=libc++"
|
44
68
|
|
45
69
|
# Dependencies.
|
70
|
+
$CFLAGS << " #{`sdl2-config --cflags`.chomp}"
|
46
71
|
$CXXFLAGS << " #{`sdl2-config --cflags`.chomp}"
|
47
72
|
# Prefer statically linking SDL 2.
|
48
73
|
$LDFLAGS << " #{`sdl2-config --static-libs`.chomp} -framework OpenGL -framework Metal -framework OpenAL"
|
@@ -57,7 +82,7 @@ if `uname`.chomp == 'Darwin'
|
|
57
82
|
$LDFLAGS.gsub! "-arch i386", ""
|
58
83
|
$ARCH_FLAG.gsub! "-arch i386", ""
|
59
84
|
CONFIG['LDSHARED'].gsub! "-arch i386", ""
|
60
|
-
|
85
|
+
elsif linux
|
61
86
|
if /BCM2708/ =~ `cat /proc/cpuinfo`
|
62
87
|
$INCFLAGS << " -I/opt/vc/include/GLES"
|
63
88
|
$INCFLAGS << " -I/opt/vc/include"
|
@@ -76,7 +101,16 @@ else
|
|
76
101
|
pkg_config 'libmpg123'
|
77
102
|
pkg_config 'fontconfig'
|
78
103
|
|
79
|
-
have_header 'AL/al.h'
|
104
|
+
have_header 'AL/al.h' if have_library('openal')
|
105
|
+
end
|
106
|
+
|
107
|
+
# Because Ruby will only compile source file in the src/ folder, but our dependencies are
|
108
|
+
# stored in dependencies/, we need to create symlinks for all the .c files. This is terrible,
|
109
|
+
# but still seems better than putting everything into the same folder to begin with.
|
110
|
+
Dir.glob('../../dependencies/**/*.c').each do |dep|
|
111
|
+
File.open("../../src/#{File.basename dep}", "w") do |shim|
|
112
|
+
shim.puts "#include \"#{File.expand_path dep}\""
|
113
|
+
end
|
80
114
|
end
|
81
115
|
|
82
116
|
# Gem::Version#initialize is apparently broken in some versions of Ruby, so use a local helper.
|
@@ -51,8 +51,8 @@ namespace Gosu
|
|
51
51
|
//! parameters. Use samples for everything that's not music.
|
52
52
|
class Sample
|
53
53
|
{
|
54
|
-
struct
|
55
|
-
std::shared_ptr<
|
54
|
+
struct Impl;
|
55
|
+
std::shared_ptr<Impl> pimpl;
|
56
56
|
|
57
57
|
public:
|
58
58
|
//! Constructs an empty sample that is inaudible when played.
|
@@ -91,10 +91,8 @@ namespace Gosu
|
|
91
91
|
//! and there is no way to control its pan (stereo position) or speed.
|
92
92
|
class Song
|
93
93
|
{
|
94
|
-
|
95
|
-
|
96
|
-
class StreamData;
|
97
|
-
std::unique_ptr<BaseData> data;
|
94
|
+
struct Impl;
|
95
|
+
std::unique_ptr<Impl> pimpl;
|
98
96
|
|
99
97
|
// Non-movable to avoid dangling internal references.
|
100
98
|
Song(Song&&) = delete;
|
@@ -117,7 +115,7 @@ namespace Gosu
|
|
117
115
|
//! no song has been played yet or the last song has finished
|
118
116
|
//! playing.
|
119
117
|
static Song* current_song();
|
120
|
-
|
118
|
+
|
121
119
|
//! Starts or resumes playback of the song. This will stop all other
|
122
120
|
//! songs and set the current song to this object.
|
123
121
|
void play(bool looping = false);
|
@@ -137,7 +135,7 @@ namespace Gosu
|
|
137
135
|
//! \param volume Can be anything from 0.0 (silence) to 1.0 (full volume).
|
138
136
|
void set_volume(double volume);
|
139
137
|
|
140
|
-
//! Called every tick by Window
|
138
|
+
//! Called every tick by Window to feed new audio data to OpenAL.
|
141
139
|
static void update();
|
142
140
|
};
|
143
141
|
}
|
File without changes
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <Gosu/Color.hpp>
|
4
|
+
#include <Gosu/IO.hpp>
|
5
|
+
#include <string>
|
6
|
+
#include <vector>
|
7
|
+
|
8
|
+
namespace Gosu
|
9
|
+
{
|
10
|
+
/// A two-dimensional array area of pixels, each represented by a Color value.
|
11
|
+
/// Bitmaps are typically created only as an intermediate step between loading image files, and
|
12
|
+
/// creating Gosu::Image objects from them (i.e. transferring the image into video RAM).
|
13
|
+
/// Has (expensive) value semantics.
|
14
|
+
class Bitmap
|
15
|
+
{
|
16
|
+
int m_width = 0, m_height = 0;
|
17
|
+
std::vector<Color> m_pixels;
|
18
|
+
|
19
|
+
public:
|
20
|
+
Bitmap() = default;
|
21
|
+
|
22
|
+
Bitmap(int width, int height, Color c = Color::NONE);
|
23
|
+
|
24
|
+
int width() const
|
25
|
+
{
|
26
|
+
return m_width;
|
27
|
+
}
|
28
|
+
|
29
|
+
int height() const
|
30
|
+
{
|
31
|
+
return m_height;
|
32
|
+
}
|
33
|
+
|
34
|
+
void swap(Bitmap& other);
|
35
|
+
|
36
|
+
void resize(int width, int height, Color c = Color::NONE);
|
37
|
+
|
38
|
+
/// Returns the color at the specified position without any bounds checking.
|
39
|
+
Color get_pixel(int x, int y) const
|
40
|
+
{
|
41
|
+
return m_pixels[y * m_width + x];
|
42
|
+
}
|
43
|
+
|
44
|
+
/// Sets the pixel at the specified position without any bounds checking.
|
45
|
+
void set_pixel(int x, int y, Color c)
|
46
|
+
{
|
47
|
+
m_pixels[y * m_width + x] = c;
|
48
|
+
}
|
49
|
+
|
50
|
+
/// This updates a pixel using the "over" alpha compositing operator, see:
|
51
|
+
/// https://en.wikipedia.org/wiki/Alpha_compositing
|
52
|
+
void blend_pixel(int x, int y, Color c);
|
53
|
+
|
54
|
+
/// Inserts a bitmap at the given position. Parts of the inserted bitmap that would be
|
55
|
+
/// outside of the target bitmap will be clipped away.
|
56
|
+
void insert(int x, int y, const Bitmap& source);
|
57
|
+
|
58
|
+
/// Inserts a portion of a bitmap at the given position. Parts of the inserted bitmap that
|
59
|
+
/// would be outside of the target bitmap will be clipped away.
|
60
|
+
void insert(int x, int y, const Bitmap& source,
|
61
|
+
int src_x, int src_y, int src_width, int src_height);
|
62
|
+
|
63
|
+
/// Direct access to the array of color values.
|
64
|
+
/// The return value is undefined if this bitmap is empty.
|
65
|
+
const Color* data() const
|
66
|
+
{
|
67
|
+
return &m_pixels[0];
|
68
|
+
}
|
69
|
+
|
70
|
+
/// Direct access to the array of color values.
|
71
|
+
/// The return value is undefined if this bitmap is empty.
|
72
|
+
Color* data()
|
73
|
+
{
|
74
|
+
return &m_pixels[0];
|
75
|
+
}
|
76
|
+
|
77
|
+
#ifdef FRIEND_TEST
|
78
|
+
FRIEND_TEST(BitmapTests, MemoryManagement);
|
79
|
+
#endif
|
80
|
+
};
|
81
|
+
|
82
|
+
/// Loads any supported image into a Bitmap.
|
83
|
+
Bitmap load_image_file(const std::string& filename);
|
84
|
+
/// Loads any supported image into a Bitmap.
|
85
|
+
Bitmap load_image_file(Reader input);
|
86
|
+
|
87
|
+
/// Saves a Bitmap to a file.
|
88
|
+
void save_image_file(const Bitmap& bitmap, const std::string& filename);
|
89
|
+
/// Saves a Bitmap to an arbitrary resource.
|
90
|
+
void save_image_file(const Bitmap& bitmap, Writer writer,
|
91
|
+
const std::string_view& format_hint = "png");
|
92
|
+
|
93
|
+
/// Set the alpha value of all pixels which are equal to the color key to zero.
|
94
|
+
/// To reduce interpolation artefacts when stretching or rotating the resulting image, the color
|
95
|
+
/// value of these pixels will also be adjusted to the average of their surrounding pixels.
|
96
|
+
void apply_color_key(Bitmap& bitmap, Color key);
|
97
|
+
|
98
|
+
Bitmap apply_border_flags(unsigned image_flags, const Bitmap& source,
|
99
|
+
int src_x, int src_y, int src_width, int src_height);
|
100
|
+
}
|
@@ -51,6 +51,9 @@ namespace Gosu
|
|
51
51
|
KB_DOWN = 81,
|
52
52
|
KB_HOME = 74,
|
53
53
|
KB_END = 77,
|
54
|
+
KB_PRINTSCREEN = 70,
|
55
|
+
KB_SCROLLLOCK = 71,
|
56
|
+
KB_PAUSE = 72,
|
54
57
|
KB_INSERT = 73,
|
55
58
|
KB_DELETE = 76,
|
56
59
|
KB_PAGE_UP = 75,
|
@@ -67,6 +70,7 @@ namespace Gosu
|
|
67
70
|
KB_COMMA = 54,
|
68
71
|
KB_PERIOD = 55,
|
69
72
|
KB_SLASH = 56,
|
73
|
+
KB_CAPSLOCK = 57,
|
70
74
|
KB_A = 4,
|
71
75
|
KB_B = 5,
|
72
76
|
KB_C = 6,
|
@@ -126,12 +130,12 @@ namespace Gosu
|
|
126
130
|
MS_OTHER_6,
|
127
131
|
MS_OTHER_7,
|
128
132
|
MS_RANGE_END = 0x110,
|
129
|
-
|
133
|
+
|
130
134
|
GP_RANGE_BEGIN,
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
+
GP_DPAD_LEFT = GP_RANGE_BEGIN,
|
136
|
+
GP_DPAD_RIGHT,
|
137
|
+
GP_DPAD_UP,
|
138
|
+
GP_DPAD_DOWN,
|
135
139
|
GP_BUTTON_0,
|
136
140
|
GP_BUTTON_1,
|
137
141
|
GP_BUTTON_2,
|
@@ -149,10 +153,10 @@ namespace Gosu
|
|
149
153
|
GP_BUTTON_14,
|
150
154
|
GP_BUTTON_15,
|
151
155
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
+
GP_0_DPAD_LEFT,
|
157
|
+
GP_0_DPAD_RIGHT,
|
158
|
+
GP_0_DPAD_UP,
|
159
|
+
GP_0_DPAD_DOWN,
|
156
160
|
GP_0_BUTTON_0,
|
157
161
|
GP_0_BUTTON_1,
|
158
162
|
GP_0_BUTTON_2,
|
@@ -169,11 +173,11 @@ namespace Gosu
|
|
169
173
|
GP_0_BUTTON_13,
|
170
174
|
GP_0_BUTTON_14,
|
171
175
|
GP_0_BUTTON_15,
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
176
|
+
|
177
|
+
GP_1_DPAD_LEFT,
|
178
|
+
GP_1_DPAD_RIGHT,
|
179
|
+
GP_1_DPAD_UP,
|
180
|
+
GP_1_DPAD_DOWN,
|
177
181
|
GP_1_BUTTON_0,
|
178
182
|
GP_1_BUTTON_1,
|
179
183
|
GP_1_BUTTON_2,
|
@@ -190,11 +194,11 @@ namespace Gosu
|
|
190
194
|
GP_1_BUTTON_13,
|
191
195
|
GP_1_BUTTON_14,
|
192
196
|
GP_1_BUTTON_15,
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
197
|
+
|
198
|
+
GP_2_DPAD_LEFT,
|
199
|
+
GP_2_DPAD_RIGHT,
|
200
|
+
GP_2_DPAD_UP,
|
201
|
+
GP_2_DPAD_DOWN,
|
198
202
|
GP_2_BUTTON_0,
|
199
203
|
GP_2_BUTTON_1,
|
200
204
|
GP_2_BUTTON_2,
|
@@ -211,11 +215,11 @@ namespace Gosu
|
|
211
215
|
GP_2_BUTTON_13,
|
212
216
|
GP_2_BUTTON_14,
|
213
217
|
GP_2_BUTTON_15,
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
218
|
+
|
219
|
+
GP_3_DPAD_LEFT,
|
220
|
+
GP_3_DPAD_RIGHT,
|
221
|
+
GP_3_DPAD_UP,
|
222
|
+
GP_3_DPAD_DOWN,
|
219
223
|
GP_3_BUTTON_0,
|
220
224
|
GP_3_BUTTON_1,
|
221
225
|
GP_3_BUTTON_2,
|
@@ -232,16 +236,71 @@ namespace Gosu
|
|
232
236
|
GP_3_BUTTON_13,
|
233
237
|
GP_3_BUTTON_14,
|
234
238
|
GP_3_BUTTON_15,
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
239
|
+
|
240
|
+
GP_LEFT,
|
241
|
+
GP_RIGHT,
|
242
|
+
GP_UP,
|
243
|
+
GP_DOWN,
|
244
|
+
|
245
|
+
GP_0_LEFT,
|
246
|
+
GP_0_RIGHT,
|
247
|
+
GP_0_UP,
|
248
|
+
GP_0_DOWN,
|
249
|
+
|
250
|
+
GP_1_LEFT,
|
251
|
+
GP_1_RIGHT,
|
252
|
+
GP_1_UP,
|
253
|
+
GP_1_DOWN,
|
254
|
+
|
255
|
+
GP_2_LEFT,
|
256
|
+
GP_2_RIGHT,
|
257
|
+
GP_2_UP,
|
258
|
+
GP_2_DOWN,
|
259
|
+
|
260
|
+
GP_3_LEFT,
|
261
|
+
GP_3_RIGHT,
|
262
|
+
GP_3_UP,
|
263
|
+
GP_3_DOWN,
|
264
|
+
GP_RANGE_END = GP_3_DOWN,
|
265
|
+
|
266
|
+
GP_AXES_RANGE_BEGIN,
|
267
|
+
GP_LEFT_STICK_X_AXIS = GP_AXES_RANGE_BEGIN,
|
268
|
+
GP_LEFT_STICK_Y_AXIS,
|
269
|
+
GP_RIGHT_STICK_X_AXIS,
|
270
|
+
GP_RIGHT_STICK_Y_AXIS,
|
271
|
+
GP_LEFT_TRIGGER_AXIS,
|
272
|
+
GP_RIGHT_TRIGGER_AXIS,
|
273
|
+
|
274
|
+
GP_0_LEFT_STICK_X_AXIS,
|
275
|
+
GP_0_LEFT_STICK_Y_AXIS,
|
276
|
+
GP_0_RIGHT_STICK_X_AXIS,
|
277
|
+
GP_0_RIGHT_STICK_Y_AXIS,
|
278
|
+
GP_0_LEFT_TRIGGER_AXIS,
|
279
|
+
GP_0_RIGHT_TRIGGER_AXIS,
|
280
|
+
|
281
|
+
GP_1_LEFT_STICK_X_AXIS,
|
282
|
+
GP_1_LEFT_STICK_Y_AXIS,
|
283
|
+
GP_1_RIGHT_STICK_X_AXIS,
|
284
|
+
GP_1_RIGHT_STICK_Y_AXIS,
|
285
|
+
GP_1_LEFT_TRIGGER_AXIS,
|
286
|
+
GP_1_RIGHT_TRIGGER_AXIS,
|
287
|
+
|
288
|
+
GP_2_LEFT_STICK_X_AXIS,
|
289
|
+
GP_2_LEFT_STICK_Y_AXIS,
|
290
|
+
GP_2_RIGHT_STICK_X_AXIS,
|
291
|
+
GP_2_RIGHT_STICK_Y_AXIS,
|
292
|
+
GP_2_LEFT_TRIGGER_AXIS,
|
293
|
+
GP_2_RIGHT_TRIGGER_AXIS,
|
294
|
+
|
295
|
+
GP_3_LEFT_STICK_X_AXIS,
|
296
|
+
GP_3_LEFT_STICK_Y_AXIS,
|
297
|
+
GP_3_RIGHT_STICK_X_AXIS,
|
298
|
+
GP_3_RIGHT_STICK_Y_AXIS,
|
299
|
+
GP_3_LEFT_TRIGGER_AXIS,
|
300
|
+
GP_3_RIGHT_TRIGGER_AXIS,
|
301
|
+
GP_AXES_RANGE_END = GP_3_RIGHT_TRIGGER_AXIS,
|
302
|
+
|
303
|
+
NUM_GAMEPADS = 4,
|
304
|
+
NO_BUTTON = 0xffffffff,
|
246
305
|
};
|
247
306
|
}
|
File without changes
|
File without changes
|