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,39 +1,41 @@
1
- #include <Gosu/Utility.hpp>
1
+ #include <Gosu/Platform.hpp>
2
+ #if defined(GOSU_IS_WIN)
3
+
2
4
  #include "WinUtility.hpp"
5
+ #include <Gosu/Utility.hpp>
3
6
  #include <stdexcept>
4
7
  #include <windows.h>
5
8
 
6
- void Gosu::Win::throwLastError(const std::string& action)
9
+ void Gosu::throw_last_winapi_error(const std::string& action)
7
10
  {
8
11
  // Obtain error message from Windows.
9
- char* buffer;
10
- if (!::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
11
- FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0,
12
- ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
13
- reinterpret_cast<LPSTR>(&buffer), 0, 0) || buffer == 0)
14
- {
15
- // IMPR: Can we do better than this?
12
+ wchar_t* buffer;
13
+
14
+ if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
15
+ FORMAT_MESSAGE_FROM_SYSTEM |
16
+ FORMAT_MESSAGE_IGNORE_INSERTS, 0, GetLastError(),
17
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR) &buffer, 0, 0)
18
+ || buffer == nullptr) {
16
19
  throw std::runtime_error("Unknown error");
17
20
  }
18
21
 
19
- // Move the message out of the ugly char* buffer.
22
+ // Safely move the message into a std::string.
20
23
  std::string message;
21
- try
22
- {
23
- message = buffer;
24
+ try {
25
+ message = wstring_to_utf8(buffer);
24
26
  }
25
- catch (...)
26
- {
27
- ::LocalFree(buffer);
27
+ catch (...) {
28
+ LocalFree(buffer);
28
29
  throw;
29
30
  }
30
- ::LocalFree(buffer);
31
+ LocalFree(buffer);
31
32
 
32
33
  // Optionally prepend the action.
33
- if (!action.empty())
34
- message = "While " + action + ", the following error occured: " +
35
- message;
34
+ if (!action.empty()) {
35
+ message = "While " + action + ", the following error occured: " + message;
36
+ }
36
37
 
37
- // Now throw it.
38
38
  throw std::runtime_error(message);
39
- }
39
+ }
40
+
41
+ #endif
@@ -1,30 +1,21 @@
1
- #ifndef GOSU_WINUTILITY_HPP
2
- #define GOSU_WINUTILITY_HPP
1
+ #pragma once
3
2
 
4
3
  #include <Gosu/Platform.hpp>
5
4
  #include <string>
6
5
 
7
6
  namespace Gosu
