gosu 0.10.9.pre1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/Gosu/Audio.hpp +35 -66
  3. data/Gosu/AutoLink.hpp +14 -16
  4. data/Gosu/Bitmap.hpp +50 -37
  5. data/Gosu/Buttons.hpp +246 -265
  6. data/Gosu/Color.hpp +32 -76
  7. data/Gosu/Directories.hpp +14 -17
  8. data/Gosu/Font.hpp +28 -34
  9. data/Gosu/Fwd.hpp +27 -31
  10. data/Gosu/Gosu.hpp +2 -5
  11. data/Gosu/Graphics.hpp +31 -48
  12. data/Gosu/GraphicsBase.hpp +27 -58
  13. data/Gosu/IO.hpp +44 -56
  14. data/Gosu/Image.hpp +29 -73
  15. data/Gosu/ImageData.hpp +13 -17
  16. data/Gosu/Input.hpp +42 -57
  17. data/Gosu/Inspection.hpp +2 -6
  18. data/Gosu/Math.hpp +32 -38
  19. data/Gosu/Platform.hpp +10 -29
  20. data/Gosu/Text.hpp +30 -39
  21. data/Gosu/TextInput.hpp +29 -36
  22. data/Gosu/Timing.hpp +14 -16
  23. data/Gosu/Utility.hpp +10 -15
  24. data/Gosu/Version.hpp +13 -14
  25. data/Gosu/Window.hpp +53 -68
  26. data/README.md +23 -11
  27. data/ext/gosu/extconf.rb +31 -81
  28. data/lib/gosu/patches.rb +35 -19
  29. data/lib/gosu/run.rb +13 -4
  30. data/rdoc/gosu.rb +24 -20
  31. data/src/ALChannelManagement.hpp +119 -0
  32. data/src/{Audio/Audio.cpp → Audio.cpp} +177 -211
  33. data/src/AudioFile.hpp +57 -0
  34. data/src/AudioToolboxFile.hpp +214 -0
  35. data/src/Bitmap.cpp +159 -0
  36. data/src/BitmapIO.cpp +141 -0
  37. data/src/BlockAllocator.cpp +133 -0
  38. data/src/{Graphics/BlockAllocator.hpp → BlockAllocator.hpp} +34 -35
  39. data/src/ClipRectStack.hpp +87 -0
  40. data/src/{Graphics/Color.cpp → Color.cpp} +30 -28
  41. data/src/DirectoriesApple.cpp +68 -0
  42. data/src/DirectoriesUnix.cpp +20 -18
  43. data/src/DirectoriesWin.cpp +40 -41
  44. data/src/DrawOp.hpp +168 -0
  45. data/src/DrawOpQueue.hpp +190 -0
  46. data/src/FileUnix.cpp +40 -46
  47. data/src/FileWin.cpp +42 -38
  48. data/src/Font.cpp +165 -0
  49. data/src/{Text/FormattedString.hpp → FormattedString.hpp} +114 -114
  50. data/src/GosuAppDelegate.cpp +30 -0
  51. data/src/{UIKit/GosuAppDelegate.h → GosuAppDelegate.h} +0 -0
  52. data/src/{UIKit/GosuGLView.mm → GosuGLView.cpp} +22 -17
  53. data/src/{UIKit/GosuGLView.h → GosuGLView.h} +0 -0
  54. data/src/GosuViewController.cpp +231 -0
  55. data/src/{UIKit/GosuViewController.h → GosuViewController.h} +0 -0
  56. data/src/Graphics.cpp +464 -0
  57. data/src/{Graphics/Common.hpp → GraphicsImpl.hpp} +29 -32
  58. data/src/IO.cpp +17 -16
  59. data/src/Iconv.hpp +13 -22
  60. data/src/Image.cpp +142 -0
  61. data/src/Input.cpp +459 -0
  62. data/src/InputUIKit.cpp +197 -0
  63. data/src/Inspection.cpp +4 -5
  64. data/src/LargeImageData.cpp +151 -0
  65. data/src/LargeImageData.hpp +43 -0
  66. data/src/{Graphics/Macro.cpp → Macro.cpp} +77 -78
  67. data/src/Macro.hpp +30 -0
  68. data/src/Math.cpp +17 -29
  69. data/src/{Audio/OggFile.hpp → OggFile.hpp} +19 -24
  70. data/src/RenderState.hpp +205 -0
  71. data/src/Resolution.cpp +86 -0
  72. data/src/ResolutionApple.cpp +25 -0
  73. data/{ext/gosu/gosu_wrap.cxx → src/RubyGosu.cxx} +2256 -1707
  74. data/{ext/gosu/gosu_wrap.h → src/RubyGosu.h} +9 -9
  75. data/src/{Audio/SndFile.hpp → SndFile.hpp} +54 -43
  76. data/src/TexChunk.cpp +117 -0
  77. data/src/{Graphics/TexChunk.hpp → TexChunk.hpp} +13 -18
  78. data/src/Text.cpp +371 -0
  79. data/src/TextApple.cpp +209 -0
  80. data/src/TextInput.cpp +278 -0
  81. data/src/TextTTFWin.cpp +251 -0
  82. data/src/{Text/TextUnix.cpp → TextUnix.cpp} +96 -92
  83. data/src/TextWin.cpp +194 -0
  84. data/src/{Graphics/Texture.cpp → Texture.cpp} +35 -38
  85. data/src/{Graphics/Texture.hpp → Texture.hpp} +9 -13
  86. data/src/TimingApple.cpp +11 -7
  87. data/src/TimingUnix.cpp +13 -7
  88. data/src/TimingWin.cpp +6 -1
  89. data/src/{Graphics/Transform.cpp → Transform.cpp} +17 -12
  90. data/src/{Graphics/TransformStack.hpp → TransformStack.hpp} +24 -25
  91. data/src/Utility.cpp +29 -70
  92. data/src/UtilityApple.cpp +52 -0
  93. data/src/UtilityWin.cpp +7 -4
  94. data/src/Version.cpp +22 -0
  95. data/src/WinMain.cpp +30 -33
  96. data/src/WinUtility.cpp +24 -22
  97. data/src/WinUtility.hpp +11 -20
  98. data/src/Window.cpp +142 -112
  99. data/src/WindowUIKit.cpp +155 -0
  100. data/src/stb_image.h +384 -173
  101. data/src/stb_vorbis.c +20 -18
  102. metadata +60 -62
  103. data/Gosu/TR1.hpp +0 -56
  104. data/src/AppleUtility.hpp +0 -66
  105. data/src/Audio/ALChannelManagement.hpp +0 -114
  106. data/src/Audio/Audio.mm +0 -1
  107. data/src/Audio/AudioFile.hpp +0 -53
  108. data/src/Audio/AudioToolboxFile.hpp +0 -207
  109. data/src/Bitmap/Bitmap.cpp +0 -183
  110. data/src/Bitmap/BitmapIO.cpp +0 -176
  111. data/src/DirectoriesApple.mm +0 -71
  112. data/src/Graphics/BlockAllocator.cpp +0 -142
  113. data/src/Graphics/ClipRectStack.hpp +0 -93
  114. data/src/Graphics/DrawOp.hpp +0 -175
  115. data/src/Graphics/DrawOpQueue.hpp +0 -188
  116. data/src/Graphics/Graphics.cpp +0 -478
  117. data/src/Graphics/Image.cpp +0 -193
  118. data/src/Graphics/LargeImageData.cpp +0 -133
  119. data/src/Graphics/LargeImageData.hpp +0 -46
  120. data/src/Graphics/Macro.hpp +0 -36
  121. data/src/Graphics/RenderState.hpp +0 -211
  122. data/src/Graphics/Resolution.cpp +0 -91
  123. data/src/Graphics/ResolutionApple.mm +0 -19
  124. data/src/Graphics/TexChunk.cpp +0 -112
  125. data/src/Input/Input.cpp +0 -463
  126. data/src/Input/InputUIKit.mm +0 -190
  127. data/src/Input/TextInput.cpp +0 -261
  128. data/src/Text/Font.cpp +0 -175
  129. data/src/Text/Text.cpp +0 -391
  130. data/src/Text/TextApple.mm +0 -227
  131. data/src/Text/TextTTFWin.cpp +0 -249
  132. data/src/Text/TextWin.cpp +0 -186
  133. data/src/UIKit/GosuAppDelegate.mm +0 -24
  134. data/src/UIKit/GosuViewController.mm +0 -211
  135. data/src/UtilityApple.mm +0 -63
  136. data/src/WindowUIKit.mm +0 -139
