gosu 1.0.0 → 1.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,7 +28,6 @@ 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);
32
31
  virtual ~SwigDirector_Window();
33
32
  virtual void show();
34
33
  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
+ (font_flags & Gosu::FF_ITALIC) ? 1 : 0,
36
+ (font_flags & Gosu::FF_UNDERLINE) ? 1 : 0,
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>
@@ -87,13 +91,11 @@ struct Gosu::Window::Impl
87
91
  unique_ptr<Input> input;
88
92
  };
89
93
 
90
- Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double update_interval,
91
- bool resizable)
94
+ Gosu::Window::Window(int width, int height, unsigned window_flags, double update_interval)
92
95
  : pimpl(new Impl)
93
96
  {
94
- #if SDL_VERSION_ATLEAST(2, 0, 5)
95
- SDL_SetWindowResizable(shared_window(), (SDL_bool)resizable);
96
- #endif
97
+ set_borderless(window_flags & WF_BORDERLESS);
98
+ set_resizable(window_flags & WF_RESIZABLE);
97
99
 
98
100
  // Even in fullscreen mode, temporarily show the window in windowed mode to centre it.
99
101
  // This ensures that the window will be centered correctly when exiting fullscreen mode.
@@ -103,12 +105,11 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double up
103
105
  SDL_SetWindowPosition(shared_window(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
104
106
 
105
107
  // Really enable fullscreen if desired.
106
- resize(width, height, fullscreen);
108
+ resize(width, height, (window_flags & WF_FULLSCREEN));
107
109
 
108
110
  SDL_GL_SetSwapInterval(1);
109
111
 
110
112
  pimpl->update_interval = update_interval;
111
- pimpl->resizable = resizable;
112
113
 
113
114
  input().on_button_down = [this](Button button) { button_down(button); };
114
115
  input().on_button_up = [this](Button button) { button_up(button); };
@@ -121,12 +122,12 @@ Gosu::Window::~Window()
121
122
  SDL_HideWindow(shared_window());
122
123
  }
123
124
 
124
- unsigned Gosu::Window::width() const
125
+ int Gosu::Window::width() const
125
126
  {
126
127
  return graphics().width();
127
128
  }
128
129
 
129
- unsigned Gosu::Window::height() const
130
+ int Gosu::Window::height() const
130
131
  {
131
132
  return graphics().height();
132
133
  }
@@ -136,12 +137,7 @@ bool Gosu::Window::fullscreen() const
136
137
  return pimpl->fullscreen;
137
138
  }
138
139
 
139
- bool Gosu::Window::resizable() const
140
- {
141
- return pimpl->resizable;
142
- }
143
-
144
- void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
140
+ void Gosu::Window::resize(int width, int height, bool fullscreen)
145
141
  {
146
142
  pimpl->fullscreen = fullscreen;
147
143
 
@@ -175,8 +171,8 @@ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
175
171
  }
176
172
  }
177
173
  else {
178
- unsigned max_width = Gosu::available_width(this);
179
- unsigned max_height = Gosu::available_height(this);
174
+ int max_width = Gosu::available_width(this);
175
+ int max_height = Gosu::available_height(this);
180
176
 
181
177
  if (resizable()) {
182
178
  // If the window is resizable, limit its size, without preserving the aspect ratio.
@@ -217,6 +213,29 @@ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
217
213
  black_bar_width, black_bar_height);
218
214
  }
219
215
 
216
+ bool Gosu::Window::resizable() const
217
+ {
218
+ return pimpl->resizable;
219
+ }
220
+
221
+ void Gosu::Window::set_resizable(bool resizable)
222
+ {
223
+ pimpl->resizable = resizable;
224
+ #if SDL_VERSION_ATLEAST(2, 0, 5)
225
+ SDL_SetWindowResizable(shared_window(), resizable ? SDL_TRUE : SDL_FALSE);
226
+ #endif
227
+ }
228
+
229
+ bool Gosu::Window::borderless() const
230
+ {
231
+ return SDL_GetWindowFlags(shared_window()) & SDL_WINDOW_BORDERLESS;
232
+ }
233
+
234
+ void Gosu::Window::set_borderless(bool borderless)
235
+ {
236
+ SDL_SetWindowBordered(shared_window(), borderless ? SDL_FALSE : SDL_TRUE);
237
+ }
238
+
220
239
  double Gosu::Window::update_interval() const
