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
@@ -0,0 +1,133 @@
1
+ #include "BlockAllocator.hpp"
2
+ #include <stdexcept>
3
+ #include <vector>
4
+
5
+ struct Gosu::BlockAllocator::Impl
6
+ {
7
+ unsigned width, height;
8
+
9
+ std::vector<Block> blocks;
10
+ unsigned first_x, first_y;
11
+ unsigned max_w, max_h;
12
+
13
+ void mark_block_used(const Block& block, unsigned a_width, unsigned a_height)
14
+ {
15
+ first_x += a_width;
16
+ if (first_x + a_width >= width) {
17
+ first_x = 0;
18
+ first_y += a_height;
19
+ }
20
+ blocks.push_back(block);
21
+ }
22
+
23
+ bool is_block_free(const Block& block) const
24
+ {
25
+ // right and bottom are exclusive (not part of the block).
26
+ unsigned right = block.left + block.width;
27
+ unsigned bottom = block.top + block.height;
28
+
29
+ // Block isn't valid.
30
+ if (right > width || bottom > height) return false;
31
+
32
+ // Test if the block collides with any existing rects.
33
+ for (auto b : blocks) {
34
+ if (b.left < right && block.left < b.left + b.width && b.top < bottom
35
+ && block.top < b.top + b.height) {
36
+ return false;
37
+ }
38
+ }
39
+
40
+ return true;
41
+ }
42
+ };
43
+
44
+ Gosu::BlockAllocator::BlockAllocator(unsigned width, unsigned height)
45
+ : pimpl(new Impl)
46
+ {
47
+ pimpl->width = width;
48
+ pimpl->height = height;
49
+
50
+ pimpl->first_x = 0;
51
+ pimpl->first_y = 0;
52
+
53
+ pimpl->max_w = width;
54
+ pimpl->max_h = height;
55
+ }
56
+
57
+ Gosu::BlockAllocator::~BlockAllocator()
58
+ {
59
+ }
60
+
61
+ unsigned Gosu::BlockAllocator::width() const
62
+ {
63
+ return pimpl->width;
64
+ }
65
+
66
+ unsigned Gosu::BlockAllocator::height() const
67
+ {
68
+ return pimpl->height;
69
+ }
70
+
71
+ bool Gosu::BlockAllocator::alloc(unsigned a_width, unsigned a_height, Block& b)
72
+ {
73
+ // The rect wouldn't even fit onto the texture!
74
+ if (a_width > width() || a_height > height()) {
75
+ return false;
76
+ }
77
+
78
+ // We know there's no space left.
79
+ if (a_width > pimpl->max_w && a_height > pimpl->max_h) {
80
+ return false;
81
+ }
82
+
83
+ // Start to look for a place next to the last returned rect. Chances are
84
+ // good we'll find a place there.
85
+ b = Block(pimpl->first_x, pimpl->first_y, a_width, a_height);
86
+ if (pimpl->is_block_free(b)) {
87
+ pimpl->mark_block_used(b, a_width, a_height);
88
+ return true;
89
+ }
90
+
91
+ // Brute force: Look for a free place on this texture.
92
+ unsigned& x = b.left;
93
+ unsigned& y = b.top;
94
+ for (y = 0; y <= height() - a_height; y += 16) {
95
+ for (x = 0; x <= width() - a_width; x += 8) {
96
+ if (!pimpl->is_block_free(b)) continue;
97
+
98
+ // Found a nice place!
99
+
100
+ // Try to make up for the large for ()-stepping.
101
+ while (y > 0 && pimpl->is_block_free(Block(x, y - 1, a_width, a_height))) --y;
102
+ while (x > 0 && pimpl->is_block_free(Block(x - 1, y, a_width, a_height))) --x;
103
+
104
+ pimpl->mark_block_used(b, a_width, a_height);
105
+ return true;
106
+ }
107
+ }
108
+
109
+ // So there was no space for the bitmap. Remember this for later.
110
+ pimpl->max_w = a_width - 1;
111
+ pimpl->max_h = a_height - 1;
112
+ return false;
113
+ }
114
+
115
+ void Gosu::BlockAllocator::block(unsigned left, unsigned top, unsigned width, unsigned height)
116
+ {
117
+ pimpl->blocks.push_back(Block(left, top, width, height));
118
+ }
119
+
120
+ void Gosu::BlockAllocator::free(unsigned left, unsigned top, unsigned width, unsigned height)
121
+ {
122
+ for (auto it = pimpl->blocks.begin(), end = pimpl->blocks.end(); it != end; ++it) {
123
+ if (it->left == left && it->top == top && it->width == width && it->height == height) {
124
+ pimpl->blocks.erase(it);
125
+ // Be optimistic again, since we might have deleted the largest/only block.
126
+ pimpl->max_w = pimpl->width - 1;
127
+ pimpl->max_h = pimpl->height - 1;
128
+ return;
129
+ }
130
+ }
131
+
132
+ throw std::logic_error("Tried to free an invalid block");
133
+ }
@@ -1,35 +1,34 @@
1
- #ifndef GOSU_SRC_BLOCKALLOCATOR_HPP
2
- #define GOSU_SRC_BLOCKALLOCATOR_HPP
3
-
4
- #include <memory>
5
- #include <Gosu/Platform.hpp>
6
-
7
- namespace Gosu
8
- {
9
- class BlockAllocator
10
- {
11
- struct Impl;
12
- const GOSU_UNIQUE_PTR<Impl> pimpl;
13
-
14
- public:
15
- struct Block
16
- {
17
- unsigned left, top, width, height;
18
- Block() {}
19
- Block(unsigned aLeft, unsigned aTop, unsigned aWidth, unsigned aHeight)
20
- : left(aLeft), top(aTop), width(aWidth), height(aHeight) {}
21
- };
22
-
23
- BlockAllocator(unsigned width, unsigned height);
24
- ~BlockAllocator();
25
-
26
- unsigned width() const;
27
- unsigned height() const;
28
-
29
- bool alloc(unsigned width, unsigned height, Block& block);
30
- void block(unsigned left, unsigned top, unsigned width, unsigned height);
31
- void free(unsigned left, unsigned top, unsigned width, unsigned height);
32
- };
33
- }
34
-
35
- #endif
1
+ #pragma once
2
+
3
+ #include <Gosu/Platform.hpp>
4
+ #include <memory>
5
+
6
+ namespace Gosu
7
+ {
8
+ class BlockAllocator
9
+ {
10
+ struct Impl;
11
+ const std::unique_ptr<Impl> pimpl;
12
+
13
+ public:
14
+ struct Block
15
+ {
16
+ unsigned left, top, width, height;
17
+ Block() {}
18
+ Block(unsigned a_left, unsigned a_top, unsigned a_width, unsigned a_height)
19
+ : left(a_left), top(a_top), width(a_width), height(a_height)
20
+ {
21
+ }
22
+ };
23
+
24
+ BlockAllocator(unsigned width, unsigned height);
25
+ ~BlockAllocator();
26
+
27
+ unsigned width() const;
28
+ unsigned height() const;
29
+
30
+ bool alloc(unsigned width, unsigned height, Block& block);
31
+ void block(unsigned left, unsigned top, unsigned width, unsigned height);
32
+ void free(unsigned left, unsigned top, unsigned width, unsigned height);
33
+ };
34
+ }
@@ -0,0 +1,87 @@
1
+ #pragma once
2
+
3
+ #include "GraphicsImpl.hpp"
4
+ #include <cassert>
5
+ #include <vector>
6
+
7
+ class Gosu::ClipRectStack
8
+ {
9
+ std::vector<ClipRect> stack;
10
+ bool has_effective_rect; // is effective_rect valid?
11
+ ClipRect effective_rect;
12
+
13
+ void update_effective_rect()
14
+ {
15
+ // Nothing to do, no clipping in place.
16
+ if (stack.empty()) {
17
+ has_effective_rect = false;
18
+ return;
19
+ }
20
+
21
+ ClipRect result = { 0.0, 0.0, 1e10, 1e10 };
22
+ for (std::size_t i = 0, end = stack.size(); i < end; ++i) {
23
+ const ClipRect& rect = stack[i];
24
+ int result_right = std::min(result.x + result.width, rect.x + rect.width);
25
+ int result_bottom = std::min(result.y + result.height, rect.y + rect.height);
26
+ result.x = std::max(result.x, rect.x);
27
+ result.y = std::max(result.y, rect.y);
28
+
29
+ if (result.x >= result_right || result.y >= result_bottom) {
30
+ // We have clipped the world away!
31
+ has_effective_rect = false;
32
+ return;
33
+ }
34
+
35
+ result.width = result_right - result.x;
36
+ result.height = result_bottom - result.y;
37
+ }
38
+
39
+ // On the iPhone, we may have to multiply everything by 2 for Retina displays.
40
+ // TODO: Doesn't this affect Retina Macs as well?
41
+ // TODO: This should be handled by a global transform.
42
+ int fac = clip_rect_base_factor();
43
+ result.x *= fac, result.y *= fac, result.width *= fac, result.height *= fac;
44
+
45
+ // Normal clipping.
46
+ effective_rect = result;
47
+ has_effective_rect = true;
48
+ }
49
+
50
+ public:
51
+ ClipRectStack()
52
+ : has_effective_rect(false)
53
+ {
54
+ }
55
+
56
+ void clear()
57
+ {
58
+ stack.clear();
59
+ has_effective_rect = false;
60
+ }
61
+
62
+ void begin_clipping(double x, double y, double width, double height)
63
+ {
64
+ ClipRect rect = { x, y, width, height };
65
+ stack.push_back(rect);
66
+ update_effective_rect();
67
+ }
68
+
69
+ void end_clipping()
70
+ {
71
+ assert (!stack.empty());
72
+ stack.pop_back();
73
+ update_effective_rect();
74
+ }
75
+
76
+ const ClipRect* maybe_effective_rect() const
77
+ {
78
+ return has_effective_rect ? &effective_rect : 0;
79
+ }
80
+
81
+ bool clipped_world_away() const
82
+ {
83
+ // When we have no effective rect but the stack is not empty, we have clipped
84
+ // the whole world away and don't need to render things.
85
+ return !has_effective_rect && !stack.empty();
86
+ }
87
+ };
@@ -6,7 +6,7 @@ namespace
6
6
  {
7
7
  struct HSV { double h, s, v; };
8
8
 
9
- HSV colorToHSV(const Gosu::Color& c)
9
+ HSV color_to_hsv(const Gosu::Color& c)
10
10
  {
11
11
  double r = c.red() / 255.0;
12
12
  double g = c.green() / 255.0;
@@ -15,8 +15,7 @@ namespace
15
15
  double min = std::min(std::min(r, g), b);
16
16
  double max = std::max(std::max(r, g), b);
17
17
 
18
- if (max == 0)
19
- {
18
+ if (max == 0) {
20
19
  HSV hsv = { 0, 0, 0 };
21
20
  return hsv;
22
21
  }
@@ -29,41 +28,44 @@ namespace
29
28
  hsv.s = delta / max;
30
29
 
31
30
  // Hue.
32
- if (r == max)
31
+ if (r == max) {
33
32
  hsv.h = (g - b) / delta + (g < b ? 6 : 0);
34
- else if (g == max)
33
+ }
34
+ else if (g == max) {
35
35
  hsv.h = (b - r) / delta + 2;
36
- else
36
+ }
37
+ else {
37
38
  hsv.h = (r - g) / delta + 4;
39
+ }
38
40
  hsv.h *= 60;
39
41
 
40
42
  return hsv;
41
43
  }
42
44
  }
43
45
 
44
- Gosu::Color Gosu::Color::fromHSV(double h, double s, double v)
46
+ Gosu::Color Gosu::Color::from_hsv(double h, double s, double v)
45
47
  {
46
- return fromAHSV(255, h, s, v);
48
+ return from_ahsv(255, h, s, v);
47
49
  }
48
50
 
49
- Gosu::Color Gosu::Color::fromAHSV(Channel alpha, double h, double s, double v)
51
+ Gosu::Color Gosu::Color::from_ahsv(Channel alpha, double h, double s, double v)
50
52
  {
51
- if (s == 0)
52
- // Grey.
53
+ if (s == 0) {
54
+ // Grey.
53
55
  return Color(alpha, v * 255, v * 255, v * 255);
56
+ }
54
57
 
55
58
  // Normalize hue
56
- h = normalizeAngle(h);
59
+ h = normalize_angle(h);
57
60
 
58
- int sector = h / 60;
61
+ int sector = h / 60;
59
62
  double factorial = h / 60 - sector;
60
63
 
61
- double p = v * (1 - s);
62
- double q = v * (1 - s * factorial);
63
- double t = v * (1 - s * (1 - factorial));
64
-
65
- switch (sector)
66
- {
64
+ double p = v * (1 - s);
65
+ double q = v * (1 - s * factorial);
66
+ double t = v * (1 - s * (1 - factorial));
67
+
68
+ switch (sector) {
67
69
  case 0:
68
70
  return Color(alpha, v * 255, t * 255, p * 255);
69
71
  case 1:
@@ -81,32 +83,32 @@ Gosu::Color Gosu::Color::fromAHSV(Channel alpha, double h, double s, double v)
81
83
 
82
84
  double Gosu::Color::hue() const
83
85
  {
84
- return colorToHSV(*this).h;
86
+ return color_to_hsv(*this).h;
85
87
  }
86
88
 
87
- void Gosu::Color::setHue(double h)
89
+ void Gosu::Color::set_hue(double h)
88
90
  {
89
- *this = fromAHSV(alpha(), h, saturation(), value());
91
+ *this = from_ahsv(alpha(), h, saturation(), value());
90
92
  }
91
93
 
92
94
  double Gosu::Color::saturation() const
93
95
  {
94
- return colorToHSV(*this).s;
96
+ return color_to_hsv(*this).s;
95
97
  }
96
98
 
97
- void Gosu::Color::setSaturation(double s)
99
+ void Gosu::Color::set_saturation(double s)
98
100
  {
99
- *this = fromAHSV(alpha(), hue(), s, value());
101
+ *this = from_ahsv(alpha(), hue(), s, value());
100
102
  }
101
103
 
102
104
  double Gosu::Color::value() const
103
105
  {
104
- return colorToHSV(*this).v;
106
+ return color_to_hsv(*this).v;
105
107
  }
106
108
 
107
- void Gosu::Color::setValue(double v)
109
+ void Gosu::Color::set_value(double v)
108
110
  {
109
- *this = fromAHSV(alpha(), hue(), saturation(), v);
111
+ *this = from_ahsv(alpha(), hue(), saturation(), v);
110
112
  }
111
113
 
112
114
  Gosu::Color Gosu::interpolate(Color a, Color b, double weight)
@@ -0,0 +1,68 @@
1
+ #include <Gosu/Platform.hpp>
2
+ #if defined(GOSU_IS_MAC)
3
+
4
+ #import <Gosu/Directories.hpp>
5
+ #import <Foundation/Foundation.h>
6
+ #import <unistd.h>
7
+
8
+
9
+ void Gosu::use_resource_directory()
10
+ {
11
+ chdir(resource_prefix().c_str());
12
+ }
13
+
14
+ std::string Gosu::user_settings_prefix()
15
+ {
16
+ static std::string result = [] {
17
+ @autoreleasepool {
18
+ NSString* library =
19
+ NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0];
20
+ NSString* preferences = [library stringByAppendingPathComponent:@"Preferences"];
21
+
22
+ return std::string(preferences.UTF8String ?: ".") + "/";
23
+ }
24
+ }();
25
+ return result;
26
+ }
27
+
28
+ std::string Gosu::user_documents_prefix()
29
+ {
30
+ static std::string result = [] {
31
+ @autoreleasepool {
32
+ NSString* documents =
33
+ NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
34
+
35
+ return std::string(documents.UTF8String ?: ".") + "/";
36
+ }
37
+ }();
38
+ return result;
39
+ }
40
+
41
+ std::string Gosu::resource_prefix()
42
+ {
43
+ static std::string result = [] {
44
+ @autoreleasepool {
45
+ NSString* resources = [NSBundle mainBundle].resourcePath;
46
+ return std::string(resources.UTF8String ?: ".") + "/";
47
+ }
48
+ }();
49
+ return result;
50
+ }
51
+
52
+ std::string Gosu::shared_resource_prefix()
53
+ {
54
+ #ifdef GOSU_IS_IPHONE
55
+ return resource_prefix();
56
+ #else
57
+ static std::string result = [] {
58
+ @autoreleasepool {
59
+ NSString* bundle_path = [NSBundle mainBundle].bundlePath;
60
+ NSString* containing_path = [bundle_path stringByDeletingLastPathComponent];
61
+ return std::string(containing_path.UTF8String ?: ".");
62
+ }
63
+ }();
64
+ return result;
65
+ #endif
66
+ }
67
+
68
+ #endif