@@ -1,13 +1,12 @@
1
1
  //! \file Graphics.hpp
2
2
  //! Interface of the Graphics class.
3
3
 
4
- #ifndef GOSU_GRAPHICS_HPP
5
- #define GOSU_GRAPHICS_HPP
4
+ #pragma once
6
5
 
7
6
  #include <Gosu/Fwd.hpp>
8
7
  #include <Gosu/Color.hpp>
9
8
  #include <Gosu/GraphicsBase.hpp>
10
- #include <Gosu/TR1.hpp>
9
+ #include <functional>
11
10
  #include <memory>
12
11
 
13
12
  namespace Gosu
@@ -17,44 +16,30 @@ namespace Gosu
17
16
  //! Returns the maximum size of an texture that will be allocated
18
17
  //! internally by Gosu.
19
18
  //! Useful when extending Gosu using OpenGL.
20
- unsigned const MAX_TEXTURE_SIZE = 1024;
19
+ const unsigned MAX_TEXTURE_SIZE = 1024;
21
20
 
22
21
  //! Serves as the target of all drawing and provides primitive drawing
23
22
  //! functionality.
24
23
  //! Usually created internally by Gosu::Window.
25
- //
26
- // TODO: This class should be separated into a Gosu::Viewport class, which
27
- // carries the width/height/fullscreen attributes, and global Gosu::drawFoo
28
- // functions. A Window then has a Viewport, and in theory, multiple windows
29
- // could have their own viewports etc.
30
24
  class Graphics
