gosu 1.0.0.pre1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gosu/extconf.rb +4 -24
  3. data/include/Gosu/Buttons.hpp +18 -17
  4. data/include/Gosu/Font.hpp +1 -1
  5. data/include/Gosu/Fwd.hpp +0 -5
  6. data/include/Gosu/Input.hpp +13 -40
  7. data/include/Gosu/Utility.hpp +14 -3
  8. data/include/Gosu/Version.hpp +3 -3
  9. data/include/Gosu/Window.hpp +25 -21
  10. data/lib/OpenAL32.dll +0 -0
  11. data/lib/gosu/patches.rb +0 -14
  12. data/lib/gosu/preview.rb +1 -3
  13. data/lib/gosu/swig_patches.rb +11 -10
  14. data/lib64/OpenAL32.dll +0 -0
  15. data/rdoc/gosu.rb +20 -6
  16. data/src/AudioFile.hpp +3 -0
  17. data/src/Input.cpp +28 -38
  18. data/src/Resolution.cpp +8 -8
  19. data/src/RubyGosu.cxx +646 -91
  20. data/src/RubyGosu.h +1 -1
  21. data/src/TrueTypeFontWin.cpp +3 -3
  22. data/src/Window.cpp +60 -31
  23. data/src/WindowUIKit.cpp +21 -9
  24. metadata +5 -31
  25. data/include/Gosu/AutoLink.hpp +0 -14
  26. data/include/Gosu/Channel.h +0 -25
  27. data/include/Gosu/Color.h +0 -38
  28. data/include/Gosu/Font.h +0 -36
  29. data/include/Gosu/Gosu.h +0 -82
  30. data/include/Gosu/Image.h +0 -54
  31. data/include/Gosu/Sample.h +0 -19
  32. data/include/Gosu/Song.h +0 -24
  33. data/include/Gosu/TextInput.h +0 -30
  34. data/include/Gosu/Window.h +0 -63
  35. data/lib/gosu/zen.rb +0 -89
  36. data/lib/libmpg123.dll +0 -0
  37. data/lib/libsndfile.dll +0 -0
  38. data/lib64/libmpg123.dll +0 -0
  39. data/lib64/libsndfile.dll +0 -0
  40. data/src/ChannelWrapper.cpp +0 -50
  41. data/src/ColorWrapper.cpp +0 -126
  42. data/src/Constants.cpp +0 -334
  43. data/src/FontWrapper.cpp +0 -74
  44. data/src/GosuWrapper.cpp +0 -251
  45. data/src/ImageWrapper.cpp +0 -168
  46. data/src/MPEGFile.hpp +0 -90
  47. data/src/SampleWrapper.cpp +0 -30
  48. data/src/SongWrapper.cpp +0 -52
  49. data/src/TextInputWrapper.cpp +0 -101
  50. data/src/WindowWrapper.cpp +0 -317
@@ -28,7 +28,7 @@ public:
28
28
  class SwigDirector_Window : public Gosu::Window, public Swig::Director {
29
29
 
30
30
  public:
31
- SwigDirector_Window(VALUE self,unsigned int width,unsigned int height,bool fullscreen=false,double update_interval=16.666666,bool resizable=false);
31
+ SwigDirector_Window(VALUE self,int width,int height,unsigned int window_flags=Gosu::WF_WINDOWED,double update_interval=16.666666);
32
32
  virtual ~SwigDirector_Window();
33
33
  virtual void show();
34
34
  virtual bool tick();
@@ -32,9 +32,9 @@ const unsigned char* Gosu::ttf_data_by_name(const string& font_name, unsigned fo
32
32
  LOGFONT logfont = {
33
33
  0, 0, 0, 0,
34
34
  (font_flags & Gosu::FF_BOLD) ? FW_BOLD : FW_NORMAL,
35
- (font_flags & Gosu::FF_ITALIC) ? TRUE : FALSE,
36
- (font_flags & Gosu::FF_UNDERLINE) ? TRUE : FALSE,
37
- FALSE /* no strikethrough */,
35
+ static_cast<BYTE>((font_flags & Gosu::FF_ITALIC) ? TRUE : FALSE),
36
+ static_cast<BYTE>((font_flags & Gosu::FF_UNDERLINE) ? TRUE : FALSE),
37
+ 0 /* no strikethrough */,
38
38
  ANSI_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
39
39
  DEFAULT_PITCH
40
40
  };
@@ -1,6 +1,10 @@
1
1
  #include <Gosu/Platform.hpp>
2
2
  #if !defined(GOSU_IS_IPHONE)
3
3
 
4
+ #if defined(GOSU_IS_WIN)
5
+ #include <windows.h>
6
+ #endif
7
+
4
8
  #include <Gosu/Gosu.hpp>
5
9
  #include "GraphicsImpl.hpp"
6
10
  #include <SDL.h>
@@ -30,11 +34,7 @@ namespace Gosu
30
34
  throw_sdl_error("Could not initialize SDL Video");
31
35
  }
32
36
 
33
- Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN;
34
-
35
- #if SDL_VERSION_ATLEAST(2, 0, 1)
36
- flags |= SDL_WINDOW_ALLOW_HIGHDPI;
37
- #endif
37
+ Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN | SDL_WINDOW_ALLOW_HIGHDPI;
38
38
 
39
39
  window =
40
40
  SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 64, 64, flags);