221
240
  {
222
241
  return pimpl->update_interval;
@@ -242,16 +261,34 @@ void Gosu::Window::show()
242
261
  {
243
262
  unsigned long time_before_tick = milliseconds();
244
263
 
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
- }
264
+ #ifdef GOSU_IS_WIN
265
+ // Try to convince Windows to only run this thread on the first core, to avoid timing glitches.
266
+ // (If we ever run into a situation where the first core is not available, we should start to
267
+ // use GetProcessAffinityMask to retrieve the allowed cores as a bitmask.)
268
+ DWORD_PTR previous_affinity = SetThreadAffinityMask(GetCurrentThread(), 1);
269
+ #endif
270
+
271
+ try {
272
+ while (tick()) {
273
+ // Sleep to keep this loop from eating 100% CPU.
274
+ unsigned long tick_time = milliseconds() - time_before_tick;
275
+ if (tick_time < update_interval()) {
276
+ sleep(update_interval() - tick_time);
277
+ }
251
278
 
252
- time_before_tick = milliseconds();
279
+ time_before_tick = milliseconds();
280
+ }
281
+ } catch (...) {
282
+ #ifdef GOSU_IS_WIN
283
+ if (previous_affinity) SetThreadAffinityMask(GetCurrentThread(), previous_affinity);
284
+ #endif
285
+ throw;
253
286
  }
254
287
 
288
+ #ifdef GOSU_IS_WIN
289
+ if (previous_affinity) SetThreadAffinityMask(GetCurrentThread(), previous_affinity);
290
+ #endif
291
+
255
292
  pimpl->state = Impl::CLOSED;
256
293
  }
257
294
 
@@ -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
4
+ version: 1.1.0.pre1
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-29 00:00:00.000000000 Z
11
+ date: 2021-01-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  2D game development library.
@@ -188,34 +188,25 @@ files:
188
188
  - include/Gosu/Audio.hpp
189
189
  - include/Gosu/Bitmap.hpp
190
190
  - include/Gosu/Buttons.hpp
191
- - include/Gosu/Channel.h
192
- - include/Gosu/Color.h
193
191
  - include/Gosu/Color.hpp
194
192
  - include/Gosu/Directories.hpp
195
- - include/Gosu/Font.h
196
193
  - include/Gosu/Font.hpp
197
194
  - include/Gosu/Fwd.hpp
198
- - include/Gosu/Gosu.h
199
195
  - include/Gosu/Gosu.hpp
200
196
  - include/Gosu/Graphics.hpp
201
197
  - include/Gosu/GraphicsBase.hpp
202
198
  - include/Gosu/IO.hpp
203
- - include/Gosu/Image.h
204
199
  - include/Gosu/Image.hpp
205
200
  - include/Gosu/ImageData.hpp
206
201
  - include/Gosu/Input.hpp
207
202
  - include/Gosu/Inspection.hpp
208
203
  - include/Gosu/Math.hpp
209
204
  - include/Gosu/Platform.hpp
210
- - include/Gosu/Sample.h
211
- - include/Gosu/Song.h
212
205
  - include/Gosu/Text.hpp
213
- - include/Gosu/TextInput.h
214
206
  - include/Gosu/TextInput.hpp
215
207
  - include/Gosu/Timing.hpp
216
208
  - include/Gosu/Utility.hpp
217
209
  - include/Gosu/Version.hpp
218
- - include/Gosu/Window.h
219
210
  - include/Gosu/Window.hpp
220
211
  - lib/OpenAL32.dll
221
212
  - lib/SDL2.dll
@@ -239,11 +230,8 @@ files:
239
230
  - src/BlockAllocator.cpp
240
231
  - src/BlockAllocator.hpp
241
232
  - src/Channel.cpp
242
- - src/ChannelWrapper.cpp
243
233
  - src/ClipRectStack.hpp
244
234
  - src/Color.cpp
245
- - src/ColorWrapper.cpp
246
- - src/Constants.cpp
247
235
  - src/DirectoriesApple.cpp
248
236
  - src/DirectoriesUnix.cpp
249
237
  - src/DirectoriesWin.cpp
@@ -253,25 +241,21 @@ files:
253
241
  - src/FileUnix.cpp
254
242
  - src/FileWin.cpp
255
243
  - src/Font.cpp
256
- - src/FontWrapper.cpp
257
244
  - src/GosuGLView.cpp
258
245
  - src/GosuGLView.hpp
259
246
  - src/GosuViewController.cpp
260
247
  - src/GosuViewController.hpp
261
- - src/GosuWrapper.cpp
262
248
  - src/Graphics.cpp
263
249
  - src/GraphicsImpl.hpp
264
250
  - src/IO.cpp
265
251
  - src/Iconv.hpp
266
252
  - src/Image.cpp
267
- - src/ImageWrapper.cpp
268
253
  - src/Input.cpp
269
254
  - src/InputUIKit.cpp
270
255
  - src/Inspection.cpp
271
256
  - src/LargeImageData.cpp
272
257
  - src/LargeImageData.hpp
273
258
  - src/Log.hpp
274
- - src/MPEGFile.hpp
275
259
  - src/Macro.cpp
276
260
  - src/Macro.hpp
277
261
  - src/MarkupParser.cpp
@@ -283,15 +267,12 @@ files:
283
267
  - src/Resolution.cpp
284
268
  - src/RubyGosu.cxx
285
269
  - src/RubyGosu.h
286
- - src/SampleWrapper.cpp
287
- - src/SongWrapper.cpp
288
270
  - src/TexChunk.cpp
289
271
  - src/TexChunk.hpp
290
272
  - src/Text.cpp
291
273
  - src/TextBuilder.cpp