31
25
  {
32
26
  struct Impl;
27
+ // Non-movable (const) to avoid dangling internal references.
28
+ const std::unique_ptr<Impl> pimpl;
33
29
 
34
- const GOSU_UNIQUE_PTR<Impl> pimpl;
35
-
36
- #if defined(GOSU_CPP11_ENABLED)
37
- // explicitly forbid copying and moving
38
- Graphics(Graphics&&) = delete;
39
- Graphics& operator=(Graphics&&) = delete;
40
- Graphics(const Graphics&) = delete;
41
- Graphics& operator=(const Graphics&) = delete;
42
- #endif
43
-
44
30
  public:
45
- Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
31
+ Graphics(unsigned physical_width, unsigned physical_height);
46
32
  ~Graphics();
47
33
 
48
- void setResolution(unsigned logicalWidth, unsigned logicalHeight,
49
- double horizontalBlackBarWidth = 0, double verticalBlackBarHeight = 0);
34
+ void set_resolution(unsigned logical_width, unsigned logical_height,
35
+ double horizontal_black_bar_width = 0, double vertical_black_bar_height = 0);
50
36
 
51
37
  unsigned width() const;
52
38
  unsigned height() const;
53
- bool fullscreen() const;
54
39
 
55
40
  //! Prepares the graphics object for drawing. Nothing must be drawn
56
41
  //! without calling begin.
57
- bool begin(Color clearWithColor = Color::BLACK);
42
+ bool begin(Color clear_with_color = Color::BLACK);
58
43
  //! Every call to begin must have a matching call to end.
59
44
  void end();
60
45
 
@@ -64,65 +49,63 @@ namespace Gosu
64
49
 
65
50
  //! Finishes all pending Gosu drawing operations and executes
66
51
  //! the following OpenGL code in a clean environment.
67
- static void beginGL();
52
+ static void begin_gl();
68
53
  //! Resets Gosu into its default rendering state.
69
- static void endGL();
54
+ static void end_gl();
70
55
  //! Schedules a custom GL functor to be executed at a certain Z level.
71
- //! The functor is called in a clean GL context (as given by beginGL/endGL).
56
+ //! The functor is called in a clean GL context (as given by begin_gl/end_gl).
72
57
  //! Gosu's rendering up to the Z level may not yet have been glFlush()ed.
73
58
  //! Note: You may not call any Gosu rendering functions from within the
74
59
  //! functor, and you must schedule it from within Window::draw's call tree.
75
- static void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
60
+ static void gl(const std::function<void ()>& functor, ZPos z);
76
61
 
77
62
  //! Enables clipping to a specified rectangle.
78
- static void beginClipping(double x, double y, double width, double height);
63
+ static void begin_clipping(double x, double y, double width, double height);
79
64
  //! Disables clipping.
80
- static void endClipping();
65
+ static void end_clipping();
81
66
 
82
67
  //! Starts recording a macro. Cannot be nested.
83
- static void beginRecording();
68
+ static void begin_recording();
84
69
  //! Finishes building the macro and returns it as a drawable object.
85
70
  //! The width and height affect nothing about the recording process,
86
71
  //! the resulting macro will simply return these values when you ask
87
72
  //! it.
88
73
  //! Most usually, the return value is passed to Image::Image().
89
- static GOSU_UNIQUE_PTR<Gosu::ImageData> endRecording(int width, int height);
74
+ static std::unique_ptr<Gosu::ImageData> end_recording(int width, int height);
90
75
 
91
76
  //! Pushes one transformation onto the transformation stack.
92
- static void pushTransform(const Transform& transform);
77
+ static void push_transform(const Transform& transform);
93
78
  //! Pops one transformation from the transformation stack.
94
- static void popTransform();
79
+ static void pop_transform();
95
80
 
96
81
  //! Draws a line from one point to another (last pixel exclusive).
97
82
  //! Note: OpenGL lines are not reliable at all and may have a missing pixel at the start
98
83
  //! or end point. Please only use this for debugging purposes. Otherwise, use a quad or
99
- //! image to simulate lines, or contribute a better drawLine to Gosu.
100
- static void drawLine(double x1, double y1, Color c1,
84
+ //! image to simulate lines, or contribute a better draw_line to Gosu.
85
+ static void draw_line(double x1, double y1, Color c1,
101
86
  double x2, double y2, Color c2,
102
- ZPos z, AlphaMode mode = amDefault);
87
+ ZPos z, AlphaMode mode = AM_DEFAULT);
103
88
 
104
- static void drawTriangle(double x1, double y1, Color c1,
89
+ static void draw_triangle(double x1, double y1, Color c1,
105
90
  double x2, double y2, Color c2,
106
91
  double x3, double y3, Color c3,
107
- ZPos z, AlphaMode mode = amDefault);
92
+ ZPos z, AlphaMode mode = AM_DEFAULT);
108
93
 
109
- static void drawQuad(double x1, double y1, Color c1,
94
+ static void draw_quad(double x1, double y1, Color c1,
110
95
  double x2, double y2, Color c2,
111
96
  double x3, double y3, Color c3,
112
97
  double x4, double y4, Color c4,
113
- ZPos z, AlphaMode mode = amDefault);
98
+ ZPos z, AlphaMode mode = AM_DEFAULT);
114
99
 
115
100
  //! For internal use only.
116
- void setPhysicalResolution(unsigned physicalWidth, unsigned physicalHeight);
101
+ void set_physical_resolution(unsigned physical_width, unsigned physical_height);
117
102
 
118
103
  //! For internal use only.
119
- static void scheduleDrawOp(const DrawOp& op);
104
+ static void schedule_draw_op(const DrawOp& op);
120
105
 
121
106
  //! Turns a portion of a bitmap into something that can be drawn on a Graphics object.
122
- static GOSU_UNIQUE_PTR<ImageData> createImage(const Bitmap& src,
123
- unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
124
- unsigned imageFlags);
107
+ static std::unique_ptr<ImageData> create_image(const Bitmap& src,
108
+ unsigned src_x, unsigned src_y, unsigned src_width, unsigned src_height,
109
+ unsigned image_flags);
125
110
  };
