gosu 0.9.1 → 0.9.2.pre1
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/Input.hpp +1 -1
- data/Gosu/Version.hpp +2 -2
- data/ext/gosu/gosu_wrap.cxx +60 -21
- data/rdoc/gosu.rb +6 -7
- data/src/Input/Input.cpp +29 -11
- data/src/TimingWin.cpp +3 -21
- data/src/Window.cpp +16 -6
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a1c34fd00bf80dda03420c2469ba363f09790e5
|
|
4
|
+
data.tar.gz: eb1a0080a88b5aae6a77731cf7f9b0d5a7ddc221
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7ebb942e9dd669d8cfb8efd51a1f1e796b042067b88beee7d62a3997c550d1fe0794afd1c82026a5d1ce4a71970b5c67611fd1e24a062dd7b1cc8e451745af3
|
|
7
|
+
data.tar.gz: d227fec88ceb822dcd120923e338e49cee87897b0be3e21eeefa1d0355c050bb4c0ec53ef8867394b2c2e30535ff6a332ea1fc2fdca1b221660b527fd40de3c9
|
data/Gosu/Input.hpp
CHANGED
data/Gosu/Version.hpp
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
#define GOSU_MAJOR_VERSION 0
|
|
5
5
|
#define GOSU_MINOR_VERSION 9
|
|
6
|
-
#define GOSU_POINT_VERSION
|
|
7
|
-
#define GOSU_VERSION "0.9.
|
|
6
|
+
#define GOSU_POINT_VERSION 2
|
|
7
|
+
#define GOSU_VERSION "0.9.2.pre1"
|
|
8
8
|
|
|
9
9
|
#define GOSU_COPYRIGHT_NOTICE \
|
|
10
10
|
"This software uses the following third-party libraries:\n" \
|
data/ext/gosu/gosu_wrap.cxx
CHANGED
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
* interface file instead.
|
|
9
9
|
* ----------------------------------------------------------------------------- */
|
|
10
10
|
|
|
11
|
-
// This file was afterwards patched using the following instructions:
|
|
12
|
-
// http://sourceforge.net/tracker/index.php?func=detail&aid=2034216&group_id=1645&atid=101645
|
|
13
|
-
// (Many thanks to Kevin Burge for that.)
|
|
14
|
-
|
|
15
11
|
#define SWIGRUBY
|
|
16
12
|
#define SWIG_DIRECTORS
|
|
17
13
|
|
|
@@ -848,7 +844,6 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
|
|
|
848
844
|
|
|
849
845
|
|
|
850
846
|
#include <ruby.h>
|
|
851
|
-
#include <map>
|
|
852
847
|
|
|
853
848
|
/* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
|
|
854
849
|
* breaks using rb_intern as an lvalue, as SWIG does. We work around this
|
|
@@ -1189,7 +1184,7 @@ extern "C" {
|
|
|
1189
1184
|
/* Global Ruby hash table to store Trackings from C/C++
|
|
1190
1185
|
structs to Ruby Objects.
|
|
1191
1186
|
*/
|
|
1192
|
-
static
|
|
1187
|
+
static VALUE swig_ruby_trackings = Qnil;
|
|
1193
1188
|
|
|
1194
1189
|
/* Global variable that stores a reference to the ruby
|
|
1195
1190
|
hash table delete function. */
|
|
@@ -1206,18 +1201,34 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
|
|
|
1206
1201
|
This is done to allow multiple DSOs to share the same
|
|
1207
1202
|
tracking table.
|
|
1208
1203
|
*/
|
|
1204
|
+
ID trackings_id = rb_intern( "@__trackings__" );
|
|
1209
1205
|
VALUE verbose = rb_gv_get("VERBOSE");
|
|
1210
1206
|
rb_gv_set("VERBOSE", Qfalse);
|
|
1207
|
+
swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
|
|
1211
1208
|
rb_gv_set("VERBOSE", verbose);
|
|
1212
1209
|
|
|
1213
1210
|
/* No, it hasn't. Create one ourselves */
|
|
1214
|
-
swig_ruby_trackings
|
|
1211
|
+
if ( swig_ruby_trackings == Qnil )
|
|
1212
|
+
{
|
|
1213
|
+
swig_ruby_trackings = rb_hash_new();
|
|
1214
|
+
rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
|
|
1215
|
+
}
|
|
1215
1216
|
|
|
1216
1217
|
/* Now store a reference to the hash table delete function
|
|
1217
1218
|
so that we only have to look it up once.*/
|
|
1218
1219
|
swig_ruby_hash_delete = rb_intern("delete");
|
|
1219
1220
|
}
|
|
1220
1221
|
|
|
1222
|
+
/* Get a Ruby number to reference a pointer */
|
|
1223
|
+
SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
|
|
1224
|
+
/* We cast the pointer to an unsigned long
|
|
1225
|
+
and then store a reference to it using
|
|
1226
|
+
a Ruby number object. */
|
|
1227
|
+
|
|
1228
|
+
/* Convert the pointer to a Ruby number */
|
|
1229
|
+
return SWIG2NUM(ptr);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1221
1232
|
/* Get a Ruby number to reference an object */
|
|
1222
1233
|
SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
|
|
1223
1234
|
/* We cast the object to an unsigned long
|
|
@@ -1239,16 +1250,39 @@ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
|
|
|
1239
1250
|
|
|
1240
1251
|
/* Add a Tracking from a C/C++ struct to a Ruby object */
|
|
1241
1252
|
SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
|
|
1253
|
+
/* In a Ruby hash table we store the pointer and
|
|
1254
|
+
the associated Ruby object. The trick here is
|
|
1255
|
+
that we cannot store the Ruby object directly - if
|
|
1256
|
+
we do then it cannot be garbage collected. So
|
|
1257
|
+
instead we typecast it as a unsigned long and
|
|
1258
|
+
convert it to a Ruby number object.*/
|
|
1259
|
+
|
|
1260
|
+
/* Get a reference to the pointer as a Ruby number */
|
|
1261
|
+
VALUE key = SWIG_RubyPtrToReference(ptr);
|
|
1262
|
+
|
|
1263
|
+
/* Get a reference to the Ruby object as a Ruby number */
|
|
1264
|
+
VALUE value = SWIG_RubyObjectToReference(object);
|
|
1265
|
+
|
|
1242
1266
|
/* Store the mapping to the global hash table. */
|
|
1243
|
-
swig_ruby_trackings
|
|
1267
|
+
rb_hash_aset(swig_ruby_trackings, key, value);
|
|
1244
1268
|
}
|
|
1245
1269
|
|
|
1246
1270
|
/* Get the Ruby object that owns the specified C/C++ struct */
|
|
1247
1271
|
SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
|
|
1248
|
-
|
|
1272
|
+
/* Get a reference to the pointer as a Ruby number */
|
|
1273
|
+
VALUE key = SWIG_RubyPtrToReference(ptr);
|
|
1274
|
+
|
|
1275
|
+
/* Now lookup the value stored in the global hash table */
|
|
1276
|
+
VALUE value = rb_hash_aref(swig_ruby_trackings, key);
|
|
1277
|
+
|
|
1278
|
+
if (value == Qnil) {
|
|
1279
|
+
/* No object exists - return nil. */
|
|
1249
1280
|
return Qnil;
|
|
1250
|
-
|
|
1251
|
-
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
/* Convert this value to Ruby object */
|
|
1284
|
+
return SWIG_RubyReferenceToObject(value);
|
|
1285
|
+
}
|
|
1252
1286
|
}
|
|
1253
1287
|
|
|
1254
1288
|
/* Remove a Tracking from a C/C++ struct to a Ruby object. It
|
|
@@ -1256,7 +1290,12 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
|
|
|
1256
1290
|
since the same memory address may be reused later to create
|
|
1257
1291
|
a new object. */
|
|
1258
1292
|
SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
|
|
1259
|
-
|
|
1293
|
+
/* Get a reference to the pointer as a Ruby number */
|
|
1294
|
+
VALUE key = SWIG_RubyPtrToReference(ptr);
|
|
1295
|
+
|
|
1296
|
+
/* Delete the object from the hash table by calling Ruby's
|
|
1297
|
+
do this we need to call the Hash.delete method.*/
|
|
1298
|
+
rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
|
|
1260
1299
|
}
|
|
1261
1300
|
|
|
1262
1301
|
/* This is a helper method that unlinks a Ruby object from its
|
|
@@ -3062,14 +3101,14 @@ SwigDirector_Window::~SwigDirector_Window() {
|
|
|
3062
3101
|
void SwigDirector_Window::update() {
|
|
3063
3102
|
VALUE result;
|
|
3064
3103
|
|
|
3065
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
|
3104
|
+
result = rb_funcall(swig_get_self(), rb_intern("update"), 0, NULL);
|
|
3066
3105
|
}
|
|
3067
3106
|
|
|
3068
3107
|
|
|
3069
3108
|
void SwigDirector_Window::draw() {
|
|
3070
3109
|
VALUE result;
|
|
3071
3110
|
|
|
3072
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
|
3111
|
+
result = rb_funcall(swig_get_self(), rb_intern("draw"), 0, NULL);
|
|
3073
3112
|
}
|
|
3074
3113
|
|
|
3075
3114
|
|
|
@@ -3077,7 +3116,7 @@ bool SwigDirector_Window::needsRedraw() const {
|
|
|
3077
3116
|
bool c_result ;
|
|
3078
3117
|
VALUE result;
|
|
3079
3118
|
|
|
3080
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
|
3119
|
+
result = rb_funcall(swig_get_self(), rb_intern("needs_redraw?"), 0, NULL);
|
|
3081
3120
|
bool swig_val;
|
|
3082
3121
|
int swig_res = SWIG_AsVal_bool(result, &swig_val);
|
|
3083
3122
|
if (!SWIG_IsOK(swig_res)) {
|
|
@@ -3092,7 +3131,7 @@ bool SwigDirector_Window::needsCursor() const {
|
|
|
3092
3131
|
bool c_result ;
|
|
3093
3132
|
VALUE result;
|
|
3094
3133
|
|
|
3095
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
|
3134
|
+
result = rb_funcall(swig_get_self(), rb_intern("needs_cursor?"), 0, NULL);
|
|
3096
3135
|
bool swig_val;
|
|
3097
3136
|
int swig_res = SWIG_AsVal_bool(result, &swig_val);
|
|
3098
3137
|
if (!SWIG_IsOK(swig_res)) {
|
|
@@ -3106,7 +3145,7 @@ bool SwigDirector_Window::needsCursor() const {
|
|
|
3106
3145
|
void SwigDirector_Window::loseFocus() {
|
|
3107
3146
|
VALUE result;
|
|
3108
3147
|
|
|
3109
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
|
3148
|
+
result = rb_funcall(swig_get_self(), rb_intern("lose_focus"), 0, NULL);
|
|
3110
3149
|
}
|
|
3111
3150
|
|
|
3112
3151
|
|
|
@@ -3127,7 +3166,7 @@ void SwigDirector_Window::buttonDown(Gosu::Button arg0) {
|
|
|
3127
3166
|
else
|
|
3128
3167
|
obj0 = LONG2NUM((&arg0)->id());
|
|
3129
3168
|
}
|
|
3130
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
|
3169
|
+
result = rb_funcall(swig_get_self(), rb_intern("button_down"), 1,obj0);
|
|
3131
3170
|
}
|
|
3132
3171
|
|
|
3133
3172
|
|
|
@@ -3141,7 +3180,7 @@ void SwigDirector_Window::buttonUp(Gosu::Button arg0) {
|
|
|
3141
3180
|
else
|
|
3142
3181
|
obj0 = LONG2NUM((&arg0)->id());
|
|
3143
3182
|
}
|
|
3144
|
-
result = rb_funcall(swig_get_self(), rb_intern("
|
|
3183
|
+
result = rb_funcall(swig_get_self(), rb_intern("button_up"), 1,obj0);
|
|
3145
3184
|
}
|
|
3146
3185
|
|
|
3147
3186
|
|
|
@@ -11095,8 +11134,8 @@ SWIGEXPORT void Init_gosu(void) {
|
|
|
11095
11134
|
SWIG_RubyInitializeTrackings();
|
|
11096
11135
|
rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
|
|
11097
11136
|
rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(9)));
|
|
11098
|
-
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(
|
|
11099
|
-
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.9.
|
|
11137
|
+
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(2)));
|
|
11138
|
+
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.9.2.pre1"));
|
|
11100
11139
|
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"));
|
|
11101
11140
|
rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
|
|
11102
11141
|
rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
|
data/rdoc/gosu.rb
CHANGED
|
@@ -676,28 +676,27 @@ module Gosu
|
|
|
676
676
|
# Gosu application. Manages initialization of all of Gosu's core components
|
|
677
677
|
# and provides timing functionality.
|
|
678
678
|
#
|
|
679
|
-
# Note that all coordinates, even the mouse position, are in client
|
|
680
|
-
#
|
|
681
|
-
# can be negative or larger than the window size.
|
|
679
|
+
# Note that all coordinates, even the mouse position, are in client coordinates, relative to the window’s top left corner.
|
|
680
|
+
# This means that the mouse position can be negative or larger than the window size.
|
|
682
681
|
#
|
|
683
|
-
# @note There should really only be one instance of this class at a time. This may or may not change later
|
|
682
|
+
# @note There should really only be one instance of this class at a time. This may or may not change later.
|
|
684
683
|
class Window
|
|
685
684
|
##
|
|
686
685
|
# @return [String] the window's caption, usually dispalyed in the title bar.
|
|
687
686
|
attr_accessor :caption
|
|
688
687
|
|
|
689
688
|
##
|
|
690
|
-
# @return [
|
|
689
|
+
# @return [Float] the mouse pointer's window-based X coordinate.
|
|
691
690
|
attr_accessor :mouse_x
|
|
692
691
|
|
|
693
692
|
##
|
|
694
|
-
# @return [
|
|
693
|
+
# @return [Float] the mouse pointer's window-based Y coordinate.
|
|
695
694
|
attr_accessor :mouse_y
|
|
696
695
|
|
|
697
696
|
##
|
|
698
697
|
# The currently active {TextInput}. If not nil, all keyboard input will be handled by this object.
|
|
699
698
|
#
|
|
700
|
-
# @return [TextInput?] the currently active text input.
|
|
699
|
+
# @return [TextInput?] the currently active text input, if any.
|
|
701
700
|
attr_accessor :text_input
|
|
702
701
|
|
|
703
702
|
##
|
data/src/Input/Input.cpp
CHANGED
|
@@ -9,30 +9,38 @@
|
|
|
9
9
|
|
|
10
10
|
namespace
|
|
11
11
|
{
|
|
12
|
+
void cleanup();
|
|
13
|
+
|
|
12
14
|
void requireSDLVideo()
|
|
13
15
|
{
|
|
14
|
-
static bool
|
|
15
|
-
if (!
|
|
16
|
+
static bool initialized = false;
|
|
17
|
+
if (!initialized)
|
|
16
18
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
20
|
+
initialized = true;
|
|
21
|
+
std::atexit(cleanup);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
void cleanup()
|
|
26
|
+
{
|
|
27
|
+
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
std::tr1::array<bool, Gosu::numButtons> buttonStates = { { false } };
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
struct Gosu::Input::Impl
|
|
27
34
|
{
|
|
28
35
|
Input& input;
|
|
36
|
+
SDL_Window* window;
|
|
29
37
|
TextInput* textInput;
|
|
30
38
|
double mouseX, mouseY;
|
|
31
39
|
double mouseFactorX, mouseFactorY;
|
|
32
40
|
double mouseOffsetX, mouseOffsetY;
|
|
33
41
|
|
|
34
|
-
Impl(Input& input)
|
|
35
|
-
: input(input), textInput(NULL)
|
|
42
|
+
Impl(Input& input, SDL_Window* window)
|
|
43
|
+
: input(input), window(window), textInput(NULL)
|
|
36
44
|
{
|
|
37
45
|
mouseFactorX = mouseFactorY = 1;
|
|
38
46
|
mouseOffsetX = mouseOffsetY = 0;
|
|
@@ -40,9 +48,16 @@ struct Gosu::Input::Impl
|
|
|
40
48
|
|
|
41
49
|
void updateMousePosition()
|
|
42
50
|
{
|
|
51
|
+
#if SDL_VERSION_ATLEAST(2, 0, 4)
|
|
52
|
+
int x, y, windowX, windowY;
|
|
53
|
+
SDL_GetWindowPosition(window, &windowX, &windowY);
|
|
54
|
+
SDL_GetGlobalMouseState(&x, &y);
|
|
55
|
+
mouseX = x - windowX, mouseY = y - windowY;
|
|
56
|
+
#else
|
|
43
57
|
int x, y;
|
|
44
58
|
SDL_GetMouseState(&x, &y);
|
|
45
59
|
mouseX = x, mouseY = y;
|
|
60
|
+
#endif
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
void enqueueEvent(int id, bool down)
|
|
@@ -70,6 +85,8 @@ struct Gosu::Input::Impl
|
|
|
70
85
|
|
|
71
86
|
void initializeGamepads()
|
|
72
87
|
{
|
|
88
|
+
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
|
89
|
+
|
|
73
90
|
int numGamepads = std::min<int>(Gosu::numGamepads, SDL_NumJoysticks());
|
|
74
91
|
|
|
75
92
|
for (int i = 0; i < numGamepads; ++i) {
|
|
@@ -95,6 +112,8 @@ struct Gosu::Input::Impl
|
|
|
95
112
|
joysticks.clear();
|
|
96
113
|
std::for_each(gameControllers.begin(), gameControllers.end(), &SDL_GameControllerClose);
|
|
97
114
|
gameControllers.clear();
|
|
115
|
+
|
|
116
|
+
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
|
98
117
|
}
|
|
99
118
|
|
|
100
119
|
typedef std::tr1::array<bool, gpNumPerGamepad> GamepadBuffer;
|
|
@@ -236,8 +255,8 @@ private:
|
|
|
236
255
|
}
|
|
237
256
|
};
|
|
238
257
|
|
|
239
|
-
Gosu::Input::Input()
|
|
240
|
-
: pimpl(new Impl(*this))
|
|
258
|
+
Gosu::Input::Input(void* window)
|
|
259
|
+
: pimpl(new Impl(*this, (SDL_Window*)window))
|
|
241
260
|
{
|
|
242
261
|
requireSDLVideo();
|
|
243
262
|
|
|
@@ -359,8 +378,7 @@ double Gosu::Input::mouseY() const
|
|
|
359
378
|
|
|
360
379
|
void Gosu::Input::setMousePosition(double x, double y)
|
|
361
380
|
{
|
|
362
|
-
|
|
363
|
-
SDL_WarpMouseInWindow(NULL,
|
|
381
|
+
SDL_WarpMouseInWindow(pimpl->window,
|
|
364
382
|
(x - pimpl->mouseOffsetX) / pimpl->mouseFactorX,
|
|
365
383
|
(y - pimpl->mouseOffsetY) / pimpl->mouseFactorY);
|
|
366
384
|
}
|
data/src/TimingWin.cpp
CHANGED
|
@@ -4,29 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
void Gosu::sleep(unsigned milliseconds)
|
|
6
6
|
{
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
namespace
|
|
11
|
-
{
|
|
12
|
-
void resetTGT()
|
|
13
|
-
{
|
|
14
|
-
::timeEndPeriod(1);
|
|
15
|
-
}
|
|
7
|
+
Sleep(milliseconds);
|
|
16
8
|
}
|
|
17
9
|
|
|
18
10
|
unsigned long Gosu::milliseconds()
|
|
19
11
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!start)
|
|
23
|
-
{
|
|
24
|
-
if (::timeBeginPeriod(1) != TIMERR_NOERROR)
|
|
25
|
-
std::atexit(resetTGT);
|
|
26
|
-
start = ::timeGetTime();
|
|
27
|
-
}
|
|
28
|
-
// Truncate to 2^30, C++ users shouldn't mind and Ruby users will
|
|
29
|
-
// have a happy GC on 32-bit systems.
|
|
30
|
-
// No, don't ask why this is an unsigned long then :)
|
|
31
|
-
return (::timeGetTime() - start) & 0x1fffffff;
|
|
12
|
+
static unsigned long start = (timeBeginPeriod(1), timeGetTime());
|
|
13
|
+
return timeGetTime() - start;
|
|
32
14
|
}
|
data/src/Window.cpp
CHANGED
|
@@ -19,7 +19,9 @@ namespace Gosu
|
|
|
19
19
|
const char *error = SDL_GetError();
|
|
20
20
|
throw std::runtime_error(operation + ": " + (error ? error : "(unknown error)"));
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
void cleanup();
|
|
24
|
+
|
|
23
25
|
SDL_Window* sharedWindow()
|
|
24
26
|
{
|
|
25
27
|
static SDL_Window *window = 0;
|
|
@@ -27,9 +29,9 @@ namespace Gosu
|
|
|
27
29
|
{
|
|
28
30
|
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
|
29
31
|
throwSDLError("Could not initialize SDL Video");
|
|
30
|
-
|
|
31
|
-
atexit(
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
std::atexit(cleanup);
|
|
34
|
+
|
|
33
35
|
Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN;
|
|
34
36
|
|
|
35
37
|
#if SDL_VERSION_ATLEAST(2, 0, 1)
|
|
@@ -65,6 +67,13 @@ namespace Gosu
|
|
|
65
67
|
{
|
|
66
68
|
SDL_GL_MakeCurrent(sharedWindow(), sharedGLContext());
|
|
67
69
|
}
|
|
70
|
+
|
|
71
|
+
void cleanup()
|
|
72
|
+
{
|
|
73
|
+
SDL_GL_DeleteContext(sharedGLContext());
|
|
74
|
+
SDL_DestroyWindow(sharedWindow());
|
|
75
|
+
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
76
|
+
}
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
struct Gosu::Window::Impl
|
|
@@ -78,7 +87,6 @@ struct Gosu::Window::Impl
|
|
|
78
87
|
Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double updateInterval)
|
|
79
88
|
: pimpl(new Impl)
|
|
80
89
|
{
|
|
81
|
-
|
|
82
90
|
int actualWidth = width;
|
|
83
91
|
int actualHeight = height;
|
|
84
92
|
double scaleFactor = 1.0;
|
|
@@ -131,7 +139,7 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double up
|
|
|
131
139
|
|
|
132
140
|
pimpl->graphics.reset(new Graphics(actualWidth, actualHeight, fullscreen));
|
|
133
141
|
pimpl->graphics->setResolution(width, height, blackBarWidth, blackBarHeight);
|
|
134
|
-
pimpl->input.reset(new Input());
|
|
142
|
+
pimpl->input.reset(new Input(sharedWindow()));
|
|
135
143
|
pimpl->input->setMouseFactors(1 / scaleFactor, 1 / scaleFactor, blackBarWidth, blackBarHeight);
|
|
136
144
|
input().onButtonDown = std::tr1::bind(&Window::buttonDown, this, _1);
|
|
137
145
|
input().onButtonUp = std::tr1::bind(&Window::buttonUp, this, _1);
|
|
@@ -208,6 +216,8 @@ void Gosu::Window::show()
|
|
|
208
216
|
sleep(pimpl->updateInterval - frameTime);
|
|
209
217
|
}
|
|
210
218
|
}
|
|
219
|
+
|
|
220
|
+
SDL_HideWindow(sharedWindow());
|
|
211
221
|
}
|
|
212
222
|
|
|
213
223
|
void Gosu::Window::close()
|
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.9.
|
|
4
|
+
version: 0.9.2.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: 2015-05-
|
|
11
|
+
date: 2015-05-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |2
|
|
14
14
|
2D game development library.
|
|
@@ -162,9 +162,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
162
162
|
version: 1.8.2
|
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
requirements:
|
|
165
|
-
- - '
|
|
165
|
+
- - '>'
|
|
166
166
|
- !ruby/object:Gem::Version
|
|
167
|
-
version:
|
|
167
|
+
version: 1.3.1
|
|
168
168
|
requirements: []
|
|
169
169
|
rubyforge_project:
|
|
170
170
|
rubygems_version: 2.0.14
|