8
7
  {
9
- //! Implementation helpers for the Windows platform.
10
- namespace Win
11
- {
12
- //! Throws an exception according to the error which GetLastError()
13
- //! returns, optionally prefixed with "While (action), the following
14
- //! error occured: ".
15
- GOSU_NORETURN void throwLastError(const std::string& action = "");
8
+ //! Throws an exception according to the error returned by GetLastError(), optionally prefixed
9
+ //! with "While (action), the following error occured: ".
10
+ GOSU_NORETURN void throw_last_winapi_error(const std::string& action = "");
16
11
 
17
- //! Small helper function that throws an exception whenever the value
18
- //! passed through is false. Note that this doesn't make sense for all
19
- //! Windows API functions, but for most of them.
20
- template<typename T>
21
- inline T check(T valToCheck, const std::string& action = "")
22
- {
23
- if (!valToCheck)
24
- throwLastError(action);
25
- return valToCheck;
12
+ //! Small helper function that throws the last Windows error when val_to_check is false.
13
+ template<typename T>
14
+ inline T winapi_check(T val_to_check, const std::string& action = "")
15
+ {
16
+ if (!val_to_check) {
17
+ throw_last_winapi_error(action);
26
18
  }
19
+ return val_to_check;
27
20
  }
28
21
  }
29
-
30
- #endif
@@ -1,204 +1,247 @@
1
+ #include <Gosu/Platform.hpp>
2
+ #if !defined(GOSU_IS_IPHONE)
3
+
1
4
  #include <Gosu/Gosu.hpp>
2
- #include "Graphics/Common.hpp"
3
5
  #include <SDL.h>
4
6
  #include <cstdlib>
5
7
  #include <memory>
6
8
  #include <stdexcept>
7
9
 
8
- using namespace std::tr1::placeholders;
9
-
10
10
  namespace Gosu
11
11
  {
12
12
  namespace FPS
13
13
  {
14
- void registerFrame();
14
+ void register_frame();
15
15
  }
16
16
 
17
- void throwSDLError(const std::string& operation)
17
+ void throw_sdl_error(const std::string& operation)
18
18
  {
19
- const char *error = SDL_GetError();
19
+ const char* error = SDL_GetError();
20
20
  throw std::runtime_error(operation + ": " + (error ? error : "(unknown error)"));
21
21
  }
22
22
 
23
23
  void cleanup();
24
24
 
25
- SDL_Window* sharedWindow()
25
+ SDL_Window* shared_window()
26
26
  {
27
- static SDL_Window *window = 0;
28
- if (window == 0)
29
- {
30
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
31
- throwSDLError("Could not initialize SDL Video");
27
+ static SDL_Window* window = nullptr;
28
+ if (window == nullptr) {
29
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
30
+ throw_sdl_error("Could not initialize SDL Video");
31
+ }
32
32
 
33
33
  std::atexit(cleanup);
34
34
 
35
35
  Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN;
36
36
 
37
- #if SDL_VERSION_ATLEAST(2, 0, 1)
37
+ #if SDL_VERSION_ATLEAST(2, 0, 1)
38
38
  flags |= SDL_WINDOW_ALLOW_HIGHDPI;
39
- #endif
39
+ #endif
40
40
 
41
- window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 64, 64, flags);
42
- if (window == 0)
43
- throwSDLError("Could not create window");
41
+ window =
42
+ SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 64, 64, flags);
43
+ if (window == nullptr) {
44
+ throw_sdl_error("Could not create window");
45
+ }
44
46
  }
45
47
  return window;
46
48
  }
47
49
 
48
- SDL_GLContext sharedGLContext()
50
+ SDL_GLContext shared_gl_context()
49
51
  {
50
- static SDL_GLContext context = 0;
51
- if (context == 0)
52
- {
53
- #ifdef GOSU_IS_OPENGLES
52
+ static SDL_GLContext context = nullptr;
53
+ if (context == nullptr) {
54
+ #ifdef GOSU_IS_OPENGLES
54
55
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
55
56
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
56
- #endif
57
+ #endif
57
58
 
58
- context = SDL_GL_CreateContext(sharedWindow());
59
+ context = SDL_GL_CreateContext(shared_window());
59
60
 
60
- if (context == 0)
61
- throwSDLError("Could not create OpenGL context");
61
+ if (context == nullptr) {
62
+ throw_sdl_error("Could not create OpenGL context");
63
+ }
62
64
  }
63
65
  return context;
64
66
  }
65
67
 
66
- void ensureCurrentContext()
68
+ void ensure_current_context()
67
69
  {
68
- SDL_GL_MakeCurrent(sharedWindow(), sharedGLContext());
70
+ SDL_GL_MakeCurrent(shared_window(), shared_gl_context());
69
71
  }
70
72
 
71
73
  void cleanup()
72
74
  {
73
- SDL_GL_DeleteContext(sharedGLContext());
74
- SDL_DestroyWindow(sharedWindow());
75
+ SDL_GL_DeleteContext(shared_gl_context());
76
+ SDL_DestroyWindow(shared_window());
75
77
  SDL_QuitSubSystem(SDL_INIT_VIDEO);
76
78
  }
77
79
  }
78
80
 
79
81
  struct Gosu::Window::Impl
80
82
  {
81
- double updateInterval;
83
+ bool fullscreen;
84
+ double update_interval;
82
85
 
83
- std::auto_ptr<Graphics> graphics;
84
- std::auto_ptr<Input> input;
86
+ std::unique_ptr<Graphics> graphics;
87
+ std::unique_ptr<Input> input;
85
88
  };
86
89
 
87
- Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double updateInterval)
90
+ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double update_interval)
88
91
  : pimpl(new Impl)