126
111
  }
127
-
128
- #endif
@@ -1,104 +1,73 @@
1
1
  //! \file GraphicsBase.hpp
2
2
  //! Contains general typedefs and enums related to graphics.
3
3
 
4
- #ifndef GOSU_GRAPHICSBASE_HPP
5
- #define GOSU_GRAPHICSBASE_HPP
4
+ #pragma once
6
5
 
7
6
  #include <Gosu/Platform.hpp>
8
- #include <Gosu/TR1.hpp>
9
- #include <limits>
7
+ #include <array>
10
8
 
11
9
  namespace Gosu
12
10
  {
13
11
  //! Represents the Z position of something drawn with Gosu's graphics
14
12
  //! system. Draw calls with higher ZPos values will cover those with a
15
- //! lower ZPos value, that is, they are performed last.
13
+ //! lower ZPos value.
16
14
  typedef double ZPos;
17
15
 
18
16
  //! Determines the way colors are combined when one is drawn onto
19
17
  //! another.
20
- #if defined(GOSU_CPP11_ENABLED)
21
- enum class AlphaMode
22
- {
23
- //! The color's channels will be interpolated. The alpha channel
24
- //! specifies the opacity of the new color, 255 is full opacity.
25
- DEFAULT,
26
- INTERPOLATE = DEFAULT,
27
- //! The colors' channels will be added. The alpha channel specifies
28
- //! the percentage of the new color's channels that will be added
29
- //! to the old color's channels.
30
- ADD,
31
- //! The color's channels will be multiplied with each other.
32
- MULTIPLY
33
- };
34
- constexpr AlphaMode amDefault = AlphaMode::DEFAULT;
35
- constexpr AlphaMode amInterpolate = AlphaMode::INTERPOLATE;
36
- constexpr AlphaMode amAdd = AlphaMode::ADD;
37
- constexpr AlphaMode amAdditive = AlphaMode::ADD;
38
- constexpr AlphaMode amMultiply = AlphaMode::MULTIPLY;
39
- #else
40
18
  enum AlphaMode
41
19
  {
20
+ AM_DEFAULT,
42
21
  //! The color's channels will be interpolated. The alpha channel
43
22
  //! specifies the opacity of the new color, 255 is full opacity.
44
- amDefault,
23
+ AM_INTERPOLATE = AM_DEFAULT,
45
24
  //! The colors' channels will be added. The alpha channel specifies
46
25
  //! the percentage of the new color's channels that will be added
47
26
  //! to the old color's channels.
48
- amAdd,
49
- amAdditive = amAdd,
27
+ AM_ADD,
50
28
  //! The color's channels will be multiplied with each other.
51
- amMultiply
29
+ AM_MULTIPLY
52
30
  };
53
- #endif
54
31
 
55
32
  enum FontFlags
56
33
  {
57
- ffBold = 1,
58
- ffItalic = 2,
59
- ffUnderline = 4,
60
- ffCombinations = 8
34
+ FF_BOLD = 1,
35
+ FF_ITALIC = 2,
36
+ FF_UNDERLINE = 4,
37
+ FF_COMBINATIONS = 8
61
38
  };
62
39
 
63
- enum TextAlign
40
+ enum Alignment
64
41
  {
65
- taLeft,
66
- taRight,
67
- taCenter,
68
- taJustify
42
+ AL_LEFT,
43
+ AL_RIGHT,
44
+ AL_CENTER,
45
+ AL_JUSTIFY
69
46
  };
70
47
 
71
48
  //! Flags that affect the tileability or interpolation of an image.
72
49
  enum ImageFlags
73
50
  {
74
- ifSmooth = 0,
51
+ IF_SMOOTH = 0,
75
52
 
76
- // Note: No constant for '1', but Gosu treats '1' as ifTileable for
53
+ // Note: No constant for '1', but Gosu treats '1' as if_tileable for
77
54
  // backward compatibility reasons (this parameter used to be a bool).
78
55
 
79
- ifTileableLeft = 1 << 1,
80
- ifTileableTop = 1 << 2,
81
- ifTileableRight = 1 << 3,
82
- ifTileableBottom = 1 << 4,
83
- ifTileable = ifTileableLeft | ifTileableTop | ifTileableRight | ifTileableBottom,
56
+ IF_TILEABLE_LEFT = 1 << 1,
57
+ IF_TILEABLE_TOP = 1 << 2,
58
+ IF_TILEABLE_RIGHT = 1 << 3,
59
+ IF_TILEABLE_BOTTOM = 1 << 4,
60
+ IF_TILEABLE = IF_TILEABLE_LEFT | IF_TILEABLE_TOP | IF_TILEABLE_RIGHT | IF_TILEABLE_BOTTOM,
84
61
 
85
62
  //! Apply nearest-neighbor interpolation when scaling this image up or
86
63
  //! down.
87
- ifRetro = 1 << 5
64
+ IF_RETRO = 1 << 5
88
65
  };
89
66
 
90
- typedef std::tr1::array<double, 16> Transform;
67
+ typedef std::array<double, 16> Transform;
91
68
  Transform translate(double x, double y);
92
- Transform rotate(double angle, double aroundX = 0, double aroundY = 0);
69
+ Transform rotate(double angle, double around_x = 0, double around_y = 0);
93
70
  Transform scale(double factor);
94
- Transform scale(double factorX, double factorY, double fromX = 0, double fromY = 0);
71
+ Transform scale(double scale_x, double scale_y, double from_x = 0, double from_y = 0);
95
72
  Transform concat(const Transform& lhs, const Transform& rhs);
96
-
97
- #ifndef SWIG
98
- // A not so useful optimization - this was supposed to bypass the Z queue for immediate rendering.
99
- // In retrospect, the only useful optimization would be to work down the Z queue on a second thread.
100
- GOSU_DEPRECATED const double zImmediate = -std::numeric_limits<double>::infinity();
101
- #endif
102
73
  }
