gosu 0.7.22 → 0.7.23
Sign up to get free protection for your applications and to get access to all the features.
- data/Gosu/Audio.hpp +2 -0
- data/Gosu/Fwd.hpp +0 -1
- data/Gosu/Gosu.hpp +1 -1
- data/Gosu/Graphics.hpp +12 -11
- data/Gosu/GraphicsBase.hpp +5 -0
- data/Gosu/Image.hpp +0 -14
- data/Gosu/Input.hpp +32 -18
- data/Gosu/Text.hpp +3 -2
- data/Gosu/Version.hpp +2 -2
- data/Gosu/Window.hpp +21 -8
- data/GosuImpl/Audio/AudioOpenAL.mm +74 -8
- data/GosuImpl/Graphics/Common.hpp +25 -1
- data/GosuImpl/Graphics/DrawOp.hpp +54 -222
- data/GosuImpl/Graphics/DrawOpQueue.hpp +127 -0
- data/GosuImpl/Graphics/FormattedString.hpp +63 -20
- data/GosuImpl/Graphics/GosuView.hpp +5 -8
- data/GosuImpl/Graphics/GosuView.mm +36 -65
- data/GosuImpl/Graphics/Graphics.cpp +121 -110
- data/GosuImpl/Graphics/Image.cpp +0 -51
- data/GosuImpl/Graphics/Macro.hpp +1 -0
- data/GosuImpl/Graphics/RenderState.hpp +107 -0
- data/GosuImpl/Graphics/TexChunk.cpp +1 -10
- data/GosuImpl/Graphics/Text.cpp +22 -10
- data/GosuImpl/Graphics/TextMac.cpp +2 -4
- data/GosuImpl/Graphics/TextTouch.mm +14 -21
- data/GosuImpl/Graphics/TextWin.cpp +5 -2
- data/GosuImpl/Graphics/Texture.cpp +11 -10
- data/GosuImpl/Graphics/Transform.cpp +3 -1
- data/GosuImpl/Input/AccelerometerReader.hpp +10 -0
- data/GosuImpl/Input/AccelerometerReader.mm +31 -0
- data/GosuImpl/InputMac.mm +51 -24
- data/GosuImpl/InputTouch.mm +112 -1
- data/GosuImpl/InputWin.cpp +27 -3
- data/GosuImpl/InputX.cpp +21 -0
- data/GosuImpl/MacUtility.hpp +33 -0
- data/GosuImpl/Orientation.hpp +15 -0
- data/GosuImpl/Orientation.mm +34 -0
- data/GosuImpl/RubyGosu.swg +7 -9
- data/GosuImpl/RubyGosu_wrap.cxx +328 -82
- data/GosuImpl/RubyGosu_wrap.h +3 -0
- data/GosuImpl/TextInputWin.cpp +2 -0
- data/GosuImpl/Utility.cpp +2 -0
- data/GosuImpl/WindowMac.mm +13 -19
- data/GosuImpl/WindowTouch.mm +44 -32
- data/GosuImpl/WindowWin.cpp +20 -12
- data/GosuImpl/WindowX.cpp +33 -23
- data/examples/CptnRuby.rb +8 -9
- data/lib/gosu.rb +0 -0
- data/lib/gosu/swig_patches.rb +0 -12
- data/linux/extconf.rb +2 -2
- metadata +11 -7
- data/Gosu/RotFlip.hpp +0 -125
- data/GosuImpl/Graphics/RotFlip.cpp +0 -184
data/Gosu/Audio.hpp
CHANGED
data/Gosu/Fwd.hpp
CHANGED
data/Gosu/Gosu.hpp
CHANGED
@@ -22,12 +22,12 @@
|
|
22
22
|
#include <Gosu/IO.hpp>
|
23
23
|
#include <Gosu/Math.hpp>
|
24
24
|
#include <Gosu/Platform.hpp>
|
25
|
-
#include <Gosu/RotFlip.hpp>
|
26
25
|
#include <Gosu/Sockets.hpp>
|
27
26
|
#include <Gosu/Text.hpp>
|
28
27
|
#include <Gosu/TextInput.hpp>
|
29
28
|
#include <Gosu/Timing.hpp>
|
30
29
|
#include <Gosu/Utility.hpp>
|
30
|
+
#include <Gosu/Version.hpp>
|
31
31
|
#include <Gosu/Window.hpp>
|
32
32
|
|
33
33
|
#endif
|
data/Gosu/Graphics.hpp
CHANGED
@@ -19,21 +19,20 @@ namespace Gosu
|
|
19
19
|
//! Returns the height, in pixels, of the user's primary screen.
|
20
20
|
unsigned screenHeight();
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
//extern unsigned const MAX_TEXTURE_SIZE;
|
22
|
+
//! Returns the maximum size of an texture that will be allocated
|
23
|
+
//! internally by Gosu.
|
24
|
+
//! Useful when extending Gosu using OpenGL.
|
25
|
+
extern unsigned const MAX_TEXTURE_SIZE;
|
27
26
|
|
28
27
|
typedef boost::array<double, 16> Transform;
|
29
|
-
Transform rotate(double angle, double aroundX = 0, double aroundY = 0);
|
30
28
|
Transform translate(double x, double y);
|
29
|
+
Transform rotate(double angle, double aroundX = 0, double aroundY = 0);
|
31
30
|
Transform scale(double factor);
|
32
|
-
Transform scale(double factorX, double factorY);
|
31
|
+
Transform scale(double factorX, double factorY, double fromX = 0, double fromY = 0);
|
33
32
|
|
34
|
-
//! Serves as the target of all drawing and provides
|
33
|
+
//! Serves as the target of all drawing and provides primitive drawing
|
35
34
|
//! functionality.
|
36
|
-
//! Usually created by Gosu::Window.
|
35
|
+
//! Usually created internally by Gosu::Window.
|
37
36
|
class Graphics
|
38
37
|
{
|
39
38
|
struct Impl;
|
@@ -44,8 +43,6 @@ namespace Gosu
|
|
44
43
|
~Graphics();
|
45
44
|
|
46
45
|
// Undocumented until I have thought about this...
|
47
|
-
double factorX() const;
|
48
|
-
double factorY() const;
|
49
46
|
void setResolution(unsigned virtualWidth, unsigned virtualHeight);
|
50
47
|
// End of Undocumented
|
51
48
|
|
@@ -58,6 +55,10 @@ namespace Gosu
|
|
58
55
|
bool begin(Color clearWithColor = Color::BLACK);
|
59
56
|
//! Every call to begin must have a matching call to end.
|
60
57
|
void end();
|
58
|
+
//! Flushes the Z queue to the screen and starts a new one.
|
59
|
+
//! Useful for games that are *very* composite in nature (splitscreen).
|
60
|
+
void flush();
|
61
|
+
|
61
62
|
//! Finishes all pending Gosu drawing operations and executes
|
62
63
|
//! the following OpenGL code in a clean environment.
|
63
64
|
void beginGL();
|
data/Gosu/GraphicsBase.hpp
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
#ifndef GOSU_GRAPHICSBASE_HPP
|
5
5
|
#define GOSU_GRAPHICSBASE_HPP
|
6
6
|
|
7
|
+
#include <Gosu/Platform.hpp>
|
7
8
|
#include <limits>
|
8
9
|
|
9
10
|
namespace Gosu
|
@@ -16,6 +17,10 @@ namespace Gosu
|
|
16
17
|
//! The lowest possible Z position. By using this, you tell Gosu that
|
17
18
|
//! your drawing operation does not need Z ordering and can be performed
|
18
19
|
//! immediately.
|
20
|
+
//! Deprecated because this turned out not be very useful in optimizing.
|
21
|
+
#ifndef SWIG
|
22
|
+
GOSU_DEPRECATED
|
23
|
+
#endif
|
19
24
|
const double zImmediate = -std::numeric_limits<double>::infinity();
|
20
25
|
|
21
26
|
//! Determines the way colors are combined when one is drawn onto
|
data/Gosu/Image.hpp
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
|
7
7
|
#include <Gosu/Fwd.hpp>
|
8
8
|
#include <Gosu/Bitmap.hpp>
|
9
|
-
#include <Gosu/RotFlip.hpp>
|
10
9
|
#include <boost/scoped_ptr.hpp>
|
11
10
|
#include <memory>
|
12
11
|
|
@@ -79,21 +78,8 @@ namespace Gosu
|
|
79
78
|
Color c = Color::WHITE,
|
80
79
|
AlphaMode mode = amDefault) const;
|
81
80
|
|
82
|
-
#ifndef SWIG
|
83
|
-
void drawRotFlip(double x, double y, ZPos z,
|
84
|
-
RotFlip rf,
|
85
|
-
double factorX = 1, double factorY = 1,
|
86
|
-
Color c = Color::WHITE,
|
87
|
-
AlphaMode mode = amDefault) const;
|
88
|
-
void drawRotFlipMod(double x, double y, ZPos z,
|
89
|
-
RotFlip rf,
|
90
|
-
double factorX, double factorY,
|
91
|
-
Color c1, Color c2, Color c3, Color c4,
|
92
|
-
AlphaMode mode = amDefault) const;
|
93
|
-
|
94
81
|
//! Provides access to the underlying image data object.
|
95
82
|
const ImageData& getData() const;
|
96
|
-
#endif
|
97
83
|
};
|
98
84
|
|
99
85
|
//! Convenience function that splits a BMP or PNG file into an array
|
data/Gosu/Input.hpp
CHANGED
@@ -9,7 +9,9 @@
|
|
9
9
|
|
10
10
|
#ifdef GOSU_IS_WIN
|
11
11
|
#include <Gosu/ButtonsWin.hpp>
|
12
|
+
#ifndef NOMINMAX
|
12
13
|
#define NOMINMAX
|
14
|
+
#endif
|
13
15
|
#include <windows.h>
|
14
16
|
#endif
|
15
17
|
|
@@ -50,20 +52,6 @@ namespace Gosu
|
|
50
52
|
Button(ButtonName name) : id_(name) {}
|
51
53
|
};
|
52
54
|
|
53
|
-
// Available even on non-iPhone platforms to make it easier to compile the
|
54
|
-
// same source for multiple platforms.
|
55
|
-
|
56
|
-
//! Struct that saves information about a touch on the surface of a multi-
|
57
|
-
//! touch device.
|
58
|
-
struct Touch
|
59
|
-
{
|
60
|
-
//! Allows for identification of a touch across calls.
|
61
|
-
void* id;
|
62
|
-
//! Position of a touch on the touch screen.
|
63
|
-
double x, y;
|
64
|
-
};
|
65
|
-
typedef std::vector<Touch> Touches;
|
66
|
-
|
67
55
|
//! Tests whether two Buttons identify the same physical button.
|
68
56
|
inline bool operator==(Button lhs, Button rhs)
|
69
57
|
{
|
@@ -78,6 +66,19 @@ namespace Gosu
|
|
78
66
|
return lhs.id() < rhs.id();
|
79
67
|
}
|
80
68
|
|
69
|
+
//! Struct that saves information about a touch on the surface of a multi-
|
70
|
+
//! touch device.
|
71
|
+
//! Available even on non-iPhone platforms to make it easier to compile the
|
72
|
+
//! same source for multiple platforms.
|
73
|
+
struct Touch
|
74
|
+
{
|
75
|
+
//! Allows for identification of a touch across calls.
|
76
|
+
void* id;
|
77
|
+
//! Position of a touch on the touch screen.
|
78
|
+
float x, y;
|
79
|
+
};
|
80
|
+
typedef std::vector<Touch> Touches;
|
81
|
+
|
81
82
|
//! Manages initialization and shutdown of the input system. Only one Input
|
82
83
|
//! instance can exist per application.
|
83
84
|
class Input
|
@@ -92,9 +93,10 @@ namespace Gosu
|
|
92
93
|
|
93
94
|
#ifdef GOSU_IS_MAC
|
94
95
|
#ifdef GOSU_IS_IPHONE
|
95
|
-
Input();
|
96
|
+
Input(void* view, float updateInterval);
|
97
|
+
void feedTouchEvent(int type, void* touches);
|
96
98
|
#else
|
97
|
-
Input(void*
|
99
|
+
Input(void* window);
|
98
100
|
bool feedNSEvent(void* event);
|
99
101
|
#endif
|
100
102
|
#endif
|
@@ -121,15 +123,23 @@ namespace Gosu
|
|
121
123
|
double mouseX() const;
|
122
124
|
//! See mouseX.
|
123
125
|
double mouseY() const;
|
124
|
-
|
126
|
+
|
125
127
|
//! Immediately moves the mouse as far towards the desired position
|
126
128
|
//! as possible. x and y are relativ to the window just as in the mouse
|
127
129
|
//! position accessors.
|
128
130
|
void setMousePosition(double x, double y);
|
129
131
|
|
130
|
-
// Undocumented for the moment.
|
132
|
+
// Undocumented for the moment. Also applies to currentTouches().
|
131
133
|
void setMouseFactors(double factorX, double factorY);
|
132
134
|
|
135
|
+
//! Currently known touches.
|
136
|
+
const Touches& currentTouches() const;
|
137
|
+
|
138
|
+
//! Accelerometer positions in all three dimensions (smoothened).
|
139
|
+
double accelerometerX() const;
|
140
|
+
double accelerometerY() const;
|
141
|
+
double accelerometerZ() const;
|
142
|
+
|
133
143
|
//! Collects new information about which buttons are pressed, where the
|
134
144
|
//! mouse is and calls onButtonUp/onButtonDown, if assigned.
|
135
145
|
void update();
|
@@ -138,6 +148,10 @@ namespace Gosu
|
|
138
148
|
//! If you use the Window class, it will assign forward these to its own methods.
|
139
149
|
boost::function<void (Button)> onButtonDown, onButtonUp;
|
140
150
|
|
151
|
+
//! Assignable events that are called by update. You can bind these to your own functions.
|
152
|
+
//! If you use the Window class, it will assign forward these to its own methods.
|
153
|
+
boost::function<void (Touch)> onTouchBegan, onTouchMoved, onTouchEnded;
|
154
|
+
|
141
155
|
//! Returns the currently active TextInput instance, or 0.
|
142
156
|
TextInput* textInput() const;
|
143
157
|
//! Sets the currently active TextInput, or clears it (input = 0).
|
data/Gosu/Text.hpp
CHANGED
@@ -51,7 +51,8 @@ namespace Gosu
|
|
51
51
|
//! \param text Formatted text.
|
52
52
|
//! \param fontName Name of a system font, or a filename to a TTF file (must contain '/', does not work on Linux).
|
53
53
|
//! \param fontHeight Height of the font in pixels.
|
54
|
-
//! \param lineSpacing Spacing between two lines of text in pixels.
|
54
|
+
//! \param lineSpacing Spacing between two lines of text in pixels. Can be negative to make
|
55
|
+
//! text stick together more closely.
|
55
56
|
//! \param maxWidth Width of the bitmap that will be returned. Text
|
56
57
|
//! will be split into multiple lines to avoid drawing over the right
|
57
58
|
//! border. When a single word is too long, it will be truncated.
|
@@ -59,7 +60,7 @@ namespace Gosu
|
|
59
60
|
//! enum.
|
60
61
|
Bitmap createText(const std::wstring& text,
|
61
62
|
const std::wstring& fontName, unsigned fontHeight,
|
62
|
-
|
63
|
+
int lineSpacing, unsigned maxWidth, TextAlign align,
|
63
64
|
unsigned fontFlags = 0);
|
64
65
|
|
65
66
|
//! Registers a new HTML-style entity that can subsequently be used
|
data/Gosu/Version.hpp
CHANGED
data/Gosu/Window.hpp
CHANGED
@@ -13,7 +13,9 @@
|
|
13
13
|
#include <string>
|
14
14
|
|
15
15
|
#ifdef GOSU_IS_WIN
|
16
|
+
#ifndef NOMINMAX
|
16
17
|
#define NOMINMAX
|
18
|
+
#endif
|
17
19
|
#include <windows.h>
|
18
20
|
#endif
|
19
21
|
|
@@ -28,7 +30,7 @@ namespace Gosu
|
|
28
30
|
{
|
29
31
|
struct Impl;
|
30
32
|
boost::scoped_ptr<Impl> pimpl;
|
31
|
-
|
33
|
+
|
32
34
|
public:
|
33
35
|
//! Constructs a Window.
|
34
36
|
//! \param updateInterval Interval in milliseconds between two calls
|
@@ -59,6 +61,19 @@ namespace Gosu
|
|
59
61
|
//! redraws for one reason or another.
|
60
62
|
//! By default, the window is redrawn all the time.
|
61
63
|
virtual bool needsRedraw() const { return true; }
|
64
|
+
|
65
|
+
//! If this function returns true, the system arrow cursor is drawn while
|
66
|
+
//! over the window.
|
67
|
+
virtual bool needsCursor() const { return false; }
|
68
|
+
|
69
|
+
//! This function is called when the window loses focus on some platforms.
|
70
|
+
//! Most importantly, it is called on the iPhone or iPad when the user
|
71
|
+
//! locks the screen.
|
72
|
+
virtual void loseFocus() {}
|
73
|
+
|
74
|
+
//! This function is called when the operating system's memory is low.
|
75
|
+
//! So far, it is only called in iOS applications.
|
76
|
+
virtual void releaseMemory() {}
|
62
77
|
|
63
78
|
//! Called before update when the user pressed a button while the
|
64
79
|
//! window had the focus.
|
@@ -94,15 +109,13 @@ namespace Gosu
|
|
94
109
|
// Note that it does not hurt to override them even if you compile
|
95
110
|
// for another platform; if you don't specify "virtual" the code
|
96
111
|
// should even be stripped away cleanly.
|
97
|
-
virtual void
|
98
|
-
virtual void
|
99
|
-
virtual void
|
100
|
-
// Currently known touches.
|
101
|
-
const Touches& currentTouches() const;
|
112
|
+
virtual void touchBegan(Touch touch) {}
|
113
|
+
virtual void touchMoved(Touch touch) {}
|
114
|
+
virtual void touchEnded(Touch touch) {}
|
102
115
|
#endif
|
103
116
|
|
104
|
-
|
105
|
-
|
117
|
+
const Audio& audio() const;
|
118
|
+
Audio& audio();
|
106
119
|
|
107
120
|
#endif
|
108
121
|
};
|
@@ -22,6 +22,10 @@
|
|
22
22
|
#include <OpenAL/al.h>
|
23
23
|
#include <OpenAL/alc.h>
|
24
24
|
|
25
|
+
#ifdef GOSU_IS_IPHONE
|
26
|
+
#import <AVFoundation/AVFoundation.h>
|
27
|
+
#endif
|
28
|
+
|
25
29
|
using namespace std;
|
26
30
|
|
27
31
|
namespace
|
@@ -245,7 +249,7 @@ protected:
|
|
245
249
|
public:
|
246
250
|
virtual ~BaseData() {}
|
247
251
|
|
248
|
-
virtual void play() = 0;
|
252
|
+
virtual void play(bool looping) = 0;
|
249
253
|
virtual void pause() = 0;
|
250
254
|
virtual void resume() = 0;
|
251
255
|
virtual bool paused() const = 0;
|
@@ -265,6 +269,62 @@ public:
|
|
265
269
|
}
|
266
270
|
};
|
267
271
|
|
272
|
+
#ifdef GOSU_IS_IPHONE
|
273
|
+
// AVAudioPlayer impl
|
274
|
+
class Gosu::Song::ModuleData : public BaseData
|
275
|
+
{
|
276
|
+
ObjRef<AVAudioPlayer> player;
|
277
|
+
|
278
|
+
void applyVolume()
|
279
|
+
{
|
280
|
+
player.obj().volume = volume();
|
281
|
+
}
|
282
|
+
|
283
|
+
public:
|
284
|
+
ModuleData(const std::wstring& filename)
|
285
|
+
{
|
286
|
+
std::string utf8Filename = Gosu::wstringToUTF8(filename);
|
287
|
+
ObjRef<NSString> nsFilename([[NSString alloc] initWithUTF8String: utf8Filename.c_str()]);
|
288
|
+
ObjRef<NSURL> url([[NSURL alloc] initFileURLWithPath: nsFilename.obj()]);
|
289
|
+
player.reset([[AVAudioPlayer alloc] initWithContentsOfURL: url.obj() error: NULL]);
|
290
|
+
}
|
291
|
+
|
292
|
+
void play(bool looping)
|
293
|
+
{
|
294
|
+
if (paused())
|
295
|
+
stop();
|
296
|
+
player.obj().numberOfLoops = looping ? -1 : 0;
|
297
|
+
[player.obj() play];
|
298
|
+
}
|
299
|
+
|
300
|
+
void pause()
|
301
|
+
{
|
302
|
+
[player.obj() pause];
|
303
|
+
}
|
304
|
+
|
305
|
+
void resume()
|
306
|
+
{
|
307
|
+
[player.obj() play];
|
308
|
+
}
|
309
|
+
|
310
|
+
bool paused() const
|
311
|
+
{
|
312
|
+
return !player.obj().playing;
|
313
|
+
};
|
314
|
+
|
315
|
+
void stop()
|
316
|
+
{
|
317
|
+
[player.obj() stop];
|
318
|
+
player.obj().currentTime = 0;
|
319
|
+
}
|
320
|
+
|
321
|
+
void update()
|
322
|
+
{
|
323
|
+
}
|
324
|
+
};
|
325
|
+
#endif
|
326
|
+
|
327
|
+
// AudioToolbox impl
|
268
328
|
class Gosu::Song::StreamData : public BaseData
|
269
329
|
{
|
270
330
|
boost::scoped_ptr<AudioFile> file;
|
@@ -327,7 +387,7 @@ public:
|
|
327
387
|
}
|
328
388
|
}
|
329
389
|
|
330
|
-
void play()
|
390
|
+
void play(bool looping)
|
331
391
|
{
|
332
392
|
int source = lookupSource();
|
333
393
|
if (source != ALChannelManagement::NO_SOURCE)
|
@@ -401,7 +461,7 @@ public:
|
|
401
461
|
int source = lookupSource();
|
402
462
|
|
403
463
|
ALuint buffer;
|
404
|
-
int
|
464
|
+
int processed;
|
405
465
|
bool active = true;
|
406
466
|
|
407
467
|
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
@@ -428,7 +488,7 @@ public:
|
|
428
488
|
|
429
489
|
if (curSongLooping)
|
430
490
|
// Start anew.
|
431
|
-
play();
|
491
|
+
play(true);
|
432
492
|
else
|
433
493
|
// Let the world know we're finished.
|
434
494
|
curSong = 0;
|
@@ -438,9 +498,15 @@ public:
|
|
438
498
|
|
439
499
|
Gosu::Song::Song(const std::wstring& filename)
|
440
500
|
{
|
441
|
-
|
442
|
-
|
443
|
-
|
501
|
+
#ifdef GOSU_IS_IPHONE
|
502
|
+
if (boost::iends_with(filename, L".mp3") || boost::iends_with(filename, L".aac") || boost::iends_with(filename, L".m4a"))
|
503
|
+
data.reset(new ModuleData(filename));
|
504
|
+
else
|
505
|
+
#endif
|
506
|
+
{
|
507
|
+
CONSTRUCTOR_COMMON;
|
508
|
+
data.reset(new StreamData(filename));
|
509
|
+
}
|
444
510
|
}
|
445
511
|
|
446
512
|
Gosu::Song::Song(Type type, Reader reader)
|
@@ -472,7 +538,7 @@ void Gosu::Song::play(bool looping)
|
|
472
538
|
}
|
473
539
|
|
474
540
|
if (curSong == 0)
|
475
|
-
data->play();
|
541
|
+
data->play(looping);
|
476
542
|
|
477
543
|
curSong = this;
|
478
544
|
curSongLooping = looping;
|