89
92
  {
90
- int actualWidth = width;
91
- int actualHeight = height;
92
- double scaleFactor = 1.0;
93
- double blackBarWidth = 0;
94
- double blackBarHeight = 0;
93
+ // This will implicitly create graphics() and input(), and make the OpenGL context current.
94
+ resize(width, height, fullscreen);
95
+
96
+ SDL_GL_SetSwapInterval(1);
97
+
98
+ pimpl->update_interval = update_interval;
99
+
100
+ if (!fullscreen) {
101
+ SDL_SetWindowPosition(shared_window(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
102
+ }
103
+
104
+ input().on_button_down = [this](Gosu::Button button) { button_down(button); };
105
+ input().on_button_up = [this](Gosu::Button button) { button_up(button); };
106
+ }
107
+
108
+ Gosu::Window::~Window()
109
+ {
110
+ SDL_HideWindow(shared_window());
111
+ }
112
+
113
+ unsigned Gosu::Window::width() const
114
+ {
115
+ return graphics().width();
116
+ }
117
+
118
+ unsigned Gosu::Window::height() const
119
+ {
120
+ return graphics().height();
121
+ }
122
+
123
+ bool Gosu::Window::fullscreen() const
124
+ {
125
+ return pimpl->fullscreen;
126
+ }
127
+
128
+ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
129
+ {
130
+ pimpl->fullscreen = fullscreen;
131
+
132
+ int actual_width = width;
133
+ int actual_height = height;
134
+ double scale_factor = 1.0;
135
+ double black_bar_width = 0;
136
+ double black_bar_height = 0;
95
137
 
96
138
  if (fullscreen) {
97
- actualWidth = Gosu::screenWidth();
98
- actualHeight = Gosu::screenHeight();
139
+ actual_width = Gosu::screen_width();
140
+ actual_height = Gosu::screen_height();
99
141
 
100
- double scaleX = 1.0 * actualWidth / width;
101
- double scaleY = 1.0 * actualHeight / height;
102
- scaleFactor = std::min(scaleX, scaleY);
142
+ double scale_x = 1.0 * actual_width / width;
143
+ double scale_y = 1.0 * actual_height / height;
144
+ scale_factor = std::min(scale_x, scale_y);
103
145
 
104
- if (scaleX < scaleY) {
105
- blackBarHeight = (actualHeight / scaleX - height) / 2;
146
+ if (scale_x < scale_y) {
147
+ black_bar_height = (actual_height / scale_x - height) / 2;
106
148
  }
107
- else if (scaleY < scaleX) {
108
- blackBarWidth = (actualWidth / scaleY - width) / 2;
149
+ else if (scale_y < scale_x) {
150
+ black_bar_width = (actual_width / scale_y - width) / 2;
109
151
  }
110
152
  }
111
153
  else {
112
- double maxWidth = Gosu::availableWidth();
113
- double maxHeight = Gosu::availableHeight();
154
+ double max_width = Gosu::available_width();
155
+ double max_height = Gosu::available_height();
114
156
 
115
- if (width > maxWidth || height > maxHeight) {
116
- scaleFactor = std::min(maxWidth / width, maxHeight / height);
117
- actualWidth = width * scaleFactor;
118
- actualHeight = height * scaleFactor;
157
+ if (width > max_width || height > max_height) {
158
+ scale_factor = std::min(max_width / width, max_height / height);
159
+ actual_width = width * scale_factor;
160
+ actual_height = height * scale_factor;
119
161
  }
120
162
  }
121
163
 
122
- SDL_SetWindowTitle(sharedWindow(), "");
123
- SDL_SetWindowSize(sharedWindow(), actualWidth, actualHeight);
124
- SDL_SetWindowPosition(sharedWindow(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
125
- if (fullscreen)
126
- {
127
- SDL_SetWindowFullscreen(sharedWindow(), fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
128
- }
164
+ SDL_SetWindowFullscreen(shared_window(), fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
165
+ SDL_SetWindowSize(shared_window(), actual_width, actual_height);
129
166
 
130
- #if SDL_VERSION_ATLEAST(2, 0, 1)
131
- SDL_GL_GetDrawableSize(sharedWindow(), &actualWidth, &actualHeight);
132
- #endif
167
+ #if SDL_VERSION_ATLEAST(2, 0, 1)
168
+ SDL_GL_GetDrawableSize(shared_window(), &actual_width, &actual_height);
169
+ #endif
133
170
 
134
- ensureCurrentContext();
135
- SDL_GL_SetSwapInterval(1);
171
+ ensure_current_context();
172
+
173
+ if (pimpl->graphics.get() == nullptr) {
174
+ pimpl->graphics.reset(new Graphics(actual_width, actual_height));
175
+ }
176
+ else {
177
+ pimpl->graphics->set_physical_resolution(actual_width, actual_height);
178
+ }
179
+ pimpl->graphics->set_resolution(width, height, black_bar_width, black_bar_height);
136
180
 
137
- pimpl->graphics.reset(new Graphics(actualWidth, actualHeight, fullscreen));
138
- pimpl->graphics->setResolution(width, height, blackBarWidth, blackBarHeight);
139
- pimpl->input.reset(new Input(sharedWindow()));
140
- pimpl->input->setMouseFactors(1 / scaleFactor, 1 / scaleFactor, blackBarWidth, blackBarHeight);
141
- input().onButtonDown = std::tr1::bind(&Window::buttonDown, this, _1);
142
- input().onButtonUp = std::tr1::bind(&Window::buttonUp, this, _1);
143
- pimpl->updateInterval = updateInterval;
181
+ if (pimpl->input.get() == nullptr) {
182
+ pimpl->input.reset(new Input(shared_window()));
183
+ }
184
+ pimpl->input->set_mouse_factors(1 / scale_factor, 1 / scale_factor,
185
+ black_bar_width, black_bar_height);
144
186
  }
145
187
 
146
- Gosu::Window::~Window()
188
+ double Gosu::Window::update_interval() const
147
189
  {
148
- SDL_HideWindow(sharedWindow());
190
+ return pimpl->update_interval;
149
191
  }
150
192
 
151
- std::wstring Gosu::Window::caption() const
193
+ void Gosu::Window::set_update_interval(double update_interval)
152
194
  {
153
- return utf8ToWstring(SDL_GetWindowTitle(sharedWindow()));
195
+ pimpl->update_interval = update_interval;
154
196
  }
155
197
 
156
- void Gosu::Window::setCaption(const std::wstring& caption)
198
+ std::string Gosu::Window::caption() const
157
199
  {
158
- std::string utf8 = wstringToUTF8(caption);
159
- SDL_SetWindowTitle(sharedWindow(), utf8.c_str());
200
+ const char* title = SDL_GetWindowTitle(shared_window());
201
+ return title ? title : "";
160
202
  }
161
203
 
162
- double Gosu::Window::updateInterval() const
204
+ void Gosu::Window::set_caption(const std::string& caption)
163
205
  {
164
- return pimpl->updateInterval;
206
+ SDL_SetWindowTitle(shared_window(), caption.c_str());
165
207
  }
166
208
 
167
209
  void Gosu::Window::show()
168
210
  {
169
- unsigned long timeBeforeTick = milliseconds();
211
+ unsigned long time_before_tick = milliseconds();
170
212
 
171
213
  while (tick()) {
172
214
  // Sleep to keep this loop from eating 100% CPU.
173
- unsigned long tickTime = milliseconds() - timeBeforeTick;
174
- if (tickTime < updateInterval())
175
- sleep(updateInterval() - tickTime);
215
+ unsigned long tick_time = milliseconds() - time_before_tick;
216
+ if (tick_time < update_interval()) {
217
+ sleep(update_interval() - tick_time);
218
+ }
176
219
 
177
- timeBeforeTick = milliseconds();
220
+ time_before_tick = milliseconds();
178
221
  }
179
222
  }
180
223
 
181
224
  bool Gosu::Window::tick()
182
225
  {
183
- if (SDL_GetWindowFlags(sharedWindow()) & SDL_WINDOW_HIDDEN) {
184
- SDL_ShowWindow(sharedWindow());
226
+ if (SDL_GetWindowFlags(shared_window()) & SDL_WINDOW_HIDDEN) {
227
+ SDL_ShowWindow(shared_window());
185
228
 
186
229
  // SDL_GL_GetDrawableSize returns different values before and after showing the window.
187
230
  // -> When first showing the window, update the physical size of Graphics (=glViewport).
188
231
  // Fixes https://github.com/gosu/gosu/issues/318
189
232
  int width, height;
190
- SDL_GL_GetDrawableSize(sharedWindow(), &width, &height);
191
- graphics().setPhysicalResolution(width, height);
233
+ SDL_GL_GetDrawableSize(shared_window(), &width, &height);
234
+ graphics().set_physical_resolution(width, height);
192
235
  }
193
236
 
194
237
  SDL_Event e;
195
238
  while (SDL_PollEvent(&e)) {
196
239
  if (e.type == SDL_QUIT) {
197
- SDL_HideWindow(sharedWindow());
240
+ SDL_HideWindow(shared_window());
198
241
  return false;
199
242
  }
200
243
  else {
201
- input().feedSDLEvent(&e);
244
+ input().feed_sdl_event(&e);
202
245
  }
203
246
  }
204
247
 
@@ -208,17 +251,17 @@ bool Gosu::Window::tick()
208
251
 
209
252
  update();
210
253
 
211
- SDL_ShowCursor(needsCursor());
254
+ SDL_ShowCursor(needs_cursor());
212
255
 
213
- if (needsRedraw()) {
214
- ensureCurrentContext();
256
+ if (needs_redraw()) {
257
+ ensure_current_context();
215
258
  if (graphics().begin()) {
216
259
  draw();
217
260
  graphics().end();
218
- FPS::registerFrame();
261
+ FPS::register_frame();
219
262
  }
220
263
 
221
- SDL_GL_SwapWindow(sharedWindow());
264
+ SDL_GL_SwapWindow(shared_window());
222
265
  }
223
266
 
224
267
  return true;
@@ -251,17 +294,4 @@ Gosu::Input& Gosu::Window::input()
251
294
  return *pimpl->input;
252
295
  }
253
296
 
254
- // Deprecated.
255
-
256
- class Gosu::Audio {};
257
- namespace { Gosu::Audio dummyAudio; }
258
-
259
- const Gosu::Audio& Gosu::Window::audio() const
260
- {
261
- return dummyAudio;
262
- }
263
-
264
- Gosu::Audio& Gosu::Window::audio()
265
- {
266
- return dummyAudio;
267
- }
297
+ #endif