@@ -87,13 +87,11 @@ struct Gosu::Window::Impl
87
87
  unique_ptr<Input> input;
88
88
  };
89
89
 
90
- Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double update_interval,
91
- bool resizable)
90
+ Gosu::Window::Window(int width, int height, unsigned window_flags, double update_interval)
92
91
  : pimpl(new Impl)
93
92
  {
94
- #if SDL_VERSION_ATLEAST(2, 0, 5)
95
- SDL_SetWindowResizable(shared_window(), (SDL_bool)resizable);
96
- #endif
93
+ set_borderless(window_flags & WF_BORDERLESS);
94
+ set_resizable(window_flags & WF_RESIZABLE);
97
95
 
98
96
  // Even in fullscreen mode, temporarily show the window in windowed mode to centre it.
99
97
  // This ensures that the window will be centered correctly when exiting fullscreen mode.
@@ -103,12 +101,11 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double up
103
101
  SDL_SetWindowPosition(shared_window(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
104
102
 
105
103
  // Really enable fullscreen if desired.
106
- resize(width, height, fullscreen);
104
+ resize(width, height, (window_flags & WF_FULLSCREEN));
107
105
 
108
106
  SDL_GL_SetSwapInterval(1);
109
107
 
110
108
  pimpl->update_interval = update_interval;
111
- pimpl->resizable = resizable;
112
109
 
113
110
  input().on_button_down = [this](Button button) { button_down(button); };
114
111
  input().on_button_up = [this](Button button) { button_up(button); };
@@ -121,12 +118,12 @@ Gosu::Window::~Window()
121
118
  SDL_HideWindow(shared_window());
122
119
  }
123
120
 
124
- unsigned Gosu::Window::width() const
121
+ int Gosu::Window::width() const
125
122
  {
126
123
  return graphics().width();
127
124
  }
128
125
 
129
- unsigned Gosu::Window::height() const
126
+ int Gosu::Window::height() const
130
127
  {
131
128
  return graphics().height();
132
129
  }
@@ -136,12 +133,7 @@ bool Gosu::Window::fullscreen() const
136
133
  return pimpl->fullscreen;
137
134
  }
138
135
 
139
- bool Gosu::Window::resizable() const
140
- {
141
- return pimpl->resizable;
142
- }
143
-
144
- void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
136
+ void Gosu::Window::resize(int width, int height, bool fullscreen)
145
137
  {
146
138
  pimpl->fullscreen = fullscreen;
147
139
 
@@ -175,8 +167,8 @@ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
175
167
  }
176
168
  }
177
169
  else {
178
- unsigned max_width = Gosu::available_width(this);
179
- unsigned max_height = Gosu::available_height(this);
170
+ int max_width = Gosu::available_width(this);
171
+ int max_height = Gosu::available_height(this);
180
172
 
181
173
  if (resizable()) {
182
174
  // If the window is resizable, limit its size, without preserving the aspect ratio.
@@ -196,9 +188,7 @@ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
196
188
  SDL_SetWindowSize(shared_window(), actual_width, actual_height);
197
189
  }
198
190
 
199
- #if SDL_VERSION_ATLEAST(2, 0, 1)
200
191
  SDL_GL_GetDrawableSize(shared_window(), &actual_width, &actual_height);
201
- #endif
202
192
 
203
193
  ensure_current_context();
204
194
 
@@ -217,6 +207,27 @@ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
217
207
  black_bar_width, black_bar_height);
