gosu 1.4.6 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/COPYING +2 -1
- data/dependencies/SDL/include/SDL3/SDL.h +91 -0
- data/dependencies/SDL/include/SDL3/SDL_assert.h +710 -0
- data/dependencies/SDL/include/SDL3/SDL_asyncio.h +550 -0
- data/dependencies/SDL/include/SDL3/SDL_atomic.h +692 -0
- data/dependencies/SDL/include/SDL3/SDL_audio.h +2382 -0
- data/dependencies/SDL/include/SDL3/SDL_begin_code.h +553 -0
- data/dependencies/SDL/include/{SDL_bits.h → SDL3/SDL_bits.h} +47 -27
- data/dependencies/SDL/include/{SDL_blendmode.h → SDL3/SDL_blendmode.h} +59 -55
- data/dependencies/SDL/include/SDL3/SDL_camera.h +535 -0
- data/dependencies/SDL/include/SDL3/SDL_clipboard.h +331 -0
- data/dependencies/SDL/include/{close_code.h → SDL3/SDL_close_code.h} +9 -8
- data/dependencies/SDL/include/{SDL_types.h → SDL3/SDL_copying.h} +2 -9
- data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +374 -0
- data/dependencies/SDL/include/SDL3/SDL_dialog.h +343 -0
- data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +234 -0
- data/dependencies/SDL/include/{SDL_egl.h → SDL3/SDL_egl.h} +11 -8
- data/dependencies/SDL/include/SDL3/SDL_endian.h +645 -0
- data/dependencies/SDL/include/SDL3/SDL_error.h +226 -0
- data/dependencies/SDL/include/SDL3/SDL_events.h +1651 -0
- data/dependencies/SDL/include/SDL3/SDL_filesystem.h +537 -0
- data/dependencies/SDL/include/SDL3/SDL_gamepad.h +1657 -0
- data/dependencies/SDL/include/SDL3/SDL_gpu.h +4637 -0
- data/dependencies/SDL/include/SDL3/SDL_guid.h +106 -0
- data/dependencies/SDL/include/SDL3/SDL_haptic.h +1461 -0
- data/dependencies/SDL/include/SDL3/SDL_hidapi.h +571 -0
- data/dependencies/SDL/include/SDL3/SDL_hints.h +5041 -0
- data/dependencies/SDL/include/SDL3/SDL_init.h +508 -0
- data/dependencies/SDL/include/SDL3/SDL_intrin.h +410 -0
- data/dependencies/SDL/include/SDL3/SDL_iostream.h +1379 -0
- data/dependencies/SDL/include/SDL3/SDL_joystick.h +1385 -0
- data/dependencies/SDL/include/SDL3/SDL_keyboard.h +615 -0
- data/dependencies/SDL/include/SDL3/SDL_keycode.h +348 -0
- data/dependencies/SDL/include/SDL3/SDL_loadso.h +145 -0
- data/dependencies/SDL/include/{SDL_locale.h → SDL3/SDL_locale.h} +40 -24
- data/dependencies/SDL/include/SDL3/SDL_log.h +541 -0
- data/dependencies/SDL/include/SDL3/SDL_main.h +704 -0
- data/dependencies/SDL/include/SDL3/SDL_main_impl.h +149 -0
- data/dependencies/SDL/include/{SDL_messagebox.h → SDL3/SDL_messagebox.h} +85 -48
- data/dependencies/SDL/include/{SDL_metal.h → SDL3/SDL_metal.h} +29 -29
- data/dependencies/SDL/include/{SDL_misc.h → SDL3/SDL_misc.h} +13 -12
- data/dependencies/SDL/include/SDL3/SDL_mouse.h +813 -0
- data/dependencies/SDL/include/SDL3/SDL_mutex.h +1117 -0
- data/dependencies/SDL/include/SDL3/SDL_oldnames.h +1339 -0
- data/dependencies/SDL/include/{SDL_opengl.h → SDL3/SDL_opengl.h} +1247 -278
- data/dependencies/SDL/include/{SDL_opengl_glext.h → SDL3/SDL_opengl_glext.h} +5 -1
- data/dependencies/SDL/include/{SDL_opengles.h → SDL3/SDL_opengles.h} +6 -7
- data/dependencies/SDL/include/{SDL_opengles2.h → SDL3/SDL_opengles2.h} +10 -11
- data/dependencies/SDL/include/SDL3/SDL_pen.h +198 -0
- data/dependencies/SDL/include/SDL3/SDL_pixels.h +1441 -0
- data/dependencies/SDL/include/{SDL_test_log.h → SDL3/SDL_platform.h} +25 -26
- data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +497 -0
- data/dependencies/SDL/include/{SDL_power.h → SDL3/SDL_power.h} +40 -20
- data/dependencies/SDL/include/SDL3/SDL_process.h +441 -0
- data/dependencies/SDL/include/SDL3/SDL_properties.h +572 -0
- data/dependencies/SDL/include/SDL3/SDL_rect.h +528 -0
- data/dependencies/SDL/include/SDL3/SDL_render.h +3034 -0
- data/dependencies/SDL/include/SDL3/SDL_revision.h +56 -0
- data/dependencies/SDL/include/{SDL_scancode.h → SDL3/SDL_scancode.h} +60 -68
- data/dependencies/SDL/include/SDL3/SDL_sensor.h +321 -0
- data/dependencies/SDL/include/SDL3/SDL_stdinc.h +6186 -0
- data/dependencies/SDL/include/SDL3/SDL_storage.h +686 -0
- data/dependencies/SDL/include/SDL3/SDL_surface.h +1769 -0
- data/dependencies/SDL/include/SDL3/SDL_system.h +840 -0
- data/dependencies/SDL/include/{SDL_test.h → SDL3/SDL_test.h} +16 -22
- data/dependencies/SDL/include/{SDL_test_assert.h → SDL3/SDL_test_assert.h} +27 -34
- data/dependencies/SDL/include/{SDL_test_common.h → SDL3/SDL_test_common.h} +109 -52
- data/dependencies/SDL/include/{SDL_test_compare.h → SDL3/SDL_test_compare.h} +22 -14
- data/dependencies/SDL/include/{SDL_test_crc32.h → SDL3/SDL_test_crc32.h} +27 -30
- data/dependencies/SDL/include/{SDL_test_font.h → SDL3/SDL_test_font.h} +50 -49
- data/dependencies/SDL/include/{SDL_test_fuzzer.h → SDL3/SDL_test_fuzzer.h} +64 -79
- data/dependencies/SDL/include/{SDL_test_harness.h → SDL3/SDL_test_harness.h} +47 -30
- data/dependencies/SDL/include/SDL3/SDL_test_log.h +83 -0
- data/dependencies/SDL/include/{SDL_test_md5.h → SDL3/SDL_test_md5.h} +21 -28
- data/dependencies/SDL/include/{SDL_test_memory.h → SDL3/SDL_test_memory.h} +19 -16
- data/dependencies/SDL/include/SDL3/SDL_thread.h +602 -0
- data/dependencies/SDL/include/SDL3/SDL_time.h +249 -0
- data/dependencies/SDL/include/SDL3/SDL_timer.h +454 -0
- data/dependencies/SDL/include/SDL3/SDL_touch.h +184 -0
- data/dependencies/SDL/include/SDL3/SDL_tray.h +544 -0
- data/dependencies/SDL/include/SDL3/SDL_version.h +198 -0
- data/dependencies/SDL/include/SDL3/SDL_video.h +3497 -0
- data/dependencies/SDL/include/SDL3/SDL_vulkan.h +287 -0
- data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
- data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +755 -0
- data/dependencies/SDL_sound/SDL_sound.c +136 -215
- data/dependencies/SDL_sound/SDL_sound_aiff.c +55 -54
- data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +24 -41
- data/dependencies/SDL_sound/SDL_sound_flac.c +32 -12
- data/dependencies/SDL_sound/SDL_sound_internal.h +33 -48
- data/dependencies/SDL_sound/SDL_sound_modplug.c +21 -29
- data/dependencies/SDL_sound/SDL_sound_mp3.c +35 -13
- data/dependencies/SDL_sound/SDL_sound_raw.c +14 -15
- data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
- data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +34 -25
- data/dependencies/SDL_sound/SDL_sound_wav.c +86 -82
- data/dependencies/SDL_sound/dr_flac.h +1890 -1301
- data/dependencies/SDL_sound/dr_mp3.h +1098 -660
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +5 -4
- data/dependencies/SDL_sound/libmodplug/load_ams.c +6 -3
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +2 -1
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
- data/dependencies/SDL_sound/libmodplug/modplug.h +2 -1
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
- data/dependencies/SDL_sound/libmodplug/sndfile.c +3 -0
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -3
- data/dependencies/SDL_sound/stb_vorbis.h +397 -342
- data/dependencies/mojoAL/AL/alc.h +2 -2
- data/dependencies/mojoAL/mojoal.c +2120 -1885
- data/dependencies/stb/stb_image.h +1190 -1379
- data/dependencies/stb/stb_image_write.h +329 -129
- data/dependencies/stb/stb_truetype.h +304 -60
- data/dependencies/utf8proc/utf8proc.c +133 -75
- data/dependencies/utf8proc/utf8proc.h +131 -50
- data/dependencies/utf8proc/utf8proc_data.h +16213 -15658
- data/ext/gosu-ffi/extconf.rb +103 -0
- data/ext/gosu-ffi/gosu-ffi.def +467 -0
- data/ffi/Gosu.cpp +330 -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 +176 -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 +160 -0
- data/ffi/Gosu_Font.cpp +97 -0
- data/ffi/Gosu_Font.h +32 -0
- data/ffi/Gosu_Image.cpp +239 -0
- data/ffi/Gosu_Image.h +71 -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 +29 -36
- 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 +53 -61
- data/include/Gosu/GraphicsBase.hpp +1 -11
- data/include/Gosu/Image.hpp +12 -15
- data/include/Gosu/Math.hpp +50 -72
- data/include/Gosu/Transform.hpp +32 -0
- data/include/Gosu/Utility.hpp +77 -1
- data/include/Gosu/Version.hpp +2 -2
- data/include/Gosu/Window.hpp +15 -9
- data/lib/SDL3.dll +0 -0
- data/lib/gosu/channel.rb +50 -0
- data/lib/gosu/color.rb +173 -0
- data/lib/gosu/compat.rb +130 -17
- data/lib/gosu/constants.rb +386 -0
- data/lib/gosu/ffi.rb +269 -0
- data/lib/gosu/font.rb +62 -0
- data/lib/gosu/gl_tex_info.rb +33 -0
- data/lib/gosu/gosu.rb +250 -0
- data/lib/gosu/image.rb +179 -0
- data/lib/gosu/numeric.rb +17 -0
- data/lib/gosu/preview.rb +6 -6
- data/lib/gosu/sample.rb +25 -0
- data/lib/gosu/song.rb +57 -0
- data/lib/gosu/text_input.rb +83 -0
- data/lib/gosu/window.rb +249 -0
- data/lib/gosu.rb +29 -8
- data/lib64/SDL3.dll +0 -0
- data/rdoc/gosu.rb +2 -2
- data/src/Audio.cpp +30 -24
- data/src/AudioFile.hpp +5 -4
- data/src/AudioFileAudioToolbox.cpp +8 -8
- data/src/AudioFileSDLSound.cpp +12 -15
- data/src/BinPacker.cpp +188 -0
- data/src/BinPacker.hpp +55 -0
- data/src/Bitmap.cpp +172 -143
- data/src/BitmapIO.cpp +60 -86
- data/src/Buffer.cpp +150 -0
- data/src/ClipRectStack.cpp +38 -0
- data/src/ClipRectStack.hpp +17 -83
- data/src/Color.cpp +75 -80
- data/src/Directories.cpp +47 -0
- data/src/DirectoriesUIKit.cpp +50 -0
- data/src/DrawOp.hpp +20 -18
- data/src/DrawOpQueue.hpp +27 -33
- 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 +13 -11
- data/src/GosuViewController.cpp +2 -10
- data/src/Graphics.cpp +86 -145
- data/src/GraphicsImpl.hpp +14 -68
- data/src/Image.cpp +41 -35
- data/src/Input.cpp +73 -78
- data/src/Macro.cpp +46 -29
- data/src/Macro.hpp +23 -17
- data/src/MarkupParser.cpp +5 -5
- data/src/Math.cpp +48 -22
- data/src/OffScreenTarget.cpp +47 -50
- data/src/OffScreenTarget.hpp +13 -11
- data/src/OpenGLContext.cpp +116 -0
- data/src/OpenGLContext.hpp +41 -0
- data/src/RenderState.hpp +49 -71
- data/src/Resolution.cpp +65 -53
- 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/TextInput.cpp +9 -9
- data/src/Texture.cpp +62 -80
- data/src/Texture.hpp +25 -23
- data/src/TiledDrawable.cpp +149 -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 +39 -32
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Utility.cpp +113 -37
- data/src/UtilityWin.cpp +49 -0
- data/src/Window.cpp +121 -151
- data/src/WindowUIKit.cpp +14 -14
- metadata +165 -118
- data/dependencies/SDL/include/SDL.h +0 -233
- data/dependencies/SDL/include/SDL_assert.h +0 -320
- data/dependencies/SDL/include/SDL_atomic.h +0 -415
- data/dependencies/SDL/include/SDL_audio.h +0 -1500
- data/dependencies/SDL/include/SDL_clipboard.h +0 -141
- data/dependencies/SDL/include/SDL_config.h +0 -331
- data/dependencies/SDL/include/SDL_cpuinfo.h +0 -594
- data/dependencies/SDL/include/SDL_endian.h +0 -348
- data/dependencies/SDL/include/SDL_error.h +0 -163
- data/dependencies/SDL/include/SDL_events.h +0 -1166
- data/dependencies/SDL/include/SDL_filesystem.h +0 -149
- data/dependencies/SDL/include/SDL_gamecontroller.h +0 -1074
- data/dependencies/SDL/include/SDL_gesture.h +0 -117
- data/dependencies/SDL/include/SDL_guid.h +0 -100
- data/dependencies/SDL/include/SDL_haptic.h +0 -1341
- data/dependencies/SDL/include/SDL_hidapi.h +0 -451
- data/dependencies/SDL/include/SDL_hints.h +0 -2569
- data/dependencies/SDL/include/SDL_joystick.h +0 -1066
- data/dependencies/SDL/include/SDL_keyboard.h +0 -353
- data/dependencies/SDL/include/SDL_keycode.h +0 -358
- data/dependencies/SDL/include/SDL_loadso.h +0 -115
- data/dependencies/SDL/include/SDL_log.h +0 -404
- data/dependencies/SDL/include/SDL_main.h +0 -275
- data/dependencies/SDL/include/SDL_mouse.h +0 -465
- data/dependencies/SDL/include/SDL_mutex.h +0 -471
- data/dependencies/SDL/include/SDL_name.h +0 -33
- data/dependencies/SDL/include/SDL_pixels.h +0 -644
- data/dependencies/SDL/include/SDL_platform.h +0 -261
- data/dependencies/SDL/include/SDL_quit.h +0 -58
- data/dependencies/SDL/include/SDL_rect.h +0 -376
- data/dependencies/SDL/include/SDL_render.h +0 -1919
- data/dependencies/SDL/include/SDL_revision.h +0 -7
- data/dependencies/SDL/include/SDL_rwops.h +0 -841
- data/dependencies/SDL/include/SDL_sensor.h +0 -322
- data/dependencies/SDL/include/SDL_shape.h +0 -155
- data/dependencies/SDL/include/SDL_stdinc.h +0 -830
- data/dependencies/SDL/include/SDL_surface.h +0 -997
- data/dependencies/SDL/include/SDL_system.h +0 -623
- data/dependencies/SDL/include/SDL_syswm.h +0 -386
- data/dependencies/SDL/include/SDL_test_images.h +0 -78
- data/dependencies/SDL/include/SDL_test_random.h +0 -115
- data/dependencies/SDL/include/SDL_thread.h +0 -464
- data/dependencies/SDL/include/SDL_timer.h +0 -222
- data/dependencies/SDL/include/SDL_touch.h +0 -150
- data/dependencies/SDL/include/SDL_version.h +0 -204
- data/dependencies/SDL/include/SDL_video.h +0 -2150
- data/dependencies/SDL/include/SDL_vulkan.h +0 -215
- data/dependencies/SDL/include/begin_code.h +0 -187
- 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 +0 -725
- data/ext/gosu/extconf.rb +0 -119
- data/include/Gosu/IO.hpp +0 -254
- data/include/Gosu/ImageData.hpp +0 -53
- data/include/Gosu/Inspection.hpp +0 -7
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/patches.rb +0 -66
- data/lib/gosu/run.rb +0 -20
- data/lib/gosu/swig_patches.rb +0 -110
- data/lib64/SDL2.dll +0 -0
- 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/dependencies/SDL/include/{SDL_opengles2_gl2.h → SDL3/SDL_opengles2_gl2.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_gl2ext.h → SDL3/SDL_opengles2_gl2ext.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_gl2platform.h → SDL3/SDL_opengles2_gl2platform.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_khrplatform.h → SDL3/SDL_opengles2_khrplatform.h} +0 -0
data/src/Graphics.cpp
CHANGED
|
@@ -1,51 +1,44 @@
|
|
|
1
|
-
#include <Gosu/Bitmap.hpp>
|
|
2
1
|
#include <Gosu/Graphics.hpp>
|
|
3
2
|
#include <Gosu/Image.hpp>
|
|
4
3
|
#include <Gosu/Utility.hpp>
|
|
5
4
|
#include "DrawOp.hpp"
|
|
6
5
|
#include "DrawOpQueue.hpp"
|
|
7
6
|
#include "GraphicsImpl.hpp"
|
|
8
|
-
#include "LargeImageData.hpp"
|
|
9
7
|
#include "Macro.hpp"
|
|
10
8
|
#include "OffScreenTarget.hpp"
|
|
11
|
-
#include "
|
|
12
|
-
#include <algorithm>
|
|
13
|
-
#include <cmath>
|
|
14
|
-
#include <functional>
|
|
9
|
+
#include "OpenGLContext.hpp"
|
|
15
10
|
#include <memory>
|
|
16
11
|
|
|
17
12
|
namespace Gosu
|
|
18
13
|
{
|
|
19
14
|
namespace
|
|
20
15
|
{
|
|
21
|
-
|
|
16
|
+
Viewport* current_viewport_pointer = nullptr;
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
Viewport& current_viewport()
|
|
24
19
|
{
|
|
25
|
-
if (
|
|
26
|
-
throw std::logic_error
|
|
20
|
+
if (current_viewport_pointer == nullptr) {
|
|
21
|
+
throw std::logic_error("Gosu::Graphics can only be drawn to while rendering");
|
|
27
22
|
}
|
|
28
|
-
return *
|
|
23
|
+
return *current_viewport_pointer;
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
std::vector<std::shared_ptr<Texture>> textures;
|
|
32
|
-
|
|
33
26
|
DrawOpQueueStack queues;
|
|
34
27
|
|
|
35
28
|
DrawOpQueue& current_queue()
|
|
36
29
|
{
|
|
37
30
|
if (queues.empty()) {
|
|
38
|
-
throw std::logic_error
|
|
31
|
+
throw std::logic_error("There is no rendering queue for this operation");
|
|
39
32
|
}
|
|
40
33
|
return queues.back();
|
|
41
34
|
}
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
37
|
|
|
45
|
-
struct Gosu::
|
|
38
|
+
struct Gosu::Viewport::Impl : private Gosu::Noncopyable
|
|
46
39
|
{
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
int virt_width = 0, virt_height = 0;
|
|
41
|
+
int phys_width = 0, phys_height = 0;
|
|
49
42
|
double black_width = 0.0, black_height = 0.0;
|
|
50
43
|
Transform base_transform;
|
|
51
44
|
|
|
@@ -57,9 +50,9 @@ struct Gosu::Graphics::Impl : private Gosu::Noncopyable
|
|
|
57
50
|
double scale_y = 1.0 * phys_height / virt_height;
|
|
58
51
|
double scale_factor = std::min(scale_x, scale_y);
|
|
59
52
|
|
|
60
|
-
Transform scale_transform = scale(scale_factor);
|
|
61
|
-
Transform translate_transform = translate(black_width, black_height);
|
|
62
|
-
base_transform =
|
|
53
|
+
Transform scale_transform = Transform::scale(scale_factor);
|
|
54
|
+
Transform translate_transform = Transform::translate(black_width, black_height);
|
|
55
|
+
base_transform = translate_transform * scale_transform;
|
|
63
56
|
}
|
|
64
57
|
|
|
65
58
|
#ifndef GOSU_IS_OPENGLES
|
|
@@ -93,8 +86,8 @@ struct Gosu::Graphics::Impl : private Gosu::Noncopyable
|
|
|
93
86
|
#endif
|
|
94
87
|
};
|
|
95
88
|
|
|
96
|
-
Gosu::
|
|
97
|
-
: m_impl(new Impl)
|
|
89
|
+
Gosu::Viewport::Viewport(int phys_width, int phys_height)
|
|
90
|
+
: m_impl(new Impl)
|
|
98
91
|
{
|
|
99
92
|
m_impl->virt_width = phys_width;
|
|
100
93
|
m_impl->virt_height = phys_height;
|
|
@@ -102,6 +95,7 @@ Gosu::Graphics::Graphics(unsigned phys_width, unsigned phys_height)
|
|
|
102
95
|
m_impl->black_height = 0;
|
|
103
96
|
|
|
104
97
|
// TODO: Should be merged into RenderState and removed from Graphics.
|
|
98
|
+
const OpenGLContext current_context;
|
|
105
99
|
glMatrixMode(GL_MODELVIEW);
|
|
106
100
|
glLoadIdentity();
|
|
107
101
|
glEnable(GL_BLEND);
|
|
@@ -109,29 +103,26 @@ Gosu::Graphics::Graphics(unsigned phys_width, unsigned phys_height)
|
|
|
109
103
|
set_physical_resolution(phys_width, phys_height);
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
Gosu::
|
|
106
|
+
Gosu::Viewport::~Viewport()
|
|
113
107
|
{
|
|
114
|
-
if (current_graphics_pointer == this) {
|
|
115
|
-
current_graphics_pointer = nullptr;
|
|
116
|
-
}
|
|
117
108
|
}
|
|
118
109
|
|
|
119
|
-
|
|
110
|
+
int Gosu::Viewport::width() const
|
|
120
111
|
{
|
|
121
112
|
return m_impl->virt_width;
|
|
122
113
|
}
|
|
123
114
|
|
|
124
|
-
|
|
115
|
+
int Gosu::Viewport::height() const
|
|
125
116
|
{
|
|
126
117
|
return m_impl->virt_height;
|
|
127
118
|
}
|
|
128
119
|
|
|
129
|
-
void Gosu::
|
|
120
|
+
void Gosu::Viewport::set_resolution(int virtual_width, int virtual_height,
|
|
130
121
|
double horizontal_black_bar_width,
|
|
131
122
|
double vertical_black_bar_height)
|
|
132
123
|
{
|
|
133
|
-
if (virtual_width
|
|
134
|
-
throw std::invalid_argument
|
|
124
|
+
if (virtual_width <= 0 || virtual_height <= 0) {
|
|
125
|
+
throw std::invalid_argument("Invalid virtual resolution.");
|
|
135
126
|
}
|
|
136
127
|
|
|
137
128
|
m_impl->virt_width = virtual_width;
|
|
@@ -142,10 +133,19 @@ void Gosu::Graphics::set_resolution(unsigned virtual_width, unsigned virtual_hei
|
|
|
142
133
|
m_impl->update_base_transform();
|
|
143
134
|
}
|
|
144
135
|
|
|
145
|
-
|
|
136
|
+
Gosu::Cleanup Gosu::Viewport::make_current()
|
|
137
|
+
{
|
|
138
|
+
auto result = finally([previous = current_viewport_pointer] {
|
|
139
|
+
current_viewport_pointer = previous;
|
|
140
|
+
});
|
|
141
|
+
current_viewport_pointer = this;
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
void Gosu::Viewport::frame(const std::function<void()>& f)
|
|
146
146
|
{
|
|
147
|
-
if (
|
|
148
|
-
throw std::logic_error
|
|
147
|
+
if (current_viewport_pointer != nullptr) {
|
|
148
|
+
throw std::logic_error("Cannot nest calls to Gosu::Graphics::frame()");
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// Cancel all recording or whatever that might still be in progress...
|
|
@@ -165,16 +165,19 @@ void Gosu::Graphics::frame(const std::function<void()>& f)
|
|
|
165
165
|
|
|
166
166
|
queues.back().set_base_transform(m_impl->base_transform);
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
const OpenGLContext current_context(true);
|
|
169
|
+
|
|
169
170
|
glClearColor(0, 0, 0, 1);
|
|
170
171
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
auto queue_cleanup = make_current();
|
|
173
174
|
|
|
174
175
|
f();
|
|
175
176
|
|
|
176
177
|
// Cancel all intermediate queues that have not been cleaned up.
|
|
177
|
-
while (queues.size() > 1)
|
|
178
|
+
while (queues.size() > 1) {
|
|
179
|
+
queues.pop_back();
|
|
180
|
+
}
|
|
178
181
|
|
|
179
182
|
flush();
|
|
180
183
|
|
|
@@ -194,9 +197,7 @@ void Gosu::Graphics::frame(const std::function<void()>& f)
|
|
|
194
197
|
flush();
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
current_graphics_pointer = nullptr;
|
|
200
|
+
queue_cleanup.perform();
|
|
200
201
|
|
|
201
202
|
// Clear leftover transforms, clip rects etc.
|
|
202
203
|
if (queues.size() == 1) {
|
|
@@ -208,61 +209,61 @@ void Gosu::Graphics::frame(const std::function<void()>& f)
|
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
void Gosu::
|
|
212
|
+
void Gosu::flush()
|
|
212
213
|
{
|
|
213
214
|
current_queue().perform_draw_ops_and_code();
|
|
214
215
|
current_queue().clear_queue();
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
void Gosu::
|
|
218
|
+
void Gosu::gl(const std::function<void()>& f)
|
|
218
219
|
{
|
|
219
220
|
if (current_queue().mode() == QM_RECORD_MACRO) {
|
|
220
|
-
throw std::logic_error
|
|
221
|
+
throw std::logic_error("Custom OpenGL is not allowed while creating a macro");
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
#ifdef GOSU_IS_OPENGLES
|
|
224
|
-
throw std::logic_error
|
|
225
|
+
throw std::logic_error("Custom OpenGL ES is not supported yet");
|
|
225
226
|
#else
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
Viewport& cg = current_viewport();
|
|
228
228
|
flush();
|
|
229
|
-
|
|
230
229
|
cg.m_impl->begin_gl();
|
|
231
|
-
|
|
230
|
+
const auto cleanup_gl = finally([&cg] { cg.m_impl->end_gl(); });
|
|
232
231
|
f();
|
|
233
|
-
|
|
234
|
-
cg.m_impl->end_gl();
|
|
235
232
|
#endif
|
|
236
233
|
}
|
|
237
234
|
|
|
238
|
-
void Gosu::
|
|
235
|
+
void Gosu::gl(Gosu::ZPos z, const std::function<void()>& f)
|
|
239
236
|
{
|
|
240
237
|
#ifdef GOSU_IS_OPENGLES
|
|
241
|
-
throw std::logic_error
|
|
238
|
+
throw std::logic_error("Custom OpenGL ES is not supported yet");
|
|
242
239
|
#else
|
|
243
240
|
const auto wrapped_f = [f] {
|
|
244
|
-
|
|
241
|
+
Viewport& cg = current_viewport();
|
|
245
242
|
cg.m_impl->begin_gl();
|
|
243
|
+
const auto cleanup_gl = finally([&cg] { cg.m_impl->end_gl(); });
|
|
246
244
|
f();
|
|
247
|
-
cg.m_impl->end_gl();
|
|
248
245
|
};
|
|
249
246
|
current_queue().gl(wrapped_f, z);
|
|
250
247
|
#endif
|
|
251
248
|
}
|
|
252
249
|
|
|
253
|
-
void Gosu::
|
|
254
|
-
const std::function<void()>& f)
|
|
250
|
+
void Gosu::clip_to(double x, double y, double width, double height, const std::function<void()>& f)
|
|
255
251
|
{
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
std::optional<int> viewport_height;
|
|
253
|
+
if (current_viewport_pointer) {
|
|
254
|
+
viewport_height = current_viewport_pointer->m_impl->phys_height;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
current_queue().begin_clipping(x, y, width, height, viewport_height);
|
|
258
|
+
const auto cleanup_cliprect = finally([] { current_queue().end_clipping(); });
|
|
259
|
+
|
|
258
260
|
f();
|
|
259
|
-
current_queue().end_clipping();
|
|
260
261
|
}
|
|
261
262
|
|
|
262
|
-
Gosu::Image Gosu::
|
|
263
|
-
|
|
263
|
+
Gosu::Image Gosu::render(int width, int height, const std::function<void()>& f,
|
|
264
|
+
unsigned image_flags)
|
|
264
265
|
{
|
|
265
|
-
|
|
266
|
+
const OpenGLContext current_context;
|
|
266
267
|
|
|
267
268
|
// Prepare for rendering at the requested size, but save the previous matrix and viewport.
|
|
268
269
|
glMatrixMode(GL_PROJECTION);
|
|
@@ -271,8 +272,8 @@ Gosu::Image Gosu::Graphics::render(int width, int height, const std::function<vo
|
|
|
271
272
|
GLint prev_viewport[4];
|
|
272
273
|
glGetIntegerv(GL_VIEWPORT, prev_viewport);
|
|
273
274
|
glViewport(0, 0, width, height);
|
|
274
|
-
// Note the flipped vertical axis in the glOrtho call
|
|
275
|
-
// flip the texture
|
|
275
|
+
// Note the flipped vertical axis in the glOrtho call, so we don't have to vertically
|
|
276
|
+
// flip the texture afterward.
|
|
276
277
|
#ifdef GOSU_IS_OPENGLES
|
|
277
278
|
glOrthof(0, width, 0, height, -1, 1); // NOLINT(readability-suspicious-call-argument)
|
|
278
279
|
#else
|
|
@@ -283,18 +284,15 @@ Gosu::Image Gosu::Graphics::render(int width, int height, const std::function<vo
|
|
|
283
284
|
Image result = OffScreenTarget(width, height, image_flags).render([&] {
|
|
284
285
|
#ifndef GOSU_IS_OPENGLES
|
|
285
286
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
|
287
|
+
const auto pop_attributes = finally([] { glPopAttrib(); });
|
|
286
288
|
#endif
|
|
287
289
|
glClearColor(0, 0, 0, 0);
|
|
288
290
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
289
291
|
glEnable(GL_BLEND);
|
|
290
292
|
queues.emplace_back(QM_RENDER_TO_TEXTURE);
|
|
293
|
+
const auto pop_queue = finally([&] { queues.pop_back(); });
|
|
291
294
|
f();
|
|
292
295
|
queues.back().perform_draw_ops_and_code();
|
|
293
|
-
queues.pop_back();
|
|
294
|
-
glFlush();
|
|
295
|
-
#ifndef GOSU_IS_OPENGLES
|
|
296
|
-
glPopAttrib();
|
|
297
|
-
#endif
|
|
298
296
|
});
|
|
299
297
|
|
|
300
298
|
// Restore previous matrix and glViewport.
|
|
@@ -305,27 +303,32 @@ Gosu::Image Gosu::Graphics::render(int width, int height, const std::function<vo
|
|
|
305
303
|
return result;
|
|
306
304
|
}
|
|
307
305
|
|
|
308
|
-
Gosu::Image Gosu::
|
|
306
|
+
Gosu::Image Gosu::record(int width, int height, const std::function<void()>& f)
|
|
309
307
|
{
|
|
310
308
|
queues.emplace_back(QM_RECORD_MACRO);
|
|
309
|
+
const auto pop_queue = finally([&] { queues.pop_back(); });
|
|
311
310
|
|
|
312
311
|
f();
|
|
313
312
|
|
|
314
|
-
std::unique_ptr<
|
|
315
|
-
|
|
316
|
-
return Image(move(result));
|
|
313
|
+
std::unique_ptr<Drawable> result(new Macro(current_queue(), width, height));
|
|
314
|
+
return Image(std::move(result));
|
|
317
315
|
}
|
|
318
316
|
|
|
319
|
-
void Gosu::
|
|
317
|
+
void Gosu::transform(const Gosu::Transform& transform, const std::function<void()>& f)
|
|
320
318
|
{
|
|
321
319
|
current_queue().push_transform(transform);
|
|
320
|
+
const auto pop_transform = finally([&] { current_queue().pop_transform(); });
|
|
321
|
+
|
|
322
322
|
f();
|
|
323
|
-
current_queue().pop_transform();
|
|
324
323
|
}
|
|
325
324
|
|
|
326
|
-
void Gosu::
|
|
325
|
+
void Gosu::draw_line(double x1, double y1, Color c1, double x2, double y2, Color c2,
|
|
327
326
|
ZPos z, BlendMode mode)
|
|
328
327
|
{
|
|
328
|
+
if (current_queue().mode() == QM_RECORD_MACRO) {
|
|
329
|
+
throw std::logic_error("Drawing lines is not allowed while recording a macro");
|
|
330
|
+
}
|
|
331
|
+
|
|
329
332
|
DrawOp op;
|
|
330
333
|
op.render_state.mode = mode;
|
|
331
334
|
op.vertices_or_block_index = 2;
|
|
@@ -336,7 +339,7 @@ void Gosu::Graphics::draw_line(double x1, double y1, Color c1, double x2, double
|
|
|
336
339
|
current_queue().schedule_draw_op(op);
|
|
337
340
|
}
|
|
338
341
|
|
|
339
|
-
void Gosu::
|
|
342
|
+
void Gosu::draw_triangle(double x1, double y1, Color c1, double x2, double y2, Color c2,
|
|
340
343
|
double x3, double y3, Color c3, ZPos z, BlendMode mode)
|
|
341
344
|
{
|
|
342
345
|
DrawOp op;
|
|
@@ -354,7 +357,7 @@ void Gosu::Graphics::draw_triangle(double x1, double y1, Color c1, double x2, do
|
|
|
354
357
|
current_queue().schedule_draw_op(op);
|
|
355
358
|
}
|
|
356
359
|
|
|
357
|
-
void Gosu::
|
|
360
|
+
void Gosu::draw_quad(double x1, double y1, Color c1, double x2, double y2, Color c2,
|
|
358
361
|
double x3, double y3, Color c3, double x4, double y4, Color c4,
|
|
359
362
|
ZPos z, BlendMode mode)
|
|
360
363
|
{
|
|
@@ -378,25 +381,26 @@ void Gosu::Graphics::draw_quad(double x1, double y1, Color c1, double x2, double
|
|
|
378
381
|
current_queue().schedule_draw_op(op);
|
|
379
382
|
}
|
|
380
383
|
|
|
381
|
-
void Gosu::
|
|
384
|
+
void Gosu::draw_rect(double x, double y, double width, double height, Color c, ZPos z,
|
|
382
385
|
Gosu::BlendMode mode)
|
|
383
386
|
{
|
|
384
387
|
draw_quad(x, y, c, x + width, y, c, x, y + height, c, x + width, y + height, c, z, mode);
|
|
385
388
|
}
|
|
386
389
|
|
|
387
|
-
void Gosu::
|
|
390
|
+
void Gosu::schedule_draw_op(const Gosu::DrawOp& op)
|
|
388
391
|
{
|
|
389
392
|
current_queue().schedule_draw_op(op);
|
|
390
393
|
}
|
|
391
394
|
|
|
392
|
-
void Gosu::
|
|
395
|
+
void Gosu::Viewport::set_physical_resolution(int phys_width, int phys_height)
|
|
393
396
|
{
|
|
394
397
|
m_impl->phys_width = phys_width;
|
|
395
398
|
m_impl->phys_height = phys_height;
|
|
396
399
|
// TODO: Should be merged into RenderState and removed from Graphics.
|
|
400
|
+
const OpenGLContext current_context;
|
|
397
401
|
glMatrixMode(GL_PROJECTION);
|
|
398
402
|
glLoadIdentity();
|
|
399
|
-
glViewport(0, 0, phys_width, phys_height);
|
|
403
|
+
glViewport(0, 0, static_cast<GLsizei>(phys_width), static_cast<GLsizei>(phys_height));
|
|
400
404
|
#ifdef GOSU_IS_OPENGLES
|
|
401
405
|
glOrthof(0, phys_width, phys_height, 0, -1, 1);
|
|
402
406
|
#else
|
|
@@ -405,66 +409,3 @@ void Gosu::Graphics::set_physical_resolution(unsigned phys_width, unsigned phys_
|
|
|
405
409
|
|
|
406
410
|
m_impl->update_base_transform();
|
|
407
411
|
}
|
|
408
|
-
|
|
409
|
-
std::unique_ptr<Gosu::ImageData> Gosu::Graphics::create_image(const Bitmap& src, unsigned src_x,
|
|
410
|
-
unsigned src_y, unsigned src_width,
|
|
411
|
-
unsigned src_height, unsigned flags)
|
|
412
|
-
{
|
|
413
|
-
static const unsigned max_size = MAX_TEXTURE_SIZE;
|
|
414
|
-
|
|
415
|
-
// Backward compatibility: This used to be 'bool tileable'.
|
|
416
|
-
if (flags == 1) flags = IF_TILEABLE;
|
|
417
|
-
|
|
418
|
-
bool wants_retro = (flags & IF_RETRO);
|
|
419
|
-
|
|
420
|
-
// Special case: If the texture is supposed to have hard borders, is
|
|
421
|
-
// quadratic, has a size that is at least 64 pixels but no more than max_size
|
|
422
|
-
// pixels and a power of two, create a single texture just for this image.
|
|
423
|
-
if ((flags & IF_TILEABLE) == IF_TILEABLE && src_width == src_height &&
|
|
424
|
-
(src_width & (src_width - 1)) == 0 && src_width >= 64 && src_width <= max_size) {
|
|
425
|
-
std::shared_ptr<Texture> texture{new Texture(src_width, src_height, wants_retro)};
|
|
426
|
-
std::unique_ptr<ImageData> data;
|
|
427
|
-
|
|
428
|
-
// Use the source bitmap directly if the source area completely covers
|
|
429
|
-
// it.
|
|
430
|
-
if (src_x == 0 && src_width == src.width() && src_y == 0 && src_height == src.height()) {
|
|
431
|
-
data = texture->try_alloc(src, 0);
|
|
432
|
-
}
|
|
433
|
-
else {
|
|
434
|
-
Bitmap bmp(src_width, src_height);
|
|
435
|
-
bmp.insert(0, 0, src, src_x, src_y, src_width, src_height);
|
|
436
|
-
data = texture->try_alloc(bmp, 0);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
if (!data) throw std::logic_error{"Internal texture block allocation error"};
|
|
440
|
-
return data;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// Too large to fit on a single texture.
|
|
444
|
-
if (src_width > max_size - 2 || src_height > max_size - 2) {
|
|
445
|
-
Bitmap bmp(src_width, src_height);
|
|
446
|
-
bmp.insert(0, 0, src, src_x, src_y, src_width, src_height);
|
|
447
|
-
return std::unique_ptr<ImageData>{
|
|
448
|
-
new LargeImageData(bmp, max_size - 2, max_size - 2, flags)};
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
Bitmap bmp = apply_border_flags(flags, src, src_x, src_y, src_width, src_height);
|
|
452
|
-
|
|
453
|
-
// Try to put the bitmap into one of the already allocated textures.
|
|
454
|
-
for (const auto& texture : textures) {
|
|
455
|
-
if (texture->retro() != wants_retro) continue;
|
|
456
|
-
|
|
457
|
-
std::unique_ptr<ImageData> data = texture->try_alloc(bmp, 1);
|
|
458
|
-
if (data) return data;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// All textures are full: Create a new one.
|
|
462
|
-
|
|
463
|
-
std::shared_ptr<Texture> texture{new Texture(max_size, max_size, wants_retro)};
|
|
464
|
-
textures.push_back(texture);
|
|
465
|
-
|
|
466
|
-
std::unique_ptr<ImageData> data{texture->try_alloc(bmp, 1)};
|
|
467
|
-
if (!data.get()) throw std::logic_error("Internal texture block allocation error");
|
|
468
|
-
|
|
469
|
-
return data;
|
|
470
|
-
}
|
data/src/GraphicsImpl.hpp
CHANGED
|
@@ -3,16 +3,8 @@
|
|
|
3
3
|
#include <Gosu/Bitmap.hpp>
|
|
4
4
|
#include <Gosu/Graphics.hpp>
|
|
5
5
|
#include <Gosu/Platform.hpp>
|
|
6
|
-
|
|
7
|
-
#if defined(GOSU_IS_IPHONE) || defined(GOSU_IS_OPENGLES)
|
|
8
|
-
#include <OpenGLES/ES1/gl.h>
|
|
9
|
-
#include <OpenGLES/ES1/glext.h>
|
|
10
|
-
#else
|
|
11
|
-
#include <SDL.h>
|
|
12
|
-
#include <SDL_opengl.h>
|
|
13
|
-
#endif
|
|
14
|
-
|
|
15
6
|
#include <algorithm>
|
|
7
|
+
#include <cstdint>
|
|
16
8
|
#include <list>
|
|
17
9
|
#include <vector>
|
|
18
10
|
|
|
@@ -21,27 +13,6 @@ namespace Gosu
|
|
|
21
13
|
struct RenderState;
|
|
22
14
|
class RenderStateManager;
|
|
23
15
|
|
|
24
|
-
const GLuint NO_TEXTURE = static_cast<GLuint>(-1);
|
|
25
|
-
const unsigned NO_CLIPPING = 0xffffffff;
|
|
26
|
-
|
|
27
|
-
// In various places in Gosu, width==NO_CLIPPING by convention means
|
|
28
|
-
// that no clipping should happen.
|
|
29
|
-
struct ClipRect
|
|
30
|
-
{
|
|
31
|
-
double x, y, width, height;
|
|
32
|
-
|
|
33
|
-
bool operator==(const ClipRect& other) const
|
|
34
|
-
{
|
|
35
|
-
// No clipping
|
|
36
|
-
return (width == NO_CLIPPING && other.width == NO_CLIPPING) ||
|
|
37
|
-
// Clipping, but same
|
|
38
|
-
(x == other.x && y == other.y && width == other.width && height == other.height);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
namespace Gosu
|
|
44
|
-
{
|
|
45
16
|
enum QueueMode
|
|
46
17
|
{
|
|
47
18
|
QM_RENDER_TO_SCREEN,
|
|
@@ -56,59 +27,34 @@ namespace Gosu
|
|
|
56
27
|
class DrawOpQueue;
|
|
57
28
|
typedef std::list<Transform> Transforms;
|
|
58
29
|
typedef std::list<DrawOpQueue> DrawOpQueueStack;
|
|
59
|
-
class LargeImageData;
|
|
60
|
-
class Macro;
|
|
61
30
|
struct ArrayVertex
|
|
62
31
|
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
32
|
+
float tex_coords[2];
|
|
33
|
+
std::uint32_t color;
|
|
34
|
+
float vertices[3];
|
|
66
35
|
};
|
|
67
|
-
|
|
36
|
+
|
|
68
37
|
template<typename T>
|
|
69
38
|
bool is_p_to_the_left_of_ab(T xa, T ya, T xb, T yb, T xp, T yp)
|
|
70
39
|
{
|
|
71
40
|
return (xb - xa) * (yp - ya) - (xp - xa) * (yb - ya) > 0;
|
|
72
41
|
}
|
|
73
|
-
|
|
42
|
+
|
|
74
43
|
template<typename T, typename C>
|
|
75
44
|
void normalize_coordinates(T& x1, T& y1, T& x2, T& y2, T& x3, T& y3, C& c3, T& x4, T& y4, C& c4)
|
|
76
45
|
{
|
|
77
46
|
if (is_p_to_the_left_of_ab(x1, y1, x2, y2, x3, y3) ==
|
|
78
47
|
is_p_to_the_left_of_ab(x2, y2, x3, y3, x4, y4)) {
|
|
79
|
-
|
|
80
|
-
swap(
|
|
81
|
-
swap(
|
|
82
|
-
swap(c3, c4);
|
|
48
|
+
std::swap(x3, x4);
|
|
49
|
+
std::swap(y3, y4);
|
|
50
|
+
std::swap(c3, c4);
|
|
83
51
|
}
|
|
84
52
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Float out[4] = { 0, 0, 0, 0 };
|
|
91
|
-
for (int i = 0; i < 4; ++i) {
|
|
92
|
-
for (int j = 0; j < 4; ++j) {
|
|
93
|
-
out[i] += in[j] * transform[j * 4 + i];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
x = out[0] / out[3];
|
|
97
|
-
y = out[1] / out[3];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
#ifdef GOSU_IS_IPHONE
|
|
101
|
-
int clip_rect_base_factor();
|
|
102
|
-
#else
|
|
103
|
-
inline int clip_rect_base_factor() { return 1; }
|
|
104
|
-
#endif
|
|
105
|
-
|
|
106
|
-
#ifndef GOSU_IS_IPHONE
|
|
107
|
-
SDL_Window* shared_window();
|
|
108
|
-
#endif
|
|
109
|
-
|
|
110
|
-
void ensure_current_context();
|
|
111
|
-
|
|
53
|
+
|
|
54
|
+
void schedule_draw_op(const DrawOp& op);
|
|
55
|
+
|
|
56
|
+
void register_frame();
|
|
57
|
+
|
|
112
58
|
inline std::string escape_markup(const std::string& text) {
|
|
113
59
|
auto markup = text;
|
|
114
60
|
for (std::string::size_type pos = 0; pos < markup.length(); ++pos) {
|