292
274
  - src/TextBuilder.hpp
293
275
  - src/TextInput.cpp
294
- - src/TextInputWrapper.cpp
295
276
  - src/Texture.cpp
296
277
  - src/Texture.hpp
297
278
  - src/TimingApple.cpp
@@ -312,7 +293,6 @@ files:
312
293
  - src/WinUtility.hpp
313
294
  - src/Window.cpp
314
295
  - src/WindowUIKit.cpp
315
- - src/WindowWrapper.cpp
316
296
  homepage: https://www.libgosu.org/
317
297
  licenses:
318
298
  - MIT
@@ -332,9 +312,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
332
312
  version: 2.5.0
333
313
  required_rubygems_version: !ruby/object:Gem::Requirement
334
314
  requirements:
335
- - - ">="
315
+ - - ">"
336
316
  - !ruby/object:Gem::Version
337
- version: '0'
317
+ version: 1.3.1
338
318
  requirements: []
339
319
  rubygems_version: 3.2.3
340
320
  signing_key:
@@ -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
@@ -1,38 +0,0 @@
1
- #pragma once
2
-
3
- #ifdef __cplusplus
4
- extern "C" {
5
- #endif
6
-
7
- typedef unsigned char Gosu_Color_Channel;
8
-
9
- unsigned Gosu_Color_create(unsigned argb);
10
- unsigned Gosu_Color_create_argb(Gosu_Color_Channel a, Gosu_Color_Channel r, Gosu_Color_Channel g, Gosu_Color_Channel b);
11
- unsigned Gosu_Color_create_from_hsv(double h, double s, double v);
12
- unsigned Gosu_Color_create_from_ahsv(Gosu_Color_Channel alpha, double h, double s, double v);
13
-
14
- Gosu_Color_Channel Gosu_Color_alpha(unsigned color);
15
- Gosu_Color_Channel Gosu_Color_red(unsigned color);
16
- Gosu_Color_Channel Gosu_Color_green(unsigned color);
17
- Gosu_Color_Channel Gosu_Color_blue(unsigned color);
18
- unsigned Gosu_Color_set_alpha(unsigned color, Gosu_Color_Channel value);
19
- unsigned Gosu_Color_set_red(unsigned color, Gosu_Color_Channel value);
20
- unsigned Gosu_Color_set_green(unsigned color, Gosu_Color_Channel value);
21
- unsigned Gosu_Color_set_blue(unsigned color, Gosu_Color_Channel value);
22
-
23
- double Gosu_Color_hue(unsigned color);
24
- double Gosu_Color_saturation(unsigned color);
25
- double Gosu_Color_value(unsigned color);
26
- unsigned Gosu_Color_set_hue(unsigned color, double value);
27
- unsigned Gosu_Color_set_saturation(unsigned color, double value);
28
- unsigned Gosu_Color_set_value(unsigned color, double value);
29
-
30
- unsigned Gosu_Color_argb(unsigned color);
31
- unsigned Gosu_Color_bgr(unsigned color);
32
- unsigned Gosu_Color_abgr(unsigned color);
33
-
34
- unsigned Gosu_Color_gl(unsigned color);
35
-
36
- #ifdef __cplusplus
37
- }
38
- #endif
@@ -1,36 +0,0 @@
1
- #pragma once
2
-
3
- #ifdef __cplusplus
4
- extern "C" {
5
- #endif
6
-
7
- typedef struct Gosu_Font Gosu_Font;
8
-
9
- Gosu_Font* Gosu_Font_create(int height, const char* name, unsigned flags);
10
-
11
- const char *Gosu_Font_name(Gosu_Font* font);
12
- int Gosu_Font_height(Gosu_Font* font);
13
- unsigned Gosu_Font_flags(Gosu_Font* font);
14
-
15
- double Gosu_Font_text_width(Gosu_Font* font, const char* text);
16
- double Gosu_Font_markup_width(Gosu_Font* font, const char* text);
17
-
18
- void Gosu_Font_draw_text(Gosu_Font* font, const char* text, double x, double y, double z,
19
- double scale_x, double scale_y, unsigned c, unsigned mode);
20
- void Gosu_Font_draw_markup(Gosu_Font* font, const char* text, double x, double y, double z,
21
- double scale_x, double scale_y, unsigned c, unsigned mode);
22
-
23
- void Gosu_Font_draw_text_rel(Gosu_Font* font, const char* text, double x, double y, double z,
24
- double rel_x, double rel_y, double scale_x, double scale_y,
25
- unsigned c, unsigned mode);
26
- void Gosu_Font_draw_markup_rel(Gosu_Font* font, const char* text, double x, double y, double z,
27
- double rel_x, double rel_y, double scale_x, double scale_y,
28
- unsigned c, unsigned mode);
29
-
30
- void Gosu_Font_set_image(Gosu_Font* font, const char* codepoint, unsigned font_flags, Gosu_Image* image);
31
-
32
- void Gosu_Font_destroy(Gosu_Font* font);
33
-
34
- #ifdef __cplusplus
35
- }
36
- #endif