218
208
  }
219
209
 
210
+ bool Gosu::Window::resizable() const
211
+ {
212
+ return pimpl->resizable;
213
+ }
214
+
215
+ void Gosu::Window::set_resizable(bool resizable)
216
+ {
217
+ pimpl->resizable = resizable;
218
+ SDL_SetWindowResizable(shared_window(), resizable ? SDL_TRUE : SDL_FALSE);
219
+ }
220
+
221
+ bool Gosu::Window::borderless() const
222
+ {
223
+ return SDL_GetWindowFlags(shared_window()) & SDL_WINDOW_BORDERLESS;
224
+ }
225
+
226
+ void Gosu::Window::set_borderless(bool borderless)
227
+ {
228
+ SDL_SetWindowBordered(shared_window(), borderless ? SDL_FALSE : SDL_TRUE);
229
+ }
230
+
220
231
  double Gosu::Window::update_interval() const
221
232
  {
222
233
  return pimpl->update_interval;
@@ -242,16 +253,34 @@ void Gosu::Window::show()
242
253
  {
243
254
  unsigned long time_before_tick = milliseconds();
244
255
 
245
- while (tick()) {
246
- // Sleep to keep this loop from eating 100% CPU.
247
- unsigned long tick_time = milliseconds() - time_before_tick;
248
- if (tick_time < update_interval()) {
249
- sleep(update_interval() - tick_time);
250
- }
256
+ #ifdef GOSU_IS_WIN
257
+ // Try to convince Windows to only run this thread on the first core, to avoid timing glitches.
258
+ // (If we ever run into a situation where the first core is not available, we should start to
259
+ // use GetProcessAffinityMask to retrieve the allowed cores as a bitmask.)
260
+ DWORD_PTR previous_affinity = SetThreadAffinityMask(GetCurrentThread(), 1);
261
+ #endif
262
+
263
+ try {
264
+ while (tick()) {
265
+ // Sleep to keep this loop from eating 100% CPU.
266
+ unsigned long tick_time = milliseconds() - time_before_tick;
267
+ if (tick_time < update_interval()) {
268
+ sleep(update_interval() - tick_time);
269
+ }
251
270
 
252
- time_before_tick = milliseconds();
271
+ time_before_tick = milliseconds();
272
+ }
273
+ } catch (...) {
274
+ #ifdef GOSU_IS_WIN
275
+ if (previous_affinity) SetThreadAffinityMask(GetCurrentThread(), previous_affinity);
276
+ #endif
277
+ throw;
253
278
  }
254
279
 
280
+ #ifdef GOSU_IS_WIN
281
+ if (previous_affinity) SetThreadAffinityMask(GetCurrentThread(), previous_affinity);
282
+ #endif
283
+
255
284
  pimpl->state = Impl::CLOSED;
256
285
  }
257
286
 
@@ -17,8 +17,7 @@ struct Gosu::Window::Impl
17
17
  string caption;
18
18
  };
19
19
 
20
- Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double update_interval,
21
- bool resizable)
20
+ Gosu::Window::Window(int width, int height, unsigned window_flags, double update_interval)
22
21
  : pimpl(new Impl)
23
22
  {
24
23
  pimpl->window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
@@ -50,12 +49,12 @@ Gosu::Window::~Window()
50
49
  {
51
50
  }
52
51
 
53
- unsigned Gosu::Window::width() const
52
+ int Gosu::Window::width() const
54
53
  {
55
54
  return graphics().width();
56
55
  }
57
56
 
58
- unsigned Gosu::Window::height() const
57
+ int Gosu::Window::height() const
59
58
  {
60
59
  return graphics().height();
61
60
  }
@@ -70,7 +69,20 @@ bool Gosu::Window::resizable() const
70
69
  return false;
71
70
  }
72
71
 
73
- void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
72
+ void Gosu::Window::set_resizable(bool resizable)
73
+ {
74
+ }
75
+
76
+ bool Gosu::Window::borderless() const
77
+ {
78
+ return true;
79
+ }
80
+
81
+ void Gosu::Window::set_borderless(bool borderless)
82
+ {
83
+ }
84
+
85
+ void Gosu::Window::resize(int width, int height, bool fullscreen)
74
86
  {
75
87
  throw logic_error("Cannot resize windows on iOS");
76
88
  }
