gosu 0.7.45 → 0.7.46
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +6 -11
- data/Gosu/{ButtonsWin.hpp → Buttons.hpp} +91 -4
- data/Gosu/ButtonsMac.hpp +91 -4
- data/Gosu/Graphics.hpp +10 -0
- data/Gosu/ImageData.hpp +1 -0
- data/Gosu/Input.hpp +2 -3
- data/Gosu/Version.hpp +2 -2
- data/Gosu/Window.hpp +1 -1
- data/GosuImpl/Audio/AudioToolboxFile.hpp +4 -0
- data/GosuImpl/Graphics/BitmapApple.mm +5 -11
- data/GosuImpl/Graphics/ClipRectStack.hpp +2 -2
- data/GosuImpl/Graphics/Common.hpp +1 -1
- data/GosuImpl/Graphics/DrawOpQueue.hpp +30 -29
- data/GosuImpl/Graphics/Graphics.cpp +2 -3
- data/GosuImpl/Graphics/TextMac.cpp +9 -5
- data/GosuImpl/Graphics/TextTouch.mm +8 -4
- data/GosuImpl/Graphics/Texture.cpp +4 -1
- data/GosuImpl/InputMac.mm +24 -45
- data/GosuImpl/InputX.cpp +25 -39
- data/GosuImpl/RubyGosu.swg +11 -0
- data/GosuImpl/RubyGosu_wrap.cxx +109 -40
- data/GosuImpl/RubyGosu_wrap.h +1 -1
- data/GosuImpl/TextInputWin.cpp +1 -1
- data/GosuImpl/TextInputX.cpp +3 -1
- data/GosuImpl/WinMain.cpp +3 -4
- data/GosuImpl/WindowMac.mm +83 -73
- data/GosuImpl/WindowWin.cpp +65 -58
- data/dependencies/libogg/AUTHORS +4 -0
- data/dependencies/libogg/CHANGES +70 -0
- data/dependencies/libogg/COPYING +28 -0
- data/dependencies/libogg/include/ogg/ogg.h +209 -0
- data/dependencies/libogg/include/ogg/os_types.h +147 -0
- data/dependencies/libogg/src/bitwise.c +857 -0
- data/dependencies/libogg/src/framing.c +2089 -0
- data/dependencies/libvorbis/AUTHORS +3 -0
- data/dependencies/libvorbis/CHANGES +126 -0
- data/dependencies/libvorbis/COPYING +28 -0
- data/dependencies/libvorbis/include/vorbis/codec.h +243 -0
- data/dependencies/libvorbis/include/vorbis/vorbisenc.h +436 -0
- data/dependencies/libvorbis/include/vorbis/vorbisfile.h +206 -0
- data/dependencies/libvorbis/lib/analysis.c +120 -0
- data/dependencies/libvorbis/lib/backends.h +144 -0
- data/dependencies/libvorbis/lib/barkmel.c +64 -0
- data/dependencies/libvorbis/lib/bitrate.c +253 -0
- data/dependencies/libvorbis/lib/bitrate.h +59 -0
- data/dependencies/libvorbis/lib/block.c +1046 -0
- data/dependencies/libvorbis/lib/books/coupled/res_books_51.h +12257 -0
- data/dependencies/libvorbis/lib/books/coupled/res_books_stereo.h +15783 -0
- data/dependencies/libvorbis/lib/books/floor/floor_books.h +1547 -0
- data/dependencies/libvorbis/lib/books/uncoupled/res_books_uncoupled.h +7758 -0
- data/dependencies/libvorbis/lib/codebook.c +479 -0
- data/dependencies/libvorbis/lib/codebook.h +119 -0
- data/dependencies/libvorbis/lib/codec_internal.h +167 -0
- data/dependencies/libvorbis/lib/envelope.c +375 -0
- data/dependencies/libvorbis/lib/envelope.h +80 -0
- data/dependencies/libvorbis/lib/floor0.c +222 -0
- data/dependencies/libvorbis/lib/floor1.c +1099 -0
- data/dependencies/libvorbis/lib/highlevel.h +58 -0
- data/dependencies/libvorbis/lib/info.c +664 -0
- data/dependencies/libvorbis/lib/lookup.c +94 -0
- data/dependencies/libvorbis/lib/lookup.h +32 -0
- data/dependencies/libvorbis/lib/lookup_data.h +192 -0
- data/dependencies/libvorbis/lib/lpc.c +160 -0
- data/dependencies/libvorbis/lib/lpc.h +29 -0
- data/dependencies/libvorbis/lib/lsp.c +456 -0
- data/dependencies/libvorbis/lib/lsp.h +28 -0
- data/dependencies/libvorbis/lib/mapping0.c +816 -0
- data/dependencies/libvorbis/lib/masking.h +785 -0
- data/dependencies/libvorbis/lib/mdct.c +563 -0
- data/dependencies/libvorbis/lib/mdct.h +71 -0
- data/dependencies/libvorbis/lib/misc.h +57 -0
- data/dependencies/libvorbis/lib/modes/floor_all.h +260 -0
- data/dependencies/libvorbis/lib/modes/psych_11.h +51 -0
- data/dependencies/libvorbis/lib/modes/psych_16.h +133 -0
- data/dependencies/libvorbis/lib/modes/psych_44.h +642 -0
- data/dependencies/libvorbis/lib/modes/psych_8.h +101 -0
- data/dependencies/libvorbis/lib/modes/residue_16.h +163 -0
- data/dependencies/libvorbis/lib/modes/residue_44.h +292 -0
- data/dependencies/libvorbis/lib/modes/residue_44p51.h +451 -0
- data/dependencies/libvorbis/lib/modes/residue_44u.h +318 -0
- data/dependencies/libvorbis/lib/modes/residue_8.h +109 -0
- data/dependencies/libvorbis/lib/modes/setup_11.h +143 -0
- data/dependencies/libvorbis/lib/modes/setup_16.h +153 -0
- data/dependencies/libvorbis/lib/modes/setup_22.h +128 -0
- data/dependencies/libvorbis/lib/modes/setup_32.h +132 -0
- data/dependencies/libvorbis/lib/modes/setup_44.h +117 -0
- data/dependencies/libvorbis/lib/modes/setup_44p51.h +74 -0
- data/dependencies/libvorbis/lib/modes/setup_44u.h +74 -0
- data/dependencies/libvorbis/lib/modes/setup_8.h +149 -0
- data/dependencies/libvorbis/lib/modes/setup_X.h +225 -0
- data/dependencies/libvorbis/lib/os.h +186 -0
- data/dependencies/libvorbis/lib/psy.c +1203 -0
- data/dependencies/libvorbis/lib/psy.h +154 -0
- data/dependencies/libvorbis/lib/psytune.c +524 -0
- data/dependencies/libvorbis/lib/registry.c +45 -0
- data/dependencies/libvorbis/lib/registry.h +32 -0
- data/dependencies/libvorbis/lib/res0.c +889 -0
- data/dependencies/libvorbis/lib/scales.h +90 -0
- data/dependencies/libvorbis/lib/sharedbook.c +579 -0
- data/dependencies/libvorbis/lib/smallft.c +1255 -0
- data/dependencies/libvorbis/lib/smallft.h +34 -0
- data/dependencies/libvorbis/lib/synthesis.c +184 -0
- data/dependencies/libvorbis/lib/tone.c +54 -0
- data/dependencies/libvorbis/lib/vorbisenc.c +1215 -0
- data/dependencies/libvorbis/lib/vorbisfile.c +2337 -0
- data/dependencies/libvorbis/lib/window.c +2135 -0
- data/dependencies/libvorbis/lib/window.h +26 -0
- data/dependencies/ogg_vorbis.license +28 -0
- data/lib/gosu/swig_patches.rb +2 -2
- data/linux/extconf.rb +17 -3
- metadata +96 -17
- data/Gosu/ButtonsX.hpp +0 -141
- data/GosuImpl/Audio/AudioSDL.cpp +0 -315
data/COPYING
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (C) 2004-
|
1
|
+
Copyright (C) 2004-2013 Julian Raschke, Jan Lücker and all contributors.
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a
|
4
4
|
copy of this software and associated documentation files (the "Software"),
|
@@ -18,17 +18,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
18
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
19
19
|
DEALINGS IN THE SOFTWARE.
|
20
20
|
|
21
|
-
|
22
|
-
Jan Lücker jan.luecker@gmx.de
|
21
|
+
Julian Raschke <julian@raschke.de> & contributors
|
23
22
|
http://www.libgosu.org/
|
24
23
|
|
25
24
|
***
|
26
25
|
|
27
|
-
This does NOT apply to
|
28
|
-
Gosu.
|
29
|
-
|
30
|
-
|
31
|
-
This does also NOT apply to libogg and libvorbis, which are included in
|
32
|
-
all source and binary distributions of Gosu, sometimes via audiere. These
|
33
|
-
projects are licensed under a BSD-like license, and their copyright terms
|
34
|
-
need to be supplied even with binary redistributions (e.g. Gosu games).
|
26
|
+
This does NOT apply to libogg and libvorbis, which are included in all source
|
27
|
+
and binary distributions of Gosu. These projects are licensed under a BSD-like
|
28
|
+
license, and their copyright terms need to be supplied even with binary
|
29
|
+
redistributions (e.g. Gosu games).
|
@@ -126,14 +126,101 @@ namespace Gosu
|
|
126
126
|
gpButton13,
|
127
127
|
gpButton14,
|
128
128
|
gpButton15,
|
129
|
-
|
129
|
+
|
130
|
+
gp0Left,
|
131
|
+
gp0Right,
|
132
|
+
gp0Up,
|
133
|
+
gp0Down,
|
134
|
+
gp0Button0,
|
135
|
+
gp0Button1,
|
136
|
+
gp0Button2,
|
137
|
+
gp0Button3,
|
138
|
+
gp0Button4,
|
139
|
+
gp0Button5,
|
140
|
+
gp0Button6,
|
141
|
+
gp0Button7,
|
142
|
+
gp0Button8,
|
143
|
+
gp0Button9,
|
144
|
+
gp0Button10,
|
145
|
+
gp0Button11,
|
146
|
+
gp0Button12,
|
147
|
+
gp0Button13,
|
148
|
+
gp0Button14,
|
149
|
+
gp0Button15,
|
150
|
+
|
151
|
+
gp1Left,
|
152
|
+
gp1Right,
|
153
|
+
gp1Up,
|
154
|
+
gp1Down,
|
155
|
+
gp1Button0,
|
156
|
+
gp1Button1,
|
157
|
+
gp1Button2,
|
158
|
+
gp1Button3,
|
159
|
+
gp1Button4,
|
160
|
+
gp1Button5,
|
161
|
+
gp1Button6,
|
162
|
+
gp1Button7,
|
163
|
+
gp1Button8,
|
164
|
+
gp1Button9,
|
165
|
+
gp1Button10,
|
166
|
+
gp1Button11,
|
167
|
+
gp1Button12,
|
168
|
+
gp1Button13,
|
169
|
+
gp1Button14,
|
170
|
+
gp1Button15,
|
171
|
+
|
172
|
+
gp2Left,
|
173
|
+
gp2Right,
|
174
|
+
gp2Up,
|
175
|
+
gp2Down,
|
176
|
+
gp2Button0,
|
177
|
+
gp2Button1,
|
178
|
+
gp2Button2,
|
179
|
+
gp2Button3,
|
180
|
+
gp2Button4,
|
181
|
+
gp2Button5,
|
182
|
+
gp2Button6,
|
183
|
+
gp2Button7,
|
184
|
+
gp2Button8,
|
185
|
+
gp2Button9,
|
186
|
+
gp2Button10,
|
187
|
+
gp2Button11,
|
188
|
+
gp2Button12,
|
189
|
+
gp2Button13,
|
190
|
+
gp2Button14,
|
191
|
+
gp2Button15,
|
192
|
+
|
193
|
+
gp3Left,
|
194
|
+
gp3Right,
|
195
|
+
gp3Up,
|
196
|
+
gp3Down,
|
197
|
+
gp3Button0,
|
198
|
+
gp3Button1,
|
199
|
+
gp3Button2,
|
200
|
+
gp3Button3,
|
201
|
+
gp3Button4,
|
202
|
+
gp3Button5,
|
203
|
+
gp3Button6,
|
204
|
+
gp3Button7,
|
205
|
+
gp3Button8,
|
206
|
+
gp3Button9,
|
207
|
+
gp3Button10,
|
208
|
+
gp3Button11,
|
209
|
+
gp3Button12,
|
210
|
+
gp3Button13,
|
211
|
+
gp3Button14,
|
212
|
+
gp3Button15,
|
213
|
+
|
214
|
+
gpRangeEnd = gp3Button15,
|
215
|
+
|
216
|
+
numButtons = gpRangeEnd + 1,
|
217
|
+
numGamepads = 4,
|
218
|
+
noButton = 0xffffffff,
|
130
219
|
|
131
220
|
kbNum = kbRangeEnd - kbRangeBegin + 1,
|
132
221
|
msNum = msRangeEnd - msRangeBegin + 1,
|
133
222
|
gpNum = gpRangeEnd - gpRangeBegin + 1,
|
134
|
-
|
135
|
-
numButtons = gpRangeEnd,
|
136
|
-
noButton = 0xffffffff
|
223
|
+
gpNumPerGamepad = gpNum / (numGamepads + 1),
|
137
224
|
};
|
138
225
|
}
|
139
226
|
|
data/Gosu/ButtonsMac.hpp
CHANGED
@@ -126,14 +126,101 @@ namespace Gosu
|
|
126
126
|
gpButton13,
|
127
127
|
gpButton14,
|
128
128
|
gpButton15,
|
129
|
-
|
129
|
+
|
130
|
+
gp0Left,
|
131
|
+
gp0Right,
|
132
|
+
gp0Up,
|
133
|
+
gp0Down,
|
134
|
+
gp0Button0,
|
135
|
+
gp0Button1,
|
136
|
+
gp0Button2,
|
137
|
+
gp0Button3,
|
138
|
+
gp0Button4,
|
139
|
+
gp0Button5,
|
140
|
+
gp0Button6,
|
141
|
+
gp0Button7,
|
142
|
+
gp0Button8,
|
143
|
+
gp0Button9,
|
144
|
+
gp0Button10,
|
145
|
+
gp0Button11,
|
146
|
+
gp0Button12,
|
147
|
+
gp0Button13,
|
148
|
+
gp0Button14,
|
149
|
+
gp0Button15,
|
150
|
+
|
151
|
+
gp1Left,
|
152
|
+
gp1Right,
|
153
|
+
gp1Up,
|
154
|
+
gp1Down,
|
155
|
+
gp1Button0,
|
156
|
+
gp1Button1,
|
157
|
+
gp1Button2,
|
158
|
+
gp1Button3,
|
159
|
+
gp1Button4,
|
160
|
+
gp1Button5,
|
161
|
+
gp1Button6,
|
162
|
+
gp1Button7,
|
163
|
+
gp1Button8,
|
164
|
+
gp1Button9,
|
165
|
+
gp1Button10,
|
166
|
+
gp1Button11,
|
167
|
+
gp1Button12,
|
168
|
+
gp1Button13,
|
169
|
+
gp1Button14,
|
170
|
+
gp1Button15,
|
171
|
+
|
172
|
+
gp2Left,
|
173
|
+
gp2Right,
|
174
|
+
gp2Up,
|
175
|
+
gp2Down,
|
176
|
+
gp2Button0,
|
177
|
+
gp2Button1,
|
178
|
+
gp2Button2,
|
179
|
+
gp2Button3,
|
180
|
+
gp2Button4,
|
181
|
+
gp2Button5,
|
182
|
+
gp2Button6,
|
183
|
+
gp2Button7,
|
184
|
+
gp2Button8,
|
185
|
+
gp2Button9,
|
186
|
+
gp2Button10,
|
187
|
+
gp2Button11,
|
188
|
+
gp2Button12,
|
189
|
+
gp2Button13,
|
190
|
+
gp2Button14,
|
191
|
+
gp2Button15,
|
192
|
+
|
193
|
+
gp3Left,
|
194
|
+
gp3Right,
|
195
|
+
gp3Up,
|
196
|
+
gp3Down,
|
197
|
+
gp3Button0,
|
198
|
+
gp3Button1,
|
199
|
+
gp3Button2,
|
200
|
+
gp3Button3,
|
201
|
+
gp3Button4,
|
202
|
+
gp3Button5,
|
203
|
+
gp3Button6,
|
204
|
+
gp3Button7,
|
205
|
+
gp3Button8,
|
206
|
+
gp3Button9,
|
207
|
+
gp3Button10,
|
208
|
+
gp3Button11,
|
209
|
+
gp3Button12,
|
210
|
+
gp3Button13,
|
211
|
+
gp3Button14,
|
212
|
+
gp3Button15,
|
213
|
+
|
214
|
+
gpRangeEnd = gp3Button15,
|
215
|
+
|
216
|
+
numButtons = gpRangeEnd + 1,
|
217
|
+
numGamepads = 4,
|
218
|
+
noButton = 0xffffffff,
|
130
219
|
|
131
220
|
kbNum = kbRangeEnd - kbRangeBegin + 1,
|
132
221
|
msNum = msRangeEnd - msRangeBegin + 1,
|
133
222
|
gpNum = gpRangeEnd - gpRangeBegin + 1,
|
134
|
-
|
135
|
-
numButtons = gpRangeEnd + 1,
|
136
|
-
noButton = 0xffffffff
|
223
|
+
gpNumPerGamepad = gpNum / (numGamepads + 1),
|
137
224
|
};
|
138
225
|
}
|
139
226
|
|
data/Gosu/Graphics.hpp
CHANGED
@@ -23,7 +23,17 @@ namespace Gosu
|
|
23
23
|
//! Useful when extending Gosu using OpenGL.
|
24
24
|
unsigned const MAX_TEXTURE_SIZE = 1024;
|
25
25
|
|
26
|
+
#ifdef GOSU_IS_MAC
|
27
|
+
struct Transform
|
28
|
+
{
|
29
|
+
double value[16];
|
30
|
+
bool operator==(const Transform &other) { for (int i = 0; i < 16; ++i) if ((*this)[i] != other[i]) return false; return true; }
|
31
|
+
const double &operator[](std::size_t idx) const { return value[idx]; }
|
32
|
+
double &operator[](std::size_t idx) { return value[idx]; }
|
33
|
+
};
|
34
|
+
#else
|
26
35
|
typedef std::tr1::array<double, 16> Transform;
|
36
|
+
#endif
|
27
37
|
Transform translate(double x, double y);
|
28
38
|
Transform rotate(double angle, double aroundX = 0, double aroundY = 0);
|
29
39
|
Transform scale(double factor);
|
data/Gosu/ImageData.hpp
CHANGED
data/Gosu/Input.hpp
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#include <Gosu/Platform.hpp>
|
9
9
|
|
10
10
|
#ifdef GOSU_IS_WIN
|
11
|
-
#include <Gosu/
|
11
|
+
#include <Gosu/Buttons.hpp>
|
12
12
|
#ifndef NOMINMAX
|
13
13
|
#define NOMINMAX
|
14
14
|
#endif
|
@@ -20,10 +20,9 @@
|
|
20
20
|
#endif
|
21
21
|
|
22
22
|
#ifdef GOSU_IS_X
|
23
|
+
#include <Gosu/Buttons.hpp>
|
23
24
|
#include <X11/Xlib.h>
|
24
25
|
#include <X11/Xutil.h>
|
25
|
-
#include <X11/keysym.h>
|
26
|
-
#include <Gosu/ButtonsX.hpp>
|
27
26
|
#endif
|
28
27
|
|
29
28
|
#include <Gosu/Platform.hpp>
|
data/Gosu/Version.hpp
CHANGED
data/Gosu/Window.hpp
CHANGED
@@ -74,7 +74,7 @@ namespace Gosu
|
|
74
74
|
//! This function is called when the operating system's memory is low.
|
75
75
|
//! So far, it is only called in iOS applications.
|
76
76
|
virtual void releaseMemory() {}
|
77
|
-
|
77
|
+
|
78
78
|
//! Called before update when the user pressed a button while the
|
79
79
|
//! window had the focus.
|
80
80
|
virtual void buttonDown(Gosu::Button) {}
|
@@ -109,15 +109,19 @@ namespace Gosu
|
|
109
109
|
// Easy formats
|
110
110
|
format_ = 0;
|
111
111
|
if (desc.mChannelsPerFrame == 1)
|
112
|
+
{
|
112
113
|
/*if (desc.mBitsPerChannel == 8)
|
113
114
|
format_ = AL_FORMAT_MONO8;
|
114
115
|
else*/ if (desc.mBitsPerChannel == 16)
|
115
116
|
format_ = AL_FORMAT_MONO16;
|
117
|
+
}
|
116
118
|
else if (desc.mChannelsPerFrame == 2)
|
119
|
+
{
|
117
120
|
/*if (desc.mBitsPerChannel == 8)
|
118
121
|
format_ = AL_FORMAT_STEREO8;
|
119
122
|
else */if (desc.mBitsPerChannel == 16)
|
120
123
|
format_ = AL_FORMAT_STEREO16;
|
124
|
+
}
|
121
125
|
|
122
126
|
if (format_ == 0 ||
|
123
127
|
// If format not native for OpenAL, set client data format
|
@@ -128,13 +128,14 @@ void Gosu::loadImageFile(Bitmap& bitmap, Reader reader)
|
|
128
128
|
applyColorKey(bitmap, Color::FUCHSIA);
|
129
129
|
}
|
130
130
|
|
131
|
-
#ifndef GOSU_IS_IPHONE
|
132
131
|
void Gosu::saveImageFile(const Bitmap& bitmap, const std::wstring& filename)
|
133
132
|
{
|
134
|
-
|
135
|
-
saveImageFile(bitmap,
|
133
|
+
Buffer buffer;
|
134
|
+
saveImageFile(bitmap, buffer.backWriter(), filename);
|
135
|
+
saveFile(buffer, filename);
|
136
136
|
}
|
137
137
|
|
138
|
+
#ifndef GOSU_IS_IPHONE
|
138
139
|
void Gosu::saveImageFile(const Bitmap& originalBitmap, Writer writer, const std::wstring& formatHint)
|
139
140
|
{
|
140
141
|
NSBitmapImageFileType fileType;
|
@@ -164,20 +165,13 @@ void Gosu::saveImageFile(const Bitmap& originalBitmap, Writer writer, const std:
|
|
164
165
|
initWithBitmapDataPlanes:&plane pixelsWide:bitmap.width() pixelsHigh:bitmap.height()
|
165
166
|
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO
|
166
167
|
colorSpaceName:NSDeviceRGBColorSpace // Nobody really seems to know which one to use
|
167
|
-
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat bytesPerRow:
|
168
|
+
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat bytesPerRow:bitmap.width() * 4 bitsPerPixel:32]);
|
168
169
|
|
169
170
|
ObjRef<NSAutoreleasePool> pool([NSAutoreleasePool new]);
|
170
171
|
NSData* data = [rep.obj() representationUsingType:fileType properties:nil];
|
171
172
|
writer.write([data bytes], [data length]);
|
172
173
|
}
|
173
174
|
#else
|
174
|
-
void Gosu::saveImageFile(const Bitmap& bmp, const std::wstring& filename)
|
175
|
-
{
|
176
|
-
Buffer buffer;
|
177
|
-
saveImageFile(bmp, buffer.backWriter());
|
178
|
-
saveFile(buffer, filename);
|
179
|
-
}
|
180
|
-
|
181
175
|
void Gosu::saveImageFile(const Bitmap& bmp, Writer writer, const std::wstring& formatHint)
|
182
176
|
{
|
183
177
|
if (isExtension(formatHint.c_str(), L"bmp"))
|
@@ -20,7 +20,7 @@ class Gosu::ClipRectStack
|
|
20
20
|
return;
|
21
21
|
}
|
22
22
|
|
23
|
-
ClipRect result = { 0, 0,
|
23
|
+
ClipRect result = { 0.0, 0.0, 1e10, 1e10 };
|
24
24
|
for (int i = 0, end = stack.size(); i < end; ++i)
|
25
25
|
{
|
26
26
|
const ClipRect& rect = stack[i];
|
@@ -62,7 +62,7 @@ public:
|
|
62
62
|
hasEffectiveRect = false;
|
63
63
|
}
|
64
64
|
|
65
|
-
void beginClipping(
|
65
|
+
void beginClipping(double x, double y, double width, double height)
|
66
66
|
{
|
67
67
|
ClipRect rect = { x, y, width, height };
|
68
68
|
stack.push_back(rect);
|
@@ -10,43 +10,44 @@
|
|
10
10
|
#include <algorithm>
|
11
11
|
#include <map>
|
12
12
|
#include <vector>
|
13
|
+
#include <cmath>
|
13
14
|
|
14
15
|
class Gosu::DrawOpQueue
|
15
16
|
{
|
16
17
|
TransformStack transformStack;
|
17
18
|
ClipRectStack clipRectStack;
|
18
|
-
|
19
|
+
|
19
20
|
typedef std::vector<DrawOp> DrawOps;
|
20
21
|
DrawOps ops;
|
21
22
|
typedef std::vector<std::tr1::function<void()> > GLBlocks;
|
22
23
|
GLBlocks glBlocks;
|
23
|
-
|
24
|
+
|
24
25
|
public:
|
25
26
|
void scheduleDrawOp(DrawOp op)
|
26
27
|
{
|
27
28
|
if (clipRectStack.clippedWorldAway())
|
28
29
|
return;
|
29
|
-
|
30
|
+
|
30
31
|
#ifdef GOSU_IS_IPHONE
|
31
32
|
// No triangles, no lines supported
|
32
33
|
assert (op.verticesOrBlockIndex == 4);
|
33
34
|
#endif
|
34
|
-
|
35
|
+
|
35
36
|
op.renderState.transform = &transformStack.current();
|
36
37
|
if (const ClipRect* cr = clipRectStack.maybeEffectiveRect())
|
37
38
|
op.renderState.clipRect = *cr;
|
38
39
|
ops.push_back(op);
|
39
40
|
}
|
40
|
-
|
41
|
+
|
41
42
|
void scheduleGL(std::tr1::function<void()> glBlock, ZPos z)
|
42
43
|
{
|
43
44
|
// TODO: Document this case: Clipped-away GL blocks are *not* being run.
|
44
45
|
if (clipRectStack.clippedWorldAway())
|
45
46
|
return;
|
46
|
-
|
47
|
+
|
47
48
|
int complementOfBlockIndex = ~(int)glBlocks.size();
|
48
49
|
glBlocks.push_back(glBlock);
|
49
|
-
|
50
|
+
|
50
51
|
DrawOp op;
|
51
52
|
op.verticesOrBlockIndex = complementOfBlockIndex;
|
52
53
|
op.renderState.transform = &transformStack.current();
|
@@ -55,60 +56,60 @@ public:
|
|
55
56
|
op.z = z;
|
56
57
|
ops.push_back(op);
|
57
58
|
}
|
58
|
-
|
59
|
-
void beginClipping(
|
59
|
+
|
60
|
+
void beginClipping(double x, double y, double width, double height, double screenHeight)
|
60
61
|
{
|
61
62
|
// Apply current transformation.
|
62
|
-
|
63
|
+
|
63
64
|
double left = x, right = x + width;
|
64
65
|
double top = y, bottom = y + height;
|
65
|
-
|
66
|
+
|
66
67
|
applyTransform(transformStack.current(), left, top);
|
67
68
|
applyTransform(transformStack.current(), right, bottom);
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
|
70
|
+
double physX = std::min(left, right);
|
71
|
+
double physY = std::min(top, bottom);
|
72
|
+
double physWidth = std::abs(left - right);
|
73
|
+
double physHeight = std::abs(top - bottom);
|
74
|
+
|
74
75
|
// Adjust for OpenGL having the wrong idea of where y=0 is.
|
75
76
|
// TODO: This should really happen *right before* setting up
|
76
77
|
// the glScissor.
|
77
78
|
physY = screenHeight - physY - physHeight;
|
78
|
-
|
79
|
+
|
79
80
|
clipRectStack.beginClipping(physX, physY, physWidth, physHeight);
|
80
81
|
}
|
81
|
-
|
82
|
+
|
82
83
|
void endClipping()
|
83
84
|
{
|
84
85
|
clipRectStack.endClipping();
|
85
86
|
}
|
86
|
-
|
87
|
+
|
87
88
|
void setBaseTransform(const Transform& baseTransform)
|
88
89
|
{
|
89
90
|
transformStack.setBaseTransform(baseTransform);
|
90
91
|
}
|
91
|
-
|
92
|
+
|
92
93
|
void pushTransform(const Transform& transform)
|
93
94
|
{
|
94
95
|
transformStack.push(transform);
|
95
96
|
}
|
96
|
-
|
97
|
+
|
97
98
|
void popTransform()
|
98
99
|
{
|
99
100
|
transformStack.pop();
|
100
101
|
}
|
101
|
-
|
102
|
+
|
102
103
|
void performDrawOpsAndCode()
|
103
104
|
{
|
104
105
|
// Apply Z-Ordering.
|
105
106
|
std::stable_sort(ops.begin(), ops.end());
|
106
|
-
|
107
|
+
|
107
108
|
RenderStateManager manager;
|
108
109
|
#ifdef GOSU_IS_IPHONE
|
109
110
|
if (ops.empty())
|
110
111
|
return;
|
111
|
-
|
112
|
+
|
112
113
|
DrawOps::const_iterator current = ops.begin(), last = ops.end() - 1;
|
113
114
|
for (; current != last; ++current)
|
114
115
|
{
|
@@ -136,24 +137,24 @@ public:
|
|
136
137
|
}
|
137
138
|
#endif
|
138
139
|
}
|
139
|
-
|
140
|
+
|
140
141
|
void compileTo(VertexArrays& vas)
|
141
142
|
{
|
142
143
|
if (!glBlocks.empty())
|
143
144
|
throw std::logic_error("Custom code cannot be recorded into a macro");
|
144
|
-
|
145
|
+
|
145
146
|
std::stable_sort(ops.begin(), ops.end());
|
146
147
|
for (DrawOps::const_iterator op = ops.begin(), end = ops.end(); op != end; ++op)
|
147
148
|
op->compileTo(vas);
|
148
149
|
}
|
149
|
-
|
150
|
+
|
150
151
|
// This retains the current stack of transforms and clippings.
|
151
152
|
void clearQueue()
|
152
153
|
{
|
153
154
|
glBlocks.clear();
|
154
155
|
ops.clear();
|
155
156
|
}
|
156
|
-
|
157
|
+
|
157
158
|
// This clears the queue and starts with new stacks. This must not be called
|
158
159
|
// when endClipping/popTransform calls might still be pending.
|
159
160
|
void reset()
|