gosu 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gosu/Graphics.hpp +0 -6
- data/Gosu/Version.hpp +2 -2
- data/Gosu/Window.hpp +19 -2
- data/ext/gosu/extconf.rb +2 -0
- data/ext/gosu/gosu_wrap.cxx +94 -48
- data/src/Audio/AudioOpenAL.cpp +2 -2
- data/src/Graphics/ClipRectStack.hpp +1 -1
- data/src/Graphics/Color.cpp +4 -4
- data/src/Graphics/LargeImageData.cpp +2 -2
- data/src/Graphics/Macro.hpp +1 -1
- data/src/Graphics/RenderState.hpp +4 -3
- data/src/Graphics/Resolution.cpp +92 -0
- data/src/Graphics/ResolutionApple.mm +19 -0
- data/src/Inspection.cpp +3 -2
- data/src/Text/FormattedString.hpp +5 -5
- data/src/Text/TextApple.mm +1 -1
- data/src/Window.cpp +23 -43
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2094143800954943e5e1d0caa49cb31ade07524
|
4
|
+
data.tar.gz: db763a9ef9839cdbae87f22b429f11b33a5fa045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d402e2be429707bc108ce0a0f409156c03f2f5f582f15ad624b1d8527bbd9709deecf457184aee0e4e24c664fac13b91c02adb182519a7931f07b506f03dccd
|
7
|
+
data.tar.gz: 94a2b28e2490fd40c5b3a2e61f6c9b10d6d1b4fe07534076e7c688b5501506e800dc4f1bf47b8c5fb82bbcb4c607fb56c94fc5d3c05208a57eedd4a98cdb2b0d
|
data/Gosu/Graphics.hpp
CHANGED
@@ -12,12 +12,6 @@
|
|
12
12
|
|
13
13
|
namespace Gosu
|
14
14
|
{
|
15
|
-
//! Returns the width, in pixels, of the user's primary screen.
|
16
|
-
unsigned screenWidth();
|
17
|
-
|
18
|
-
//! Returns the height, in pixels, of the user's primary screen.
|
19
|
-
unsigned screenHeight();
|
20
|
-
|
21
15
|
//! Returns the maximum size of an texture that will be allocated
|
22
16
|
//! internally by Gosu.
|
23
17
|
//! Useful when extending Gosu using OpenGL.
|
data/Gosu/Version.hpp
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
#define GOSU_MAJOR_VERSION 0
|
5
5
|
#define GOSU_MINOR_VERSION 8
|
6
|
-
#define GOSU_POINT_VERSION
|
7
|
-
#define GOSU_VERSION "0.8.
|
6
|
+
#define GOSU_POINT_VERSION 4
|
7
|
+
#define GOSU_VERSION "0.8.4"
|
8
8
|
|
9
9
|
#define GOSU_COPYRIGHT_NOTICE \
|
10
10
|
"This software uses the following third-party libraries:\n" \
|
data/Gosu/Window.hpp
CHANGED
@@ -20,6 +20,20 @@
|
|
20
20
|
|
21
21
|
namespace Gosu
|
22
22
|
{
|
23
|
+
//! Returns the width (in pixels) of the user's primary screen.
|
24
|
+
unsigned screenWidth();
|
25
|
+
|
26
|
+
//! Returns the height (in pixels) of the user's primary screen.
|
27
|
+
unsigned screenHeight();
|
28
|
+
|
29
|
+
//! Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
|
30
|
+
//! All windows larger than this size will automatically be shrunk to fit.
|
31
|
+
unsigned availableWidth();
|
32
|
+
|
33
|
+
//! Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
|
34
|
+
//! All windows larger than this size will automatically be shrunk to fit.
|
35
|
+
unsigned availableHeight();
|
36
|
+
|
23
37
|
//! Convenient all-in-one class that serves as the foundation of a standard
|
24
38
|
//! Gosu application. Manages initialization of all of Gosu's core components
|
25
39
|
//! and provides timing functionality.
|
@@ -38,6 +52,9 @@ namespace Gosu
|
|
38
52
|
|
39
53
|
public:
|
40
54
|
//! Constructs a Window.
|
55
|
+
//! \param width Width of the window in points; that is, pixels on a normal display, and 'virtual pixels' on a
|
56
|
+
//! high-resolution display.
|
57
|
+
//! \param height See width.
|
41
58
|
//! \param updateInterval Interval in milliseconds between two calls
|
42
59
|
//! to the update member function.
|
43
60
|
Window(unsigned width, unsigned height, bool fullscreen,
|
@@ -63,8 +80,8 @@ namespace Gosu
|
|
63
80
|
virtual void draw() {}
|
64
81
|
|
65
82
|
//! Gives the game a chance to say no to being redrawn.
|
66
|
-
//! This is not a definitive answer. The operating system can still
|
67
|
-
//!
|
83
|
+
//! This is not a definitive answer. The operating system can still force
|
84
|
+
//! the window to redraw itself.
|
68
85
|
//! By default, the window is redrawn all the time.
|
69
86
|
virtual bool needsRedraw() const { return true; }
|
70
87
|
|
data/ext/gosu/extconf.rb
CHANGED
@@ -28,6 +28,7 @@ BASE_FILES = %w(
|
|
28
28
|
Graphics/Graphics.cpp
|
29
29
|
Graphics/Image.cpp
|
30
30
|
Graphics/LargeImageData.cpp
|
31
|
+
Graphics/Resolution.cpp
|
31
32
|
Graphics/TexChunk.cpp
|
32
33
|
Graphics/Texture.cpp
|
33
34
|
Graphics/Transform.cpp
|
@@ -45,6 +46,7 @@ BASE_FILES = %w(
|
|
45
46
|
MAC_FILES = %w(
|
46
47
|
Audio/AudioOpenAL.mm
|
47
48
|
Bitmap/BitmapApple.mm
|
49
|
+
Graphics/ResolutionApple.mm
|
48
50
|
Text/TextApple.mm
|
49
51
|
Text/TextMac.cpp
|
50
52
|
TimingApple.cpp
|
data/ext/gosu/gosu_wrap.cxx
CHANGED
@@ -3379,50 +3379,6 @@ fail:
|
|
3379
3379
|
}
|
3380
3380
|
|
3381
3381
|
|
3382
|
-
SWIGINTERN VALUE
|
3383
|
-
_wrap_screen_width(int argc, VALUE *argv, VALUE self) {
|
3384
|
-
unsigned int result;
|
3385
|
-
VALUE vresult = Qnil;
|
3386
|
-
|
3387
|
-
if ((argc < 0) || (argc > 0)) {
|
3388
|
-
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
3389
|
-
}
|
3390
|
-
{
|
3391
|
-
try {
|
3392
|
-
result = (unsigned int)Gosu::screenWidth();
|
3393
|
-
} catch (const std::exception& e) {
|
3394
|
-
SWIG_exception(SWIG_RuntimeError, e.what());
|
3395
|
-
}
|
3396
|
-
}
|
3397
|
-
vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
|
3398
|
-
return vresult;
|
3399
|
-
fail:
|
3400
|
-
return Qnil;
|
3401
|
-
}
|
3402
|
-
|
3403
|
-
|
3404
|
-
SWIGINTERN VALUE
|
3405
|
-
_wrap_screen_height(int argc, VALUE *argv, VALUE self) {
|
3406
|
-
unsigned int result;
|
3407
|
-
VALUE vresult = Qnil;
|
3408
|
-
|
3409
|
-
if ((argc < 0) || (argc > 0)) {
|
3410
|
-
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
3411
|
-
}
|
3412
|
-
{
|
3413
|
-
try {
|
3414
|
-
result = (unsigned int)Gosu::screenHeight();
|
3415
|
-
} catch (const std::exception& e) {
|
3416
|
-
SWIG_exception(SWIG_RuntimeError, e.what());
|
3417
|
-
}
|
3418
|
-
}
|
3419
|
-
vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
|
3420
|
-
return vresult;
|
3421
|
-
fail:
|
3422
|
-
return Qnil;
|
3423
|
-
}
|
3424
|
-
|
3425
|
-
|
3426
3382
|
SWIGINTERN VALUE
|
3427
3383
|
_wrap_language(int argc, VALUE *argv, VALUE self) {
|
3428
3384
|
std::string result;
|
@@ -8270,6 +8226,94 @@ fail:
|
|
8270
8226
|
}
|
8271
8227
|
|
8272
8228
|
|
8229
|
+
SWIGINTERN VALUE
|
8230
|
+
_wrap_screen_width(int argc, VALUE *argv, VALUE self) {
|
8231
|
+
unsigned int result;
|
8232
|
+
VALUE vresult = Qnil;
|
8233
|
+
|
8234
|
+
if ((argc < 0) || (argc > 0)) {
|
8235
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
8236
|
+
}
|
8237
|
+
{
|
8238
|
+
try {
|
8239
|
+
result = (unsigned int)Gosu::screenWidth();
|
8240
|
+
} catch (const std::exception& e) {
|
8241
|
+
SWIG_exception(SWIG_RuntimeError, e.what());
|
8242
|
+
}
|
8243
|
+
}
|
8244
|
+
vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
|
8245
|
+
return vresult;
|
8246
|
+
fail:
|
8247
|
+
return Qnil;
|
8248
|
+
}
|
8249
|
+
|
8250
|
+
|
8251
|
+
SWIGINTERN VALUE
|
8252
|
+
_wrap_screen_height(int argc, VALUE *argv, VALUE self) {
|
8253
|
+
unsigned int result;
|
8254
|
+
VALUE vresult = Qnil;
|
8255
|
+
|
8256
|
+
if ((argc < 0) || (argc > 0)) {
|
8257
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
8258
|
+
}
|
8259
|
+
{
|
8260
|
+
try {
|
8261
|
+
result = (unsigned int)Gosu::screenHeight();
|
8262
|
+
} catch (const std::exception& e) {
|
8263
|
+
SWIG_exception(SWIG_RuntimeError, e.what());
|
8264
|
+
}
|
8265
|
+
}
|
8266
|
+
vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
|
8267
|
+
return vresult;
|
8268
|
+
fail:
|
8269
|
+
return Qnil;
|
8270
|
+
}
|
8271
|
+
|
8272
|
+
|
8273
|
+
SWIGINTERN VALUE
|
8274
|
+
_wrap_available_width(int argc, VALUE *argv, VALUE self) {
|
8275
|
+
unsigned int result;
|
8276
|
+
VALUE vresult = Qnil;
|
8277
|
+
|
8278
|
+
if ((argc < 0) || (argc > 0)) {
|
8279
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
8280
|
+
}
|
8281
|
+
{
|
8282
|
+
try {
|
8283
|
+
result = (unsigned int)Gosu::availableWidth();
|
8284
|
+
} catch (const std::exception& e) {
|
8285
|
+
SWIG_exception(SWIG_RuntimeError, e.what());
|
8286
|
+
}
|
8287
|
+
}
|
8288
|
+
vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
|
8289
|
+
return vresult;
|
8290
|
+
fail:
|
8291
|
+
return Qnil;
|
8292
|
+
}
|
8293
|
+
|
8294
|
+
|
8295
|
+
SWIGINTERN VALUE
|
8296
|
+
_wrap_available_height(int argc, VALUE *argv, VALUE self) {
|
8297
|
+
unsigned int result;
|
8298
|
+
VALUE vresult = Qnil;
|
8299
|
+
|
8300
|
+
if ((argc < 0) || (argc > 0)) {
|
8301
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
8302
|
+
}
|
8303
|
+
{
|
8304
|
+
try {
|
8305
|
+
result = (unsigned int)Gosu::availableHeight();
|
8306
|
+
} catch (const std::exception& e) {
|
8307
|
+
SWIG_exception(SWIG_RuntimeError, e.what());
|
8308
|
+
}
|
8309
|
+
}
|
8310
|
+
vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
|
8311
|
+
return vresult;
|
8312
|
+
fail:
|
8313
|
+
return Qnil;
|
8314
|
+
}
|
8315
|
+
|
8316
|
+
|
8273
8317
|
static swig_class SwigClassWindow;
|
8274
8318
|
|
8275
8319
|
#ifdef HAVE_RB_DEFINE_ALLOC_FUNC
|
@@ -10832,8 +10876,8 @@ SWIGEXPORT void Init_gosu(void) {
|
|
10832
10876
|
SWIG_RubyInitializeTrackings();
|
10833
10877
|
rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
|
10834
10878
|
rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(8)));
|
10835
|
-
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(
|
10836
|
-
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.8.
|
10879
|
+
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(4)));
|
10880
|
+
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.8.4"));
|
10837
10881
|
rb_define_const(mGosu, "GOSU_COPYRIGHT_NOTICE", SWIG_FromCharPtr("This software uses the following third-party libraries:\n\nGosu, http://www.libgosu.org, MIT License, http://opensource.org/licenses/MIT\nSDL 2, http://www.libsdl.org, MIT License, http://opensource.org/licenses/MIT\nFreeImage, http://freeimage.sourceforge.net, FreeImage Public License\nlibogg & libvorbis, http://www.xiph.org, BSD License, 3-Clause Version, http://www.xiph.org/licenses/bsd\nlibsndfile, http://www.mega-nerd.com/libsndfile, GNU LGPL 3, http://www.gnu.org/copyleft/lesser.html\nOpenAL Soft, http://kcat.strangesoft.net/openal.html, GNU LGPL 2, http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html\n"));
|
10838
10882
|
rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
|
10839
10883
|
rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
|
@@ -10846,8 +10890,6 @@ SWIGEXPORT void Init_gosu(void) {
|
|
10846
10890
|
rb_define_module_function(mGosu, "normalize_angle", VALUEFUNC(_wrap_normalize_angle), -1);
|
10847
10891
|
rb_define_module_function(mGosu, "distance", VALUEFUNC(_wrap_distance), -1);
|
10848
10892
|
rb_define_module_function(mGosu, "default_font_name", VALUEFUNC(_wrap_default_font_name), -1);
|
10849
|
-
rb_define_module_function(mGosu, "screen_width", VALUEFUNC(_wrap_screen_width), -1);
|
10850
|
-
rb_define_module_function(mGosu, "screen_height", VALUEFUNC(_wrap_screen_height), -1);
|
10851
10893
|
rb_define_const(mGosu, "MAX_TEXTURE_SIZE", SWIG_From_unsigned_SS_int(static_cast< unsigned int >(Gosu::MAX_TEXTURE_SIZE)));
|
10852
10894
|
rb_define_module_function(mGosu, "language", VALUEFUNC(_wrap_language), -1);
|
10853
10895
|
rb_define_module_function(mGosu, "enable_undocumented_retrofication", VALUEFUNC(_wrap_enable_undocumented_retrofication), -1);
|
@@ -11223,6 +11265,10 @@ SWIGEXPORT void Init_gosu(void) {
|
|
11223
11265
|
SwigClassTextInput.mark = 0;
|
11224
11266
|
SwigClassTextInput.destroy = (void (*)(void *)) free_Gosu_TextInput;
|
11225
11267
|
SwigClassTextInput.trackObjects = 1;
|
11268
|
+
rb_define_module_function(mGosu, "screen_width", VALUEFUNC(_wrap_screen_width), -1);
|
11269
|
+
rb_define_module_function(mGosu, "screen_height", VALUEFUNC(_wrap_screen_height), -1);
|
11270
|
+
rb_define_module_function(mGosu, "available_width", VALUEFUNC(_wrap_available_width), -1);
|
11271
|
+
rb_define_module_function(mGosu, "available_height", VALUEFUNC(_wrap_available_height), -1);
|
11226
11272
|
rb_define_module_function(mGosu, "disown_Window", VALUEFUNC(_wrap_disown_Window), -1);
|
11227
11273
|
|
11228
11274
|
SwigClassWindow.klass = rb_define_class_under(mGosu, "Window", rb_cObject);
|
data/src/Audio/AudioOpenAL.cpp
CHANGED
@@ -155,7 +155,7 @@ struct Gosu::Sample::SampleData
|
|
155
155
|
alBufferData(buffer,
|
156
156
|
audioFile.format(),
|
157
157
|
&audioFile.decodedData().front(),
|
158
|
-
audioFile.decodedData().size(),
|
158
|
+
(ALsizei)audioFile.decodedData().size(),
|
159
159
|
audioFile.sampleRate());
|
160
160
|
}
|
161
161
|
|
@@ -352,7 +352,7 @@ class Gosu::Song::StreamData : public BaseData
|
|
352
352
|
char audioData[BUFFER_SIZE];
|
353
353
|
std::size_t readBytes = file->readData(audioData, BUFFER_SIZE);
|
354
354
|
if (readBytes > 0)
|
355
|
-
alBufferData(buffer, file->format(), audioData, readBytes, file->sampleRate());
|
355
|
+
alBufferData(buffer, file->format(), audioData, (ALsizei)readBytes, file->sampleRate());
|
356
356
|
return readBytes > 0;
|
357
357
|
}
|
358
358
|
|
@@ -21,7 +21,7 @@ class Gosu::ClipRectStack
|
|
21
21
|
}
|
22
22
|
|
23
23
|
ClipRect result = { 0.0, 0.0, 1e10, 1e10 };
|
24
|
-
for (
|
24
|
+
for (std::size_t i = 0, end = stack.size(); i < end; ++i)
|
25
25
|
{
|
26
26
|
const ClipRect& rect = stack[i];
|
27
27
|
int resultRight = std::min(result.x + result.width, rect.x + rect.width);
|
data/src/Graphics/Color.cpp
CHANGED
@@ -111,10 +111,10 @@ void Gosu::Color::setValue(double v)
|
|
111
111
|
|
112
112
|
Gosu::Color Gosu::interpolate(Color a, Color b, double weight)
|
113
113
|
{
|
114
|
-
return Color(clamp<
|
115
|
-
clamp<
|
116
|
-
clamp<
|
117
|
-
clamp<
|
114
|
+
return Color(clamp<long>(round(Gosu::interpolate(a.alpha(), b.alpha(), weight)), 0, 255),
|
115
|
+
clamp<long>(round(Gosu::interpolate(a.red(), b.red(), weight)), 0, 255),
|
116
|
+
clamp<long>(round(Gosu::interpolate(a.green(), b.green(), weight)), 0, 255),
|
117
|
+
clamp<long>(round(Gosu::interpolate(a.blue(), b.blue(), weight)), 0, 255));
|
118
118
|
}
|
119
119
|
|
120
120
|
Gosu::Color Gosu::multiply(Color a, Color b)
|
@@ -12,8 +12,8 @@ Gosu::LargeImageData::LargeImageData(Graphics& graphics,
|
|
12
12
|
{
|
13
13
|
fullWidth = source.width();
|
14
14
|
fullHeight = source.height();
|
15
|
-
partsX = trunc(ceil(1.0 * source.width() / partWidth));
|
16
|
-
partsY = trunc(ceil(1.0 * source.height() / partHeight));
|
15
|
+
partsX = static_cast<unsigned>(trunc(ceil(1.0 * source.width() / partWidth)));
|
16
|
+
partsY = static_cast<unsigned>(trunc(ceil(1.0 * source.height() / partHeight)));
|
17
17
|
this->partWidth = partWidth;
|
18
18
|
this->partHeight = partHeight;
|
19
19
|
|
data/src/Graphics/Macro.hpp
CHANGED
@@ -183,7 +183,7 @@ class Gosu::Macro : public Gosu::ImageData
|
|
183
183
|
it->renderState.apply();
|
184
184
|
glMultMatrixd(&transform[0]);
|
185
185
|
glInterleavedArrays(GL_T2F_C4UB_V3F, 0, &it->vertices[0]);
|
186
|
-
glDrawArrays(GL_QUADS, 0, it->vertices.size());
|
186
|
+
glDrawArrays(GL_QUADS, 0, (GLsizei)it->vertices.size());
|
187
187
|
glPopMatrix();
|
188
188
|
}
|
189
189
|
#endif
|
@@ -33,7 +33,9 @@ struct Gosu::RenderState
|
|
33
33
|
glBindTexture(GL_TEXTURE_2D, texture->texName());
|
34
34
|
}
|
35
35
|
else
|
36
|
+
{
|
36
37
|
glDisable(GL_TEXTURE_2D);
|
38
|
+
}
|
37
39
|
}
|
38
40
|
|
39
41
|
void applyAlphaMode() const
|
@@ -49,7 +51,9 @@ struct Gosu::RenderState
|
|
49
51
|
void applyClipRect() const
|
50
52
|
{
|
51
53
|
if (clipRect.width == NO_CLIPPING)
|
54
|
+
{
|
52
55
|
glDisable(GL_SCISSOR_TEST);
|
56
|
+
}
|
53
57
|
else
|
54
58
|
{
|
55
59
|
glEnable(GL_SCISSOR_TEST);
|
@@ -187,9 +191,6 @@ public:
|
|
187
191
|
// The cached values may have been messed with. Reset them again.
|
188
192
|
void enforceAfterUntrustedGL() const
|
189
193
|
{
|
190
|
-
// TODO: Actually, we don't have to worry about anything pushed
|
191
|
-
// using glPushAttribs because beginGL/endGL will take care of that.
|
192
|
-
|
193
194
|
applyTexture();
|
194
195
|
applyTransform();
|
195
196
|
applyClipRect();
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#include <Gosu/Gosu.hpp>
|
2
|
+
|
3
|
+
#ifdef GOSU_IS_WIN
|
4
|
+
#include <windows.h>
|
5
|
+
// Note: This does not use the SDL2 variant below, which reports 2560x1920 in my Windows VM, which is running at 2560x1080. Last checked with SDL 2.0.3.
|
6
|
+
// TODO: Try this on a real Windows machine.
|
7
|
+
|
8
|
+
unsigned Gosu::screenWidth()
|
9
|
+
{
|
10
|
+
return GetSystemMetrics(SM_CXSCREEN);
|
11
|
+
}
|
12
|
+
|
13
|
+
unsigned Gosu::screenHeight()
|
14
|
+
{
|
15
|
+
return GetSystemMetrics(SM_CYSCREEN);
|
16
|
+
}
|
17
|
+
|
18
|
+
// Note: It is okay for this couple of functions to be OS-specific.
|
19
|
+
namespace
|
20
|
+
{
|
21
|
+
SIZE calculateAvailableSize()
|
22
|
+
{
|
23
|
+
RECT workArea;
|
24
|
+
SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
25
|
+
|
26
|
+
RECT windowSize = workArea;
|
27
|
+
// Note: This should be kept in sync with STYLE_NORMAL in SDL_windowswindow.c.
|
28
|
+
DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
29
|
+
AdjustWindowRectEx(&windowSize, style, FALSE, 0);
|
30
|
+
|
31
|
+
SIZE availableSize;
|
32
|
+
availableSize.cx = 2 * (workArea.right - workArea.left) - (windowSize.right - windowSize.left);
|
33
|
+
availableSize.cy = 2 * (workArea.bottom - workArea.top) - (windowSize.bottom - windowSize.top);
|
34
|
+
return availableSize;
|
35
|
+
}
|
36
|
+
|
37
|
+
SIZE availableSize = calculateAvailableSize();
|
38
|
+
}
|
39
|
+
|
40
|
+
unsigned Gosu::availableWidth()
|
41
|
+
{
|
42
|
+
return availableSize.cx;
|
43
|
+
}
|
44
|
+
|
45
|
+
unsigned Gosu::availableHeight()
|
46
|
+
{
|
47
|
+
return availableSize.cy;
|
48
|
+
}
|
49
|
+
#else
|
50
|
+
#include <SDL2/SDL.h>
|
51
|
+
|
52
|
+
namespace
|
53
|
+
{
|
54
|
+
SDL_DisplayMode currentDisplayMode = { 0, 0 };
|
55
|
+
}
|
56
|
+
|
57
|
+
unsigned Gosu::screenWidth()
|
58
|
+
{
|
59
|
+
// TODO - not thread-safe
|
60
|
+
if (currentDisplayMode.w == 0) {
|
61
|
+
SDL_Init(SDL_INIT_VIDEO);
|
62
|
+
SDL_GetDisplayMode(0, 0, ¤tDisplayMode);
|
63
|
+
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
64
|
+
}
|
65
|
+
return currentDisplayMode.w;
|
66
|
+
}
|
67
|
+
|
68
|
+
unsigned Gosu::screenHeight()
|
69
|
+
{
|
70
|
+
// TODO - not thread-safe
|
71
|
+
if (currentDisplayMode.h == 0) {
|
72
|
+
SDL_Init(SDL_INIT_VIDEO);
|
73
|
+
SDL_GetDisplayMode(0, 0, ¤tDisplayMode);
|
74
|
+
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
75
|
+
}
|
76
|
+
return currentDisplayMode.h;
|
77
|
+
}
|
78
|
+
|
79
|
+
// Pessimistic fallback implementation for availableWidth / availableHeight.
|
80
|
+
|
81
|
+
#if !defined(GOSU_IS_MAC)
|
82
|
+
unsigned Gosu::availableWidth()
|
83
|
+
{
|
84
|
+
return Gosu::screenWidth() * 0.9;
|
85
|
+
}
|
86
|
+
|
87
|
+
unsigned Gosu::availableHeight()
|
88
|
+
{
|
89
|
+
return Gosu::screenHeight() * 0.8;
|
90
|
+
}
|
91
|
+
#endif
|
92
|
+
#endif
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#include <Gosu/Gosu.hpp>
|
2
|
+
#import <AppKit/AppKit.h>
|
3
|
+
|
4
|
+
namespace Gosu
|
5
|
+
{
|
6
|
+
NSUInteger styleMaskFromSDL2 = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
|
7
|
+
NSRect availableFrame = [[[NSScreen screens] objectAtIndex:0] visibleFrame];
|
8
|
+
NSRect availableContentFrame = [NSWindow contentRectForFrameRect:availableFrame styleMask:styleMaskFromSDL2];
|
9
|
+
}
|
10
|
+
|
11
|
+
unsigned Gosu::availableWidth()
|
12
|
+
{
|
13
|
+
return availableContentFrame.size.width;
|
14
|
+
}
|
15
|
+
|
16
|
+
unsigned Gosu::availableHeight()
|
17
|
+
{
|
18
|
+
return availableContentFrame.size.height;
|
19
|
+
}
|
data/src/Inspection.cpp
CHANGED
@@ -5,12 +5,13 @@ namespace Gosu
|
|
5
5
|
{
|
6
6
|
namespace FPS
|
7
7
|
{
|
8
|
-
int fps, accum
|
8
|
+
int fps, accum;
|
9
|
+
unsigned long sec;
|
9
10
|
|
10
11
|
void registerFrame()
|
11
12
|
{
|
12
13
|
++accum;
|
13
|
-
|
14
|
+
unsigned long newSec = Gosu::milliseconds() / 1000;
|
14
15
|
if (sec != newSec)
|
15
16
|
{
|
16
17
|
sec = newSec;
|
@@ -123,7 +123,7 @@ namespace Gosu
|
|
123
123
|
len >= pos + 10 && html[pos + 9] == L'>')
|
124
124
|
{
|
125
125
|
using namespace std;
|
126
|
-
unsigned rgb = wcstoul(html + pos + 3, 0, 16);
|
126
|
+
unsigned rgb = static_cast<std::tr1::uint32_t>(wcstoul(html + pos + 3, 0, 16));
|
127
127
|
c.push_back(0xff000000 | rgb);
|
128
128
|
pos += 10;
|
129
129
|
continue;
|
@@ -132,7 +132,7 @@ namespace Gosu
|
|
132
132
|
len >= pos + 12 && html[pos + 11] == L'>')
|
133
133
|
{
|
134
134
|
using namespace std;
|
135
|
-
unsigned argb = wcstoul(html + pos + 3, 0, 16);
|
135
|
+
unsigned argb = static_cast<std::tr1::uint32_t>(wcstoul(html + pos + 3, 0, 16));
|
136
136
|
c.push_back(argb);
|
137
137
|
pos += 12;
|
138
138
|
continue;
|
@@ -241,15 +241,15 @@ namespace Gosu
|
|
241
241
|
return characters[index].color;
|
242
242
|
}
|
243
243
|
|
244
|
-
|
244
|
+
std::size_t length() const
|
245
245
|
{
|
246
|
-
if (
|
246
|
+
if (std::size_t len = characters.size())
|
247
247
|
return len;
|
248
248
|
else
|
249
249
|
return simpleString.length();
|
250
250
|
}
|
251
251
|
|
252
|
-
FormattedString range(
|
252
|
+
FormattedString range(std::size_t begin, std::size_t end) const
|
253
253
|
{
|
254
254
|
FormattedString result;
|
255
255
|
if (characters.empty())
|
data/src/Text/TextApple.mm
CHANGED
@@ -168,7 +168,7 @@ void Gosu::drawText(Bitmap& bitmap, const wstring& text, int x, int y,
|
|
168
168
|
CGSize size = [string.obj() sizeWithFont: font];
|
169
169
|
#endif
|
170
170
|
|
171
|
-
unsigned width = round(size.width / size.height * fontHeight);
|
171
|
+
unsigned width = static_cast<unsigned>(round(size.width / size.height * fontHeight));
|
172
172
|
|
173
173
|
// Get the width and height of the image
|
174
174
|
Bitmap bmp(width, fontHeight);
|
data/src/Window.cpp
CHANGED
@@ -12,30 +12,6 @@ namespace Gosu
|
|
12
12
|
{
|
13
13
|
void registerFrame();
|
14
14
|
}
|
15
|
-
|
16
|
-
SDL_DisplayMode currentDisplayMode = { 0, 0 };
|
17
|
-
}
|
18
|
-
|
19
|
-
unsigned Gosu::screenWidth()
|
20
|
-
{
|
21
|
-
// TODO - not thread-safe
|
22
|
-
if (currentDisplayMode.w == 0) {
|
23
|
-
SDL_Init(SDL_INIT_VIDEO);
|
24
|
-
SDL_GetDisplayMode(0, 0, ¤tDisplayMode);
|
25
|
-
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
26
|
-
}
|
27
|
-
return currentDisplayMode.w;
|
28
|
-
}
|
29
|
-
|
30
|
-
unsigned Gosu::screenHeight()
|
31
|
-
{
|
32
|
-
// TODO - not thread-safe
|
33
|
-
if (currentDisplayMode.h == 0) {
|
34
|
-
SDL_Init(SDL_INIT_VIDEO);
|
35
|
-
SDL_GetDisplayMode(0, 0, ¤tDisplayMode);
|
36
|
-
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
37
|
-
}
|
38
|
-
return currentDisplayMode.h;
|
39
15
|
}
|
40
16
|
|
41
17
|
struct Gosu::Window::Impl
|
@@ -78,8 +54,8 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double up
|
|
78
54
|
else {
|
79
55
|
// TODO - get platform-specific best width/height we could get
|
80
56
|
|
81
|
-
double maxWidth = Gosu::
|
82
|
-
double maxHeight = Gosu::
|
57
|
+
double maxWidth = Gosu::availableWidth();
|
58
|
+
double maxHeight = Gosu::availableHeight();
|
83
59
|
|
84
60
|
if (width > maxWidth || height > maxHeight) {
|
85
61
|
scaleFactor = std::min(maxWidth / width, maxHeight / height);
|
@@ -88,15 +64,17 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double up
|
|
88
64
|
}
|
89
65
|
}
|
90
66
|
|
67
|
+
Uint32 flags = SDL_WINDOW_OPENGL;
|
68
|
+
#if SDL_VERSION_ATLEAST(2, 0, 1)
|
69
|
+
flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
70
|
+
#endif
|
71
|
+
if (fullscreen) {
|
72
|
+
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
73
|
+
}
|
74
|
+
|
91
75
|
pimpl->window = SDL_CreateWindow("",
|
92
76
|
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
93
|
-
actualWidth, actualHeight,
|
94
|
-
SDL_WINDOW_OPENGL |
|
95
|
-
// Note: This flag is not available in all versions of SDL 2, e.g. SDL 2.0.0 on OpenSuSE 13.1.
|
96
|
-
#ifdef SDL_WINDOW_ALLOW_HIGHDPI
|
97
|
-
SDL_WINDOW_ALLOW_HIGHDPI |
|
98
|
-
#endif
|
99
|
-
(fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
|
77
|
+
actualWidth, actualHeight, flags);
|
100
78
|
|
101
79
|
#ifdef GOSU_IS_OPENGLES
|
102
80
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
|
@@ -174,19 +152,21 @@ void Gosu::Window::show()
|
|
174
152
|
|
175
153
|
SDL_ShowCursor(needsCursor());
|
176
154
|
|
177
|
-
if (
|
178
|
-
|
179
|
-
|
180
|
-
|
155
|
+
if (needsRedraw()) {
|
156
|
+
if (graphics().begin()) {
|
157
|
+
draw();
|
158
|
+
graphics().end();
|
159
|
+
FPS::registerFrame();
|
160
|
+
}
|
161
|
+
|
162
|
+
SDL_GL_SwapWindow(pimpl->window);
|
163
|
+
|
164
|
+
if (GosusDarkSide::oncePerTick) GosusDarkSide::oncePerTick();
|
181
165
|
}
|
182
|
-
|
183
|
-
SDL_GL_SwapWindow(pimpl->window);
|
184
|
-
|
185
|
-
if (GosusDarkSide::oncePerTick) GosusDarkSide::oncePerTick();
|
186
166
|
|
187
167
|
// Sleep to keep this loop from eating 100% CPU.
|
188
|
-
unsigned
|
189
|
-
if (frameTime
|
168
|
+
unsigned long frameTime = milliseconds() - startTime;
|
169
|
+
if (frameTime < pimpl->updateInterval) {
|
190
170
|
sleep(pimpl->updateInterval - frameTime);
|
191
171
|
}
|
192
172
|
}
|
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: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Raschke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
2D game development library.
|
@@ -118,6 +118,8 @@ files:
|
|
118
118
|
- src/Graphics/LargeImageData.hpp
|
119
119
|
- src/Graphics/Macro.hpp
|
120
120
|
- src/Graphics/RenderState.hpp
|
121
|
+
- src/Graphics/Resolution.cpp
|
122
|
+
- src/Graphics/ResolutionApple.mm
|
121
123
|
- src/Graphics/TexChunk.cpp
|
122
124
|
- src/Graphics/TexChunk.hpp
|
123
125
|
- src/Graphics/Texture.cpp
|