@@ -138,24 +150,24 @@ void* Gosu::Window::uikit_window() const
138
150
  return (__bridge void*) pimpl->window;
139
151
  }
140
152
 
141
- unsigned Gosu::screen_width(Window*)
153
+ int Gosu::screen_width(Window*)
142
154
  {
143
155
  return available_width() * [UIScreen mainScreen].scale;
144
156
  }
145
157
 
146
- unsigned Gosu::screen_height(Window*)
158
+ int Gosu::screen_height(Window*)
147
159
  {
148
160
  return available_height() * [UIScreen mainScreen].scale;
149
161
  }
150
162
 
151
- unsigned Gosu::available_width(Window*)
163
+ int Gosu::available_width(Window*)
152
164
  {
153
165
  static CGSize screen_size = [UIScreen mainScreen].bounds.size;
154
166
  static CGFloat width = MAX(screen_size.width, screen_size.height);
155
167
  return width;
156
168
  }
157
169
 
158
- unsigned Gosu::available_height(Window*)
170
+ int Gosu::available_height(Window*)
159
171
  {
160
172
  static CGSize screen_size = [UIScreen mainScreen].bounds.size;
161
173
  static CGFloat height = MIN(screen_size.width, screen_size.height);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-28 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  2D game development library.
@@ -186,37 +186,27 @@ files:
186
186
  - dependencies/utf8proc/utf8proc_data.h
187
187
  - ext/gosu/extconf.rb
188
188
  - include/Gosu/Audio.hpp
189
- - include/Gosu/AutoLink.hpp
190
189
  - include/Gosu/Bitmap.hpp
191
190
  - include/Gosu/Buttons.hpp
192
- - include/Gosu/Channel.h
193
- - include/Gosu/Color.h
194
191
  - include/Gosu/Color.hpp
195
192
  - include/Gosu/Directories.hpp
196
- - include/Gosu/Font.h
197
193
  - include/Gosu/Font.hpp
198
194
  - include/Gosu/Fwd.hpp
199
- - include/Gosu/Gosu.h
200
195
  - include/Gosu/Gosu.hpp
201
196
  - include/Gosu/Graphics.hpp
202
197
  - include/Gosu/GraphicsBase.hpp
203
198
  - include/Gosu/IO.hpp
204
- - include/Gosu/Image.h
205
199
  - include/Gosu/Image.hpp
206
200
  - include/Gosu/ImageData.hpp
207
201
  - include/Gosu/Input.hpp
208
202
  - include/Gosu/Inspection.hpp
209
203
  - include/Gosu/Math.hpp
210
204
  - include/Gosu/Platform.hpp
211
- - include/Gosu/Sample.h
212
- - include/Gosu/Song.h
213
205
  - include/Gosu/Text.hpp
214
- - include/Gosu/TextInput.h
215
206
  - include/Gosu/TextInput.hpp
216
207
  - include/Gosu/Timing.hpp
217
208
  - include/Gosu/Utility.hpp
218
209
  - include/Gosu/Version.hpp
219
- - include/Gosu/Window.h
220
210
  - include/Gosu/Window.hpp
221
211
  - lib/OpenAL32.dll
222
212
  - lib/SDL2.dll
@@ -226,13 +216,8 @@ files:
226
216
  - lib/gosu/preview.rb
227
217
  - lib/gosu/run.rb
228
218
  - lib/gosu/swig_patches.rb
229
- - lib/gosu/zen.rb
230
- - lib/libmpg123.dll
231
- - lib/libsndfile.dll
232
219
  - lib64/OpenAL32.dll
233
220
  - lib64/SDL2.dll
234
- - lib64/libmpg123.dll
235
- - lib64/libsndfile.dll
236
221
  - rdoc/gosu.rb
237
222
  - src/Audio.cpp
238
223
  - src/AudioFile.hpp
@@ -245,11 +230,8 @@ files:
245
230
  - src/BlockAllocator.cpp
246
231
  - src/BlockAllocator.hpp
247
232
  - src/Channel.cpp
248
- - src/ChannelWrapper.cpp
249
233
  - src/ClipRectStack.hpp
250
234
  - src/Color.cpp
251
- - src/ColorWrapper.cpp
252
- - src/Constants.cpp
253
235
  - src/DirectoriesApple.cpp
254
236
  - src/DirectoriesUnix.cpp
255
237
  - src/DirectoriesWin.cpp
@@ -259,25 +241,21 @@ files:
259
241
  - src/FileUnix.cpp
260
242
  - src/FileWin.cpp
261
243
  - src/Font.cpp
262
- - src/FontWrapper.cpp
263
244
  - src/GosuGLView.cpp
264
245
  - src/GosuGLView.hpp
265
246
  - src/GosuViewController.cpp
266
247
  - src/GosuViewController.hpp
267
- - src/GosuWrapper.cpp
268
248
  - src/Graphics.cpp
269
249
  - src/GraphicsImpl.hpp
270
250
  - src/IO.cpp
271
251
  - src/Iconv.hpp
272
252
  - src/Image.cpp
273
- - src/ImageWrapper.cpp
274
253
  - src/Input.cpp
275
254
  - src/InputUIKit.cpp
276
255
  - src/Inspection.cpp
277
256
  - src/LargeImageData.cpp
278
257
  - src/LargeImageData.hpp
279
258
  - src/Log.hpp
280
- - src/MPEGFile.hpp
281
259
  - src/Macro.cpp
282
260
  - src/Macro.hpp
283
261
  - src/MarkupParser.cpp
@@ -289,15 +267,12 @@ files:
289
267
  - src/Resolution.cpp
290
268
  - src/RubyGosu.cxx
291
269
  - src/RubyGosu.h
292
- - src/SampleWrapper.cpp
293
- - src/SongWrapper.cpp
294
270
  - src/TexChunk.cpp
295
271
  - src/TexChunk.hpp
296
272
  - src/Text.cpp
297
273
  - src/TextBuilder.cpp
298
274
  - src/TextBuilder.hpp
299
275
  - src/TextInput.cpp
300
- - src/TextInputWrapper.cpp
301
276
  - src/Texture.cpp
302
277
  - src/Texture.hpp
303
278
  - src/TimingApple.cpp
@@ -318,7 +293,6 @@ files:
318
293
  - src/WinUtility.hpp
319
294
  - src/Window.cpp
320
295
  - src/WindowUIKit.cpp
321
- - src/WindowWrapper.cpp
322
296
  homepage: https://www.libgosu.org/
323
297
  licenses:
324
298
  - MIT
@@ -335,12 +309,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
335
309
  requirements:
336
310
  - - ">="
337
311
  - !ruby/object:Gem::Version
338
- version: 1.9.3
312
+ version: 2.5.0
339
313
  required_rubygems_version: !ruby/object:Gem::Requirement
340
314
  requirements:
341
- - - ">"
315
+ - - ">="
342
316
  - !ruby/object:Gem::Version
343
- version: 1.3.1
317
+ version: '0'
344
318
  requirements: []
345
319
  rubygems_version: 3.2.3
346
320
  signing_key:
@@ -1,14 +0,0 @@
1
- //! \file AutoLink.hpp
2
- //! Contains pragmas that make MSVC link against all the necessary libraries
3
- //! automatically.
4
-
5
- #ifdef _MSC_VER
6
- #pragma once
7
-
8
- #ifdef NDEBUG
9
- #pragma comment(lib, "Gosu.lib")
10
- #else
11
- #pragma comment(lib, "GosuDebug.lib")
12
- #endif
13
-
14
- #endif
@@ -1,25 +0,0 @@
1
- #pragma once
2
-
3
- #ifdef __cplusplus
4
- extern "C" {
5
- #endif
6
-
7
- typedef struct Gosu_Channel Gosu_Channel;
8
-
9
- Gosu_Channel* Gosu_Channel_create(Gosu_Channel* channel);
10
- void Gosu_Channel_destroy(Gosu_Channel* channel);
11
-
12
- void Gosu_Channel_play(Gosu_Channel *channel);
13
- bool Gosu_Channel_playing(Gosu_Channel *channel);
14
- void Gosu_Channel_pause(Gosu_Channel *channel);
15
- bool Gosu_Channel_paused(Gosu_Channel *channel);
16
- void Gosu_Channel_resume(Gosu_Channel *channel);
17
- void Gosu_Channel_stop(Gosu_Channel *channel);
18
-
19
- void Gosu_Channel_set_volume(Gosu_Channel *channel, double volume);
20
- void Gosu_Channel_set_speed(Gosu_Channel *channel, double speed);
21
- void Gosu_Channel_set_pan(Gosu_Channel *channel, double pan);
22
-
23
- #ifdef __cplusplus
24
- }
25
- #endif