gosu 0.7.48 → 0.7.49

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -7
  2. data/.yardopts +1 -1
  3. data/Gosu/Audio.hpp +11 -3
  4. data/Gosu/Buttons.hpp +1 -1
  5. data/Gosu/Color.hpp +11 -11
  6. data/Gosu/Graphics.hpp +11 -3
  7. data/Gosu/GraphicsBase.hpp +21 -0
  8. data/Gosu/IO.hpp +12 -2
  9. data/Gosu/Image.hpp +1 -1
  10. data/Gosu/ImageData.hpp +2 -1
  11. data/Gosu/Input.hpp +8 -1
  12. data/Gosu/Platform.hpp +21 -5
  13. data/Gosu/Sockets.hpp +22 -3
  14. data/Gosu/TR1.hpp +4 -0
  15. data/Gosu/TextInput.hpp +7 -1
  16. data/Gosu/Version.hpp +2 -2
  17. data/Gosu/Window.hpp +7 -1
  18. data/GosuImpl/Audio/ALChannelManagement.hpp +11 -1
  19. data/GosuImpl/Audio/AudioOpenAL.cpp +1 -1
  20. data/GosuImpl/Graphics/BitmapApple.mm +16 -2
  21. data/GosuImpl/Graphics/BlockAllocator.hpp +2 -1
  22. data/GosuImpl/Graphics/Color.cpp +11 -11
  23. data/GosuImpl/Graphics/DrawOpQueue.hpp +0 -2
  24. data/GosuImpl/Graphics/Font.cpp +2 -2
  25. data/GosuImpl/Graphics/GosuView.hpp +1 -17
  26. data/GosuImpl/Graphics/GosuView.mm +68 -32
  27. data/GosuImpl/Graphics/Graphics.cpp +14 -63
  28. data/GosuImpl/Graphics/Image.cpp +1 -1
  29. data/GosuImpl/Graphics/LargeImageData.hpp +3 -2
  30. data/GosuImpl/Graphics/Macro.hpp +7 -6
  31. data/GosuImpl/Graphics/TexChunk.cpp +2 -2
  32. data/GosuImpl/Graphics/TexChunk.hpp +1 -1
  33. data/GosuImpl/Graphics/Texture.cpp +3 -3
  34. data/GosuImpl/Graphics/Texture.hpp +1 -1
  35. data/GosuImpl/Iconv.hpp +0 -5
  36. data/GosuImpl/InputTouch.mm +2 -12
  37. data/GosuImpl/WindowTouch.mm +70 -34
  38. data/GosuImpl/WindowWin.cpp +2 -2
  39. data/GosuImpl/WindowX.cpp +4 -4
  40. data/linux/extconf.rb +10 -2
  41. data/reference/gosu.rb +848 -266
  42. metadata +26 -46
  43. data/Gosu/Async.hpp +0 -50
  44. data/GosuImpl/Async.cpp +0 -38
  45. data/GosuImpl/Orientation.hpp +0 -15
  46. data/GosuImpl/Orientation.mm +0 -34
  47. data/GosuImpl/RubyGosuStub.mm +0 -52
  48. data/reference/Drawing_with_Colors.rdoc +0 -5
  49. data/reference/Order_of_Corners.rdoc +0 -5
  50. data/reference/Tileability.rdoc +0 -11
  51. data/reference/Z_Ordering.rdoc +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA512:
3
- metadata.gz: 12757ae26d02d3cad60c1062c94d9a66d5ad2ecbfebea61eee6a3e92ec35127f4a60a89e536be7cc212962e0feb2d721a744f5a7f604db4682ce2fa532487e03
4
- data.tar.gz: 83b6d27a97e32233878676f797275e593efd5946fe5e41c093937e20bb6767f969e257693b5df4fd071883aa7ed14b8a545567cd57bf199058b4a54b92503174
5
- SHA1:
6
- metadata.gz: 4cc0bdd7ce334c6f0d65250719b6f44a3965eaf2
7
- data.tar.gz: 1b6a3594dd5ab71455bec96cf0d345bcd0e4cc42
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 98fdd3c3dcad165605ab512fee4b11d77b9f9741
4
+ data.tar.gz: fe97e808302d1523a11ae40f9e0ec6d8be646573
5
+ SHA512:
6
+ metadata.gz: b0280a8ed1bc01d4384e8cc70ed1686b62f5ac4b81a6197039a563b37c00f9a583416226bb2c96ee61dee042f02c58c594069207d95d9c53be5d304956ade982
7
+ data.tar.gz: 1c9030d88de771441d8f7ea87297e22c55f600bf9b7c06e379a6a5e64f18902405e0bd8186e9fddbccf92351396af1fa0c9c0c91a9e5ad13d3f15ee5bb923c21
data/.yardopts CHANGED
@@ -1 +1 @@
1
- reference/gosu.rb - README.txt COPYING reference/*.rdoc --output reference/rdoc
1
+ reference/*.rb - README.txt COPYING reference/*.md --markup markdown -M rdiscount --output reference/rdoc
@@ -21,7 +21,7 @@ namespace Gosu
21
21
  {
22
22
  // Deprecated.
23
23
  #ifndef SWIG
24
- GOSU_DEPRECATED class Audio;
24
+ class GOSU_DEPRECATED Audio;
25
25
  #endif
26
26
 
27
27
  //! An instance of a Sample playing. Can be used to stop sounds dynamically,
@@ -109,10 +109,18 @@ namespace Gosu
109
109
  class BaseData;
110
110
  class ModuleData;
111
111
  class StreamData;
112
+ GOSU_UNIQUE_PTR<BaseData> data;
113
+
114
+ #if defined(GOSU_CPP11_ENABLED)
115
+ Song(Song&&) = delete;
116
+ Song& operator=(Song&&) = delete;
117
+ Song(const Song&) = delete;
118
+ Song& operator=(const Song&) = delete;
119
+ #else
112
120
  Song(const Song&);
113
121
  Song& operator=(const Song&);
114
- std::auto_ptr<BaseData> data;
115
-
122
+ #endif
123
+
116
124
  public:
117
125
  //! Constructs a song that can be played on the provided audio system
118
126
  //! and loads the song from a file. The type is determined from the
@@ -253,7 +253,7 @@ namespace Gosu
253
253
  kbNum = kbRangeEnd - kbRangeBegin + 1,
254
254
  msNum = msRangeEnd - msRangeBegin + 1,
255
255
  gpNum = gpRangeEnd - gpRangeBegin + 1,
256
- gpNumPerGamepad = gpNum / (numGamepads + 1),
256
+ gpNumPerGamepad = gpNum / (numGamepads + 1)
257
257
  };
258
258
  }
259
259
 
@@ -186,18 +186,18 @@ namespace Gosu
186
186
 
187
187
  namespace Colors
188
188
  {
189
- const Color none = 0x00000000;
190
- const Color black = 0xff000000;
191
- const Color gray = 0xff808080;
192
- const Color white = 0xffffffff;
189
+ GOSU_DEPRECATED const Color none (0x00000000);
190
+ GOSU_DEPRECATED const Color black (0xff000000);
191
+ GOSU_DEPRECATED const Color gray (0xff808080);
192
+ GOSU_DEPRECATED const Color white (0xffffffff);
193
193
 
194
- const Color aqua = 0xff00ffff;
195
- const Color red = 0xffff0000;
196
- const Color green = 0xff00ff00;
197
- const Color blue = 0xff0000ff;
198
- const Color yellow = 0xffffff00;
199
- const Color fuchsia = 0xffff00ff;
200
- const Color cyan = 0xff00ffff;
194
+ GOSU_DEPRECATED const Color aqua (0xff00ffff);
195
+ GOSU_DEPRECATED const Color red (0xffff0000);
196
+ GOSU_DEPRECATED const Color green (0xff00ff00);
197
+ GOSU_DEPRECATED const Color blue (0xff0000ff);
198
+ GOSU_DEPRECATED const Color yellow (0xffffff00);
199
+ GOSU_DEPRECATED const Color fuchsia (0xffff00ff);
200
+ GOSU_DEPRECATED const Color cyan (0xff00ffff);
201
201
  }
202
202
  }
203
203
 
@@ -49,7 +49,15 @@ namespace Gosu
49
49
  class Graphics
50
50
  {
51
51
  struct Impl;
52
- const std::auto_ptr<Impl> pimpl;
52
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
53
+
54
+ #if defined(GOSU_CPP11_ENABLED)
55
+ // explicitly forbid copying and moving
56
+ Graphics(Graphics&&) = delete;
57
+ Graphics& operator=(Graphics&&) = delete;
58
+ Graphics(const Graphics&) = delete;
59
+ Graphics& operator=(const Graphics&) = delete;
60
+ #endif
53
61
 
54
62
  public:
55
63
  Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
@@ -97,7 +105,7 @@ namespace Gosu
97
105
  //! the resulting macro will simply return these values when you ask
98
106
  //! it.
99
107
  //! Most usually, the return value is passed to Image::Image().
100
- std::auto_ptr<Gosu::ImageData> endRecording(int width, int height);
108
+ GOSU_UNIQUE_PTR<Gosu::ImageData> endRecording(int width, int height);
101
109
 
102
110
  //! Pushes one transformation onto the transformation stack.
103
111
  void pushTransform(const Transform& transform);
@@ -125,7 +133,7 @@ namespace Gosu
125
133
 
126
134
  //! Turns a portion of a bitmap into something that can be drawn on
127
135
  //! this graphics object.
128
- std::auto_ptr<ImageData> createImage(const Bitmap& src,
136
+ GOSU_UNIQUE_PTR<ImageData> createImage(const Bitmap& src,
129
137
  unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
130
138
  unsigned borderFlags);
131
139
  };
@@ -16,6 +16,26 @@ namespace Gosu
16
16
 
17
17
  //! Determines the way colors are combined when one is drawn onto
18
18
  //! another.
19
+ #if defined(GOSU_CPP11_ENABLED)
20
+ enum class AlphaMode
21
+ {
22
+ //! The color's channels will be interpolated. The alpha channel
23
+ //! specifies the opacity of the new color, 255 is full opacity.
24
+ DEFAULT,
25
+ INTERPOLATE = DEFAULT,
26
+ //! The colors' channels will be added. The alpha channel specifies
27
+ //! the percentage of the new color's channels that will be added
28
+ //! to the old color's channels.
29
+ ADD,
30
+ //! The color's channels will be multiplied with each other.
31
+ MULTIPLY
32
+ };
33
+ GOSU_DEPRECATED constexpr AlphaMode amDefault = AlphaMode::DEFAULT;
34
+ GOSU_DEPRECATED constexpr AlphaMode amInterpolate = AlphaMode::INTERPOLATE;
35
+ GOSU_DEPRECATED constexpr AlphaMode amAdd = AlphaMode::ADD;
36
+ GOSU_DEPRECATED constexpr AlphaMode amAdditive = AlphaMode::ADD;
37
+ GOSU_DEPRECATED constexpr AlphaMode amMultiply = AlphaMode::MULTIPLY;
38
+ #else
19
39
  enum AlphaMode
20
40
  {
21
41
  //! The color's channels will be interpolated. The alpha channel
@@ -29,6 +49,7 @@ namespace Gosu
29
49
  //! The color's channels will be multiplied with each other.
30
50
  amMultiply
31
51
  };
52
+ #endif
32
53
 
33
54
  enum FontFlags
34
55
  {
@@ -9,6 +9,7 @@
9
9
  #include <memory>
10
10
  #include <string>
11
11
  #include <vector>
12
+ #include <Gosu/Platform.hpp>
12
13
 
13
14
  namespace Gosu
14
15
  {
@@ -141,8 +142,16 @@ namespace Gosu
141
142
  class Resource
142
143
  {
143
144
  // Non-copyable
145
+ #if defined(GOSU_CPP11_ENABLED)
146
+ Resource(const Resource&) = delete;
147
+ Resource& operator=(const Resource&) = delete;
148
+ // and non-movable
149
+ Resource(Resource&&) = delete;
150
+ Resource& operator=(Resource&&) = delete;
151
+ #else
144
152
  Resource(const Resource&);
145
153
  Resource& operator=(const Resource&);
154
+ #endif
146
155
 
147
156
  public:
148
157
  Resource()
@@ -189,7 +198,8 @@ namespace Gosu
189
198
  }
190
199
 
191
200
  Buffer(const Buffer& other)
192
- : buf(other.buf)
201
+ : Resource()
202
+ , buf(other.buf)
193
203
  {
194
204
  }
195
205
 
@@ -236,7 +246,7 @@ namespace Gosu
236
246
  class File : public Resource
237
247
  {
238
248
  struct Impl;
239
- const std::auto_ptr<Impl> pimpl;
249
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
240
250
 
241
251
  public:
242
252
  explicit File(const std::wstring& filename, FileMode mode = fmRead);
@@ -46,7 +46,7 @@ namespace Gosu
46
46
  bool tileable = false);
47
47
 
48
48
  //! Creates an Image from a user-supplied instance of the ImageData interface.
49
- explicit Image(std::auto_ptr<ImageData> data);
49
+ explicit Image(GOSU_UNIQUE_PTR<ImageData> data);
50
50
 
51
51
  unsigned width() const;
52
52
  unsigned height() const;
@@ -7,6 +7,7 @@
7
7
  #include <Gosu/Color.hpp>
8
8
  #include <Gosu/GraphicsBase.hpp>
9
9
  #include <Gosu/Fwd.hpp>
10
+ #include <Gosu/Platform.hpp>
10
11
 
11
12
  namespace Gosu
12
13
  {
@@ -51,7 +52,7 @@ namespace Gosu
51
52
  virtual const GLTexInfo* glTexInfo() const = 0;
52
53
  virtual Bitmap toBitmap() const = 0;
53
54
 
54
- virtual std::auto_ptr<ImageData> subimage(int x, int y, int width, int height) const = 0;
55
+ virtual GOSU_UNIQUE_PTR<ImageData> subimage(int x, int y, int width, int height) const = 0;
55
56
 
56
57
  virtual void insert(const Bitmap& bitmap, int x, int y) = 0;
57
58
  };
@@ -75,7 +75,14 @@ namespace Gosu
75
75
  class Input
76
76
  {
77
77
  struct Impl;
78
- const std::auto_ptr<Impl> pimpl;
78
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
79
+ #if defined(GOSU_CPP11_ENABLED)
80
+ // explicitly forbid copying and moving
81
+ Input(Input&&) = delete;
82
+ Input& operator=(Input&&) = delete;
83
+ Input(const Input&) = delete;
84
+ Input& operator=(const Input&) = delete;
85
+ #endif
79
86
 
80
87
  public:
81
88
  #ifdef GOSU_IS_WIN
@@ -62,12 +62,28 @@ namespace Gosu
62
62
  # endif
63
63
  #endif
64
64
 
65
- #if defined(GOSU_IS_WIN)
66
- # define GOSU_DEPRECATED __declspec(deprecated)
67
- #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
68
- # define GOSU_DEPRECATED __attribute__((__deprecated__))
65
+ #ifndef SWIG
66
+ # if (defined(_MSC_VER) && _MSC_VER >= 1700) || ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__))
67
+ # define GOSU_CPP11_ENABLED
68
+ # endif
69
+ #endif
70
+
71
+ #ifdef GOSU_CPP11_ENABLED
72
+ # define GOSU_UNIQUE_PTR std::unique_ptr
73
+ # define GOSU_MOVE_UNIQUE_PTR(ptr) std::move(ptr)
69
74
  #else
70
- # define GOSU_DEPRECATED
75
+ # define GOSU_UNIQUE_PTR std::auto_ptr
76
+ # define GOSU_MOVE_UNIQUE_PTR(ptr) (ptr)
77
+ #endif
78
+
79
+ #ifndef GOSU_DEPRECATED
80
+ # if defined(GOSU_IS_WIN)
81
+ # define GOSU_DEPRECATED __declspec(deprecated)
82
+ # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
83
+ # define GOSU_DEPRECATED __attribute__((__deprecated__))
84
+ # else
85
+ # define GOSU_DEPRECATED
86
+ # endif
71
87
  #endif
72
88
 
73
89
  #endif
@@ -7,6 +7,7 @@
7
7
  #include <Gosu/TR1.hpp>
8
8
  #include <cstddef>
9
9
  #include <string>
10
+ #include <Gosu/Platform.hpp>
10
11
 
11
12
  namespace Gosu
12
13
  {
@@ -35,7 +36,13 @@ namespace Gosu
35
36
  class MessageSocket
36
37
  {
37
38
  struct Impl;
38
- const std::auto_ptr<Impl> pimpl;
39
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
40
+ #if defined(GOSU_CPP11_ENABLED)
41
+ MessageSocket(const MessageSocket&) = delete;
42
+ MessageSocket& operator=(const MessageSocket&) = delete;
43
+ MessageSocket(MessageSocket&&) = delete;
44
+ MessageSocket& operator=(MessageSocket&&) = delete;
45
+ #endif
39
46
 
40
47
  public:
41
48
  //! Opens a message socket for listening at the specified port.
@@ -84,7 +91,13 @@ namespace Gosu
84
91
  class CommSocket
85
92
  {
86
93
  struct Impl;
87
- const std::auto_ptr<Impl> pimpl;
94
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
95
+ #if defined(GOSU_CPP11_ENABLED)
96
+ CommSocket(const CommSocket&) = delete;
97
+ CommSocket& operator=(const CommSocket&) = delete;
98
+ CommSocket(CommSocket&&) = delete;
99
+ CommSocket& operator=(CommSocket&&) = delete;
100
+ #endif
88
101
 
89
102
  public:
90
103
  CommSocket(CommMode mode, SocketAddress targetAddress,
@@ -117,7 +130,13 @@ namespace Gosu
117
130
  class ListenerSocket
118
131
  {
119
132
  struct Impl;
120
- const std::auto_ptr<Impl> pimpl;
133
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
134
+ #if defined(GOSU_CPP11_ENABLED)
135
+ ListenerSocket(const ListenerSocket&) = delete;
136
+ ListenerSocket& operator=(const ListenerSocket&) = delete;
137
+ ListenerSocket(ListenerSocket&&) = delete;
138
+ ListenerSocket& operator=(ListenerSocket&&) = delete;
139
+ #endif
121
140
 
122
141
  public:
123
142
  ListenerSocket(SocketPort port);
@@ -23,6 +23,10 @@
23
23
  typedef signed long long int64_t;
24
24
 
25
25
  #ifdef _LIBCPP_MEMORY
26
+ namespace placeholders
27
+ {
28
+ using namespace std::placeholders;
29
+ }
26
30
  using std::array;
27
31
  using std::bind;
28
32
  using std::function;
@@ -23,7 +23,13 @@ namespace Gosu
23
23
  class TextInput
24
24
  {
25
25
  struct Impl;
26
- const std::auto_ptr<Impl> pimpl;
26
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
27
+ #if defined(GOSU_CPP11_ENABLED)
28
+ TextInput(TextInput&&) = delete;
29
+ TextInput& operator=(TextInput&&) = delete;
30
+ TextInput(const TextInput&) = delete;
31
+ TextInput& operator=(const TextInput&) = delete;
32
+ #endif
27
33
 
28
34
  public:
29
35
  TextInput();
@@ -3,8 +3,8 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 7
6
- #define GOSU_POINT_VERSION 48
7
- #define GOSU_VERSION "0.7.48"
6
+ #define GOSU_POINT_VERSION 49
7
+ #define GOSU_VERSION "0.7.49"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  " " \
@@ -28,7 +28,13 @@ namespace Gosu
28
28
  class Window
29
29
  {
30
30
  struct Impl;
31
- const std::auto_ptr<Impl> pimpl;
31
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
32
+ #if defined(GOSU_CPP11_ENABLED)
33
+ Window(Window&&) = delete;
34
+ Window& operator=(Window&&) = delete;
35
+ Window(const Window&) = delete;
36
+ Window& operator=(const Window&) = delete;
37
+ #endif
32
38
 
33
39
  public:
34
40
  //! Constructs a Window.
@@ -39,6 +39,11 @@ namespace Gosu
39
39
  return alDevice;
40
40
  }
41
41
 
42
+ static ALCcontext* context()
43
+ {
44
+ return alContext;
45
+ }
46
+
42
47
  ALChannelManagement()
43
48
  {
44
49
  // Open preferred device
@@ -95,10 +100,15 @@ namespace Gosu
95
100
  ALuint ALChannelManagement::currentToken = 0;
96
101
  ALuint ALChannelManagement::currentTokens[NUM_SOURCES];
97
102
 
98
- std::auto_ptr<ALChannelManagement> alChannelManagement;
103
+ GOSU_UNIQUE_PTR<ALChannelManagement> alChannelManagement;
99
104
 
100
105
  void releaseAllOpenALResources()
101
106
  {
102
107
  alChannelManagement.reset();
103
108
  }
109
+
110
+ ALCcontext *sharedContext()
111
+ {
112
+ return ALChannelManagement::context();
113
+ }
104
114
  }
@@ -327,7 +327,7 @@ public:
327
327
  // AudioFile impl
328
328
  class Gosu::Song::StreamData : public BaseData
329
329
  {
330
- std::auto_ptr<AudioFile> file;
330
+ GOSU_UNIQUE_PTR<AudioFile> file;
331
331
  ALuint buffers[2];
332
332
 
333
333
  void applyVolume()
@@ -97,9 +97,23 @@ namespace Gosu { bool isExtension(const wchar_t* str, const wchar_t* ext); }
97
97
  void Gosu::loadImageFile(Bitmap& bitmap, const std::wstring& filename)
98
98
  {
99
99
  ObjRef<NSAutoreleasePool> pool([NSAutoreleasePool new]);
100
+ ObjRef<APPLE_IMAGE> image;
100
101
  ObjRef<NSString> filenameRef([[NSString alloc] initWithUTF8String: wstringToUTF8(filename).c_str()]);
101
- ObjRef<APPLE_IMAGE> image([[APPLE_IMAGE alloc] initWithContentsOfFile: filenameRef.obj()]);
102
- if (!image.get())
102
+
103
+ #ifdef GOSU_IS_IPHONE
104
+ if ([UIScreen mainScreen].scale > 1) {
105
+ #endif
106
+ // Prevent app from automatically appending @2x to full filenames by loading into an NSData object first
107
+ NSData *data = [NSData dataWithContentsOfFile:filenameRef.obj()];
108
+ image.reset([[APPLE_IMAGE alloc] initWithData:data]);
109
+ #ifdef GOSU_IS_IPHONE
110
+ }
111
+ else {
112
+ image.reset([[APPLE_IMAGE alloc] initWithContentsOfFile:filenameRef.obj()]);
113
+ }
114
+ #endif
115
+
116
+ if (! image.get())
103
117
  throw std::runtime_error("Cannot load image file " + wstringToUTF8(filename));
104
118
 
105
119
  appleImageToBitmap(image.obj(), bitmap);