103
-
104
- #endif
@@ -1,25 +1,24 @@
1
1
  //! \file IO.hpp
2
2
  //! Contains everything related to input and output.
3
3
 
4
- #ifndef GOSU_IO_HPP
5
- #define GOSU_IO_HPP
4
+ #pragma once
6
5
 
7
- #include <cstddef>
6
+ #include <Gosu/Platform.hpp>
8
7
  #include <algorithm>
8
+ #include <cstddef>
9
9
  #include <memory>
10
10
  #include <string>
11
11
  #include <vector>
12
- #include <Gosu/Platform.hpp>
13
12
 
14
13
  namespace Gosu
15
14
  {
16
15
  class Resource;
17
16
 
18
- enum ByteOrder { boLittle, boBig, boDontCare };
17
+ enum ByteOrder { BO_LITTLE, BO_BIG, BO_DONT_CARE };
19
18
  #ifdef __BIG_ENDIAN__
20
- const ByteOrder nativeByteOrder = boBig, otherByteOrder = boLittle;
19
+ const ByteOrder BO_NATIVE = BO_BIG, BO_OTHER = BO_LITTLE;
21
20
  #else
22
- const ByteOrder nativeByteOrder = boLittle, otherByteOrder = boBig;
21
+ const ByteOrder BO_NATIVE = BO_LITTLE, BO_OTHER = BO_BIG;
23
22
  #endif
24
23
 
25
24
  //! Utility class that points to a specific position in a resource
@@ -45,7 +44,7 @@ namespace Gosu
45
44
  return pos;
46
45
  }
47
46
 
48
- void setPosition(std::size_t value)
47
+ void set_position(std::size_t value)
49
48
  {
50
49
  // TODO: Check?
51
50
  pos = value;
@@ -57,26 +56,25 @@ namespace Gosu
57
56
  pos += offset;
58
57
  }
59
58
 
60
- void read(void* destBuffer, std::size_t length);
59
+ void read(void* dest_buffer, std::size_t length);
61
60
 
62
61
  //! Convenience function; equivalent to read(&t, sizeof t).
63
62
  template<typename T>
64
- void readPod(T& t, ByteOrder bo = boDontCare)
63
+ void read_pod(T& t, ByteOrder bo = BO_DONT_CARE)
65
64
  {
66
65
  read(&t, sizeof t);
67
- if (bo == otherByteOrder)
68
- {
66
+ if (bo == BO_OTHER) {
69
67
  char* begin = reinterpret_cast<char*>(&t);
70
68
  std::reverse(begin, begin + sizeof t);
71
69
  }
72
70
  }
73
71
 
74
- //! Similar to readPod(T&), but returns the read value instead.
72
+ //! Similar to read_pod(T&), but returns the read value instead.
75
73
  template<typename T>
76
- T getPod(ByteOrder bo = boDontCare)
74
+ T get_pod(ByteOrder bo = BO_DONT_CARE)
77
75
  {
78
76
  T t;
79
- readPod<T>(t, bo);
77
+ read_pod<T>(t, bo);
80
78
  return t;
81
79
  }
82
80
  };
@@ -104,7 +102,7 @@ namespace Gosu
104
102
  return pos;
105
103
  }
106
104
 
107
- void setPosition(std::size_t value)
105
+ void set_position(std::size_t value)
108
106
  {
109
107
  // TODO: Check?
110
108
  pos = value;
@@ -116,21 +114,21 @@ namespace Gosu
116
114
  pos += offset;
117
115
  }
118
116
 
119
- void write(const void* sourceBuffer, std::size_t length);
117
+ void write(const void* source_buffer, std::size_t length);
120
118
 
121
119
  //! Convenience function; equivalent to write(&t, sizeof t).
122
120
  template<typename T>
123
- void writePod(const T& t, ByteOrder bo = boDontCare)
121
+ void write_pod(const T& t, ByteOrder bo = BO_DONT_CARE)
124
122
  {
125
- if (bo == otherByteOrder)
126
- {
123
+ if (bo == BO_OTHER) {
127
124
  char buf[sizeof t];
128
125
  const char* begin = reinterpret_cast<const char*>(&t);
129
126
  std::reverse_copy(begin, begin + sizeof t, buf);
130
127
  write(buf, sizeof buf);
131
128
  }
132
- else
129
+ else {
133
130
  write(&t, sizeof t);
131
+ }
134
132
  }
135
133
  };
136
134
 
@@ -141,17 +139,11 @@ namespace Gosu
141
139
  //! truncating its content or allocating room for more data.
142
140
  class Resource
143
141
  {
144
- // Non-copyable
145
- #if defined(GOSU_CPP11_ENABLED)
142
+ // Non-copyable and non-movable to avoid slicing.
146
143
  Resource(const Resource&) = delete;
147
144
  Resource& operator=(const Resource&) = delete;
148
- // and non-movable
149
145
  Resource(Resource&&) = delete;
150
146
  Resource& operator=(Resource&&) = delete;
151
- #else
152
- Resource(const Resource&);
153
- Resource& operator=(const Resource&);
154
- #endif
155
147
 
156
148
  public:
157
149
  Resource()
@@ -164,27 +156,25 @@ namespace Gosu
164
156
 
165
157
  //! Convenience: Creates a new Reader that reads from the start of
166
158
  //! the resource.
167
- Reader frontReader() const
159
+ Reader front_reader() const
168
160
  {
169
161
  return Reader(*this, 0);
170
162
  }
171
163
 
172
164
  //! Convenience: Creates a new Writer that appends data at the
173
165
  //! end of the resource.
174
- Writer backWriter()
166
+ Writer back_writer()
175
167
  {
176
168
  return Writer(*this, size());
177
169
  }
178
170
 
179
171
  virtual std::size_t size() const = 0;
180
172
 
181
- virtual void resize(std::size_t newSize) = 0;
173
+ virtual void resize(std::size_t new_size) = 0;
182
174
 
183
- virtual void read(std::size_t offset, std::size_t length,
184
- void* destBuffer) const = 0;
175
+ virtual void read(std::size_t offset, std::size_t length, void* dest_buffer) const = 0;
185
176
 
186
- virtual void write(std::size_t offset, std::size_t length,
187
- const void* sourceBuffer) = 0;
177
+ virtual void write(std::size_t offset, std::size_t length, const void* source_buffer) = 0;
188
178
  };
189
179
 
190
180
  //! Piece of memory with the Resource interface.
@@ -209,14 +199,13 @@ namespace Gosu
209
199
  return *this;
210
200
  }
211
201
 
212
- std::size_t size() const;
213
- void resize(std::size_t newSize);
202
+ std::size_t size() const override;
214
203
 
215
- void read(std::size_t offset, std::size_t length,
216
- void* destBuffer) const;
204
+ void resize(std::size_t new_size) override;
217
205
 
218
- void write(std::size_t offset, std::size_t length,
219
- const void* sourceBuffer);
206
+ void read(std::size_t offset, std::size_t length, void* dest_buffer) const override;
207
+
208
+ void write(std::size_t offset, std::size_t length, const void* source_buffer) override;
220
209
 
221
210
  const void* data() const
222
211
  {
@@ -233,37 +222,36 @@ namespace Gosu
233
222
  {
234
223
  //! Opens an existing file for reading; throws an exception if the file
235
224
  //! cannot be found.
236
- fmRead,
225
+ FM_READ,
237
226
  //! Writes data to a file. If the file already exists, is emptied on
238
227
  //! opening. If the file does not exist, it is created.
239
- fmReplace,
228
+ FM_REPLACE,
240
229
  //! Opens or creates a file with writing access, but does not clear
241
230
  //! existing contents.
242
- fmAlter
231
+ FM_ALTER
243
232
  };
244
233
 
245
234
  //! File with the Resource interface.
246
235
  class File : public Resource
247
236
  {
248
237
  struct Impl;
249
- const GOSU_UNIQUE_PTR<Impl> pimpl;
238
+ const std::unique_ptr<Impl> pimpl;
250
239
 
251
240
  public:
252
- explicit File(const std::wstring& filename, FileMode mode = fmRead);
241
+ explicit File(const std::string& filename, FileMode mode = FM_READ);
253
242
  ~File();
254
243
 
255
- std::size_t size() const;
256
- void resize(std::size_t newSize);
257
- void read(std::size_t offset, std::size_t length,
258
- void* destBuffer) const;
259
- void write(std::size_t offset, std::size_t length,
260
- const void* sourceBuffer);
244
+ std::size_t size() const override;
245
+
246
+ void resize(std::size_t new_size) override;
247
+
248
+ void read(std::size_t offset, std::size_t length, void* dest_buffer) const override;
249
+
250
+ void write(std::size_t offset, std::size_t length, const void* source_buffer) override;
261
251
  };
262
252
 
263
253
  //! Loads a whole file into a buffer.
264
- void loadFile(Buffer& buffer, const std::wstring& filename);
254
+ void load_file(Buffer& buffer, const std::string& filename);
265
255
  //! Creates or overwrites a file with the contents of a buffer.
266
- void saveFile(const Buffer& buffer, const std::wstring& filename);
256
+ void save_file(const Buffer& buffer, const std::string& filename);
267
257
  }
268
-
269
- #endif