gosu 0.10.1.2 → 0.10.2.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fb3a09de604515fbe77c22ef529000d209a944f
4
- data.tar.gz: e9f3ecbcfa5a2feadc9bbc94b90040e28327b58d
3
+ metadata.gz: ecfdbb08ed4f62285efa92a4e6531cd11adae83f
4
+ data.tar.gz: 8c7633022fb1c04feacd970b3aa347c3e2130eb5
5
5
  SHA512:
6
- metadata.gz: b01c0d3a59982e155d032ddd09bb9ce3582072f1cb4a208a3fa2b769a4c55e634f02f57217d139f171932a03a3968d71abba37389e73864b62ed46a7dc80801f
7
- data.tar.gz: e2bbd8efe6e877c7d94e6db147a015c9de154a1337ad706a0e6f6a0c00347c682452f44e05fbc5fc2ac91b01e65d0ced4416ee927b02d3f81cedc5180d18f749
6
+ metadata.gz: 2c13a96ad5c4e0b58ff964208c7a7cd12ee92bb93a4cdb214641ab93877bbfec080c0923364ef115cab7335eb718655d00c5c4210d59b65d6762926bd161bba8
7
+ data.tar.gz: c24c6d0429534be9927d1a1bbbd39031bb18b0d23914dd3af8e702571b20746ff57ba416dd2fd644a22d117e8efb481ce4f8d9a8cc45db24c059fa7c93e6074c
@@ -3,8 +3,8 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 10
6
- #define GOSU_POINT_VERSION 1
7
- #define GOSU_VERSION "0.10.1"
6
+ #define GOSU_POINT_VERSION 2
7
+ #define GOSU_VERSION "0.10.2.pre1"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  "This software uses the following third-party libraries:\n" \
@@ -65,10 +65,20 @@ namespace Gosu
65
65
  void setCaption(const std::wstring& caption);
66
66
 
67
67
  double updateInterval() const;
68
-
68
+
69
69
  //! Enters a modal loop where the Window is visible on screen and
70
70
  //! receives calls to draw, update etc.
71
- void show();
71
+ virtual void show();
72
+
73
+ //! Performs a single mainloop step.
74
+ //! This method is only useful if you want to integrate Gosu with
75
+ //! another library that has its own main loop.
76
+ //! This method implicitly shows the window if it was hidden before, and
77
+ //! returns false when the window has been closed.
78
+ //! If you discard the return value and keep calling tick(), the window will be shown again,
79
+ //! or keep being shown.
80
+ virtual bool tick();
81
+
72
82
  //! Closes the window if it is currently shown.
73
83
  void close();
74
84
 
@@ -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
 
@@ -874,7 +870,6 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
874
870
 
875
871
 
876
872
  #include <ruby.h>
877
- #include <map>
878
873
 
879
874
  /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
880
875
  * breaks using rb_intern as an lvalue, as SWIG does. We work around this
@@ -1215,7 +1210,7 @@ extern "C" {
1215
1210
  /* Global Ruby hash table to store Trackings from C/C++
1216
1211
  structs to Ruby Objects.
1217
1212
  */
1218
- static std::map<void*, VALUE> swig_ruby_trackings;
1213
+ static VALUE swig_ruby_trackings = Qnil;
1219
1214
 
1220
1215
  /* Global variable that stores a reference to the ruby
1221
1216
  hash table delete function. */
@@ -1232,18 +1227,34 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1232
1227
  This is done to allow multiple DSOs to share the same
1233
1228
  tracking table.
1234
1229
  */
1230
+ ID trackings_id = rb_intern( "@__trackings__" );
1235
1231
  VALUE verbose = rb_gv_get("VERBOSE");
1236
1232
  rb_gv_set("VERBOSE", Qfalse);
1233
+ swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
1237
1234
  rb_gv_set("VERBOSE", verbose);
1238
1235
 
1239
1236
  /* No, it hasn't. Create one ourselves */
1240
- swig_ruby_trackings.clear();
1237
+ if ( swig_ruby_trackings == Qnil )
1238
+ {
1239
+ swig_ruby_trackings = rb_hash_new();
1240
+ rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
1241
+ }
1241
1242
 
1242
1243
  /* Now store a reference to the hash table delete function
1243
1244
  so that we only have to look it up once.*/
1244
1245
  swig_ruby_hash_delete = rb_intern("delete");
1245
1246
  }
1246
1247
 
1248
+ /* Get a Ruby number to reference a pointer */
1249
+ SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
1250
+ /* We cast the pointer to an unsigned long
1251
+ and then store a reference to it using
1252
+ a Ruby number object. */
1253
+
1254
+ /* Convert the pointer to a Ruby number */
1255
+ return SWIG2NUM(ptr);
1256
+ }
1257
+
1247
1258
  /* Get a Ruby number to reference an object */
1248
1259
  SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
1249
1260
  /* We cast the object to an unsigned long
@@ -1265,16 +1276,39 @@ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
1265
1276
 
1266
1277
  /* Add a Tracking from a C/C++ struct to a Ruby object */
1267
1278
  SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1279
+ /* In a Ruby hash table we store the pointer and
1280
+ the associated Ruby object. The trick here is
1281
+ that we cannot store the Ruby object directly - if
1282
+ we do then it cannot be garbage collected. So
1283
+ instead we typecast it as a unsigned long and
1284
+ convert it to a Ruby number object.*/
1285
+
1286
+ /* Get a reference to the pointer as a Ruby number */
1287
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1288
+
1289
+ /* Get a reference to the Ruby object as a Ruby number */
1290
+ VALUE value = SWIG_RubyObjectToReference(object);
1291
+
1268
1292
  /* Store the mapping to the global hash table. */
1269
- swig_ruby_trackings[ptr] = object;
1293
+ rb_hash_aset(swig_ruby_trackings, key, value);
1270
1294
  }
1271
1295
 
1272
1296
  /* Get the Ruby object that owns the specified C/C++ struct */
1273
1297
  SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1274
- if (swig_ruby_trackings.count(ptr) == 0)
1298
+ /* Get a reference to the pointer as a Ruby number */
1299
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1300
+
1301
+ /* Now lookup the value stored in the global hash table */
1302
+ VALUE value = rb_hash_aref(swig_ruby_trackings, key);
1303
+
1304
+ if (value == Qnil) {
1305
+ /* No object exists - return nil. */
1275
1306
  return Qnil;
1276
- else
1277
- return swig_ruby_trackings[ptr];
1307
+ }
1308
+ else {
1309
+ /* Convert this value to Ruby object */
1310
+ return SWIG_RubyReferenceToObject(value);
1311
+ }
1278
1312
  }
1279
1313
 
1280
1314
  /* Remove a Tracking from a C/C++ struct to a Ruby object. It
@@ -1282,7 +1316,12 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1282
1316
  since the same memory address may be reused later to create
1283
1317
  a new object. */
1284
1318
  SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1285
- swig_ruby_trackings.erase(ptr);
1319
+ /* Get a reference to the pointer as a Ruby number */
1320
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1321
+
1322
+ /* Delete the object from the hash table by calling Ruby's
1323
+ do this we need to call the Hash.delete method.*/
1324
+ rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
1286
1325
  }
1287
1326
 
1288
1327
  /* This is a helper method that unlinks a Ruby object from its
@@ -2236,20 +2275,6 @@ namespace Gosu {
2236
2275
  #define RUBY_18_19(r18, r19) r18
2237
2276
  #endif
2238
2277
 
2239
- namespace GosusDarkSide
2240
- {
2241
- // TODO: Find a way for this to fit into Gosu's design.
2242
- // This can point to a function that wants to be called every
2243
- // frame, e.g. rb_thread_schedule.
2244
- typedef void (*HookOfHorror)();
2245
- extern HookOfHorror oncePerTick;
2246
-
2247
- void yieldToOtherRubyThreads()
2248
- {
2249
- rb_thread_schedule();
2250
- }
2251
- }
2252
-
2253
2278
  namespace
2254
2279
  {
2255
2280
  void callRubyBlock(VALUE block) {
@@ -3069,17 +3094,39 @@ SwigDirector_Window::SwigDirector_Window(VALUE self, unsigned int width, unsigne
3069
3094
  SwigDirector_Window::~SwigDirector_Window() {
3070
3095
  }
3071
3096
 
3097
+ void SwigDirector_Window::show() {
3098
+ VALUE result;
3099
+
3100
+ result = rb_funcall(swig_get_self(), rb_intern("show"), 0, NULL);
3101
+ }
3102
+
3103
+
3104
+ bool SwigDirector_Window::tick() {
3105
+ bool c_result ;
3106
+ VALUE result;
3107
+
3108
+ result = rb_funcall(swig_get_self(), rb_intern("tick"), 0, NULL);
3109
+ bool swig_val;
3110
+ int swig_res = SWIG_AsVal_bool(result, &swig_val);
3111
+ if (!SWIG_IsOK(swig_res)) {
3112
+ Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(SWIG_ArgError(swig_res)), "in output value of type '""bool""'");
3113
+ }
3114
+ c_result = static_cast< bool >(swig_val);
3115
+ return (bool) c_result;
3116
+ }
3117
+
3118
+
3072
3119
  void SwigDirector_Window::update() {
3073
3120
  VALUE result;
3074
3121
 
3075
- result = rb_funcall(swig_get_self(), rb_intern("protected_update"), 0, NULL);
3122
+ result = rb_funcall(swig_get_self(), rb_intern("update"), 0, NULL);
3076
3123
  }
3077
3124
 
3078
3125
 
3079
3126
  void SwigDirector_Window::draw() {
3080
3127
  VALUE result;
3081
3128
 
3082
- result = rb_funcall(swig_get_self(), rb_intern("protected_draw_2"), 0, NULL);
3129
+ result = rb_funcall(swig_get_self(), rb_intern("draw"), 0, NULL);
3083
3130
  }
3084
3131
 
3085
3132
 
@@ -3087,7 +3134,7 @@ bool SwigDirector_Window::needsRedraw() const {
3087
3134
  bool c_result ;
3088
3135
  VALUE result;
3089
3136
 
3090
- result = rb_funcall(swig_get_self(), rb_intern("protected_needs_redraw?"), 0, NULL);
3137
+ result = rb_funcall(swig_get_self(), rb_intern("needs_redraw?"), 0, NULL);
3091
3138
  bool swig_val;
3092
3139
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3093
3140
  if (!SWIG_IsOK(swig_res)) {
@@ -3102,7 +3149,7 @@ bool SwigDirector_Window::needsCursor() const {
3102
3149
  bool c_result ;
3103
3150
  VALUE result;
3104
3151
 
3105
- result = rb_funcall(swig_get_self(), rb_intern("protected_needs_cursor?"), 0, NULL);
3152
+ result = rb_funcall(swig_get_self(), rb_intern("needs_cursor?"), 0, NULL);
3106
3153
  bool swig_val;
3107
3154
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3108
3155
  if (!SWIG_IsOK(swig_res)) {
@@ -3116,7 +3163,7 @@ bool SwigDirector_Window::needsCursor() const {
3116
3163
  void SwigDirector_Window::loseFocus() {
3117
3164
  VALUE result;
3118
3165
 
3119
- result = rb_funcall(swig_get_self(), rb_intern("protected_lose_focus"), 0, NULL);
3166
+ result = rb_funcall(swig_get_self(), rb_intern("lose_focus"), 0, NULL);
3120
3167
  }
3121
3168
 
3122
3169
 
@@ -3137,7 +3184,7 @@ void SwigDirector_Window::buttonDown(Gosu::Button arg0) {
3137
3184
  else
3138
3185
  obj0 = LONG2NUM((&arg0)->id());
3139
3186
  }
3140
- result = rb_funcall(swig_get_self(), rb_intern("protected_button_down"), 1,obj0);
3187
+ result = rb_funcall(swig_get_self(), rb_intern("button_down"), 1,obj0);
3141
3188
  }
3142
3189
 
3143
3190
 
@@ -3151,7 +3198,7 @@ void SwigDirector_Window::buttonUp(Gosu::Button arg0) {
3151
3198
  else
3152
3199
  obj0 = LONG2NUM((&arg0)->id());
3153
3200
  }
3154
- result = rb_funcall(swig_get_self(), rb_intern("protected_button_up"), 1,obj0);
3201
+ result = rb_funcall(swig_get_self(), rb_intern("button_up"), 1,obj0);
3155
3202
  }
3156
3203
 
3157
3204
 
@@ -8813,6 +8860,8 @@ _wrap_Window_show(int argc, VALUE *argv, VALUE self) {
8813
8860
  Gosu::Window *arg1 = (Gosu::Window *) 0 ;
8814
8861
  void *argp1 = 0 ;
8815
8862
  int res1 = 0 ;
8863
+ Swig::Director *director = 0;
8864
+ bool upcall = false;
8816
8865
 
8817
8866
  if ((argc < 0) || (argc > 0)) {
8818
8867
  rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
@@ -8822,12 +8871,23 @@ _wrap_Window_show(int argc, VALUE *argv, VALUE self) {
8822
8871
  SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Window *","show", 1, self ));
8823
8872
  }
8824
8873
  arg1 = reinterpret_cast< Gosu::Window * >(argp1);
8825
- {
8826
- try {
8827
- (arg1)->show();
8828
- } catch (const std::exception& e) {
8829
- SWIG_exception(SWIG_RuntimeError, e.what());
8874
+ director = dynamic_cast<Swig::Director *>(arg1);
8875
+ upcall = (director && (director->swig_get_self() == self));
8876
+ try {
8877
+ {
8878
+ try {
8879
+ if (upcall) {
8880
+ (arg1)->Gosu::Window::show();
8881
+ } else {
8882
+ (arg1)->show();
8883
+ }
8884
+ } catch (const std::exception& e) {
8885
+ SWIG_exception(SWIG_RuntimeError, e.what());
8886
+ }
8830
8887
  }
8888
+ } catch (Swig::DirectorException& e) {
8889
+ rb_exc_raise(e.getError());
8890
+ SWIG_fail;
8831
8891
  }
8832
8892
  return Qnil;
8833
8893
  fail:
@@ -8835,6 +8895,49 @@ fail:
8835
8895
  }
8836
8896
 
8837
8897
 
8898
+ SWIGINTERN VALUE
8899
+ _wrap_Window_tick(int argc, VALUE *argv, VALUE self) {
8900
+ Gosu::Window *arg1 = (Gosu::Window *) 0 ;
8901
+ void *argp1 = 0 ;
8902
+ int res1 = 0 ;
8903
+ Swig::Director *director = 0;
8904
+ bool upcall = false;
8905
+ bool result;
8906
+ VALUE vresult = Qnil;
8907
+
8908
+ if ((argc < 0) || (argc > 0)) {
8909
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
8910
+ }
8911
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Window, 0 | 0 );
8912
+ if (!SWIG_IsOK(res1)) {
8913
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Window *","tick", 1, self ));
8914
+ }
8915
+ arg1 = reinterpret_cast< Gosu::Window * >(argp1);
8916
+ director = dynamic_cast<Swig::Director *>(arg1);
8917
+ upcall = (director && (director->swig_get_self() == self));
8918
+ try {
8919
+ {
8920
+ try {
8921
+ if (upcall) {
8922
+ result = (bool)(arg1)->Gosu::Window::tick();
8923
+ } else {
8924
+ result = (bool)(arg1)->tick();
8925
+ }
8926
+ } catch (const std::exception& e) {
8927
+ SWIG_exception(SWIG_RuntimeError, e.what());
8928
+ }
8929
+ }
8930
+ } catch (Swig::DirectorException& e) {
8931
+ rb_exc_raise(e.getError());
8932
+ SWIG_fail;
8933
+ }
8934
+ vresult = SWIG_From_bool(static_cast< bool >(result));
8935
+ return vresult;
8936
+ fail:
8937
+ return Qnil;
8938
+ }
8939
+
8940
+
8838
8941
  SWIGINTERN VALUE
8839
8942
  _wrap_Window_close(int argc, VALUE *argv, VALUE self) {
8840
8943
  Gosu::Window *arg1 = (Gosu::Window *) 0 ;
@@ -11105,8 +11208,8 @@ SWIGEXPORT void Init_gosu(void) {
11105
11208
  SWIG_RubyInitializeTrackings();
11106
11209
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
11107
11210
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(10)));
11108
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(1)));
11109
- rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.10.1"));
11211
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(2)));
11212
+ rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.10.2.pre1"));
11110
11213
  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\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"));
11111
11214
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
11112
11215
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
@@ -11470,12 +11573,6 @@ SWIGEXPORT void Init_gosu(void) {
11470
11573
  rb_define_const(mGosu, "Gp3Button13", SWIG_From_int(static_cast< int >(Gosu::gp3Button13)));
11471
11574
  rb_define_const(mGosu, "Gp3Button14", SWIG_From_int(static_cast< int >(Gosu::gp3Button14)));
11472
11575
  rb_define_const(mGosu, "Gp3Button15", SWIG_From_int(static_cast< int >(Gosu::gp3Button15)));
11473
-
11474
- GosusDarkSide::oncePerTick = GosusDarkSide::yieldToOtherRubyThreads;
11475
- // While we are at it, call srand() - otherwise unavailable to Ruby people
11476
- std::srand(static_cast<unsigned int>(std::time(0)));
11477
- std::rand(); // and flush the first value
11478
-
11479
11576
  rb_define_module_function(mGosu, "disown_TextInput", VALUEFUNC(_wrap_disown_TextInput), -1);
11480
11577
 
11481
11578
  SwigClassTextInput.klass = rb_define_class_under(mGosu, "TextInput", rb_cObject);
@@ -11506,6 +11603,7 @@ SWIGEXPORT void Init_gosu(void) {
11506
11603
  rb_define_method(SwigClassWindow.klass, "caption=", VALUEFUNC(_wrap_Window_captione___), -1);
11507
11604
  rb_define_method(SwigClassWindow.klass, "update_interval", VALUEFUNC(_wrap_Window_update_interval), -1);
11508
11605
  rb_define_method(SwigClassWindow.klass, "show", VALUEFUNC(_wrap_Window_show), -1);
11606
+ rb_define_method(SwigClassWindow.klass, "tick", VALUEFUNC(_wrap_Window_tick), -1);
11509
11607
  rb_define_method(SwigClassWindow.klass, "close", VALUEFUNC(_wrap_Window_close), -1);
11510
11608
  rb_define_method(SwigClassWindow.klass, "update", VALUEFUNC(_wrap_Window_update), -1);
11511
11609
  rb_define_method(SwigClassWindow.klass, "draw", VALUEFUNC(_wrap_Window_draw), -1);
@@ -30,6 +30,8 @@ class SwigDirector_Window : public Gosu::Window, public Swig::Director {
30
30
  public:
31
31
  SwigDirector_Window(VALUE self, unsigned int width, unsigned int height, bool fullscreen = false, double updateInterval = 16.666666);
32
32
  virtual ~SwigDirector_Window();
33
+ virtual void show();
34
+ virtual bool tick();
33
35
  virtual void update();
34
36
  virtual void draw();
35
37
  virtual bool needsRedraw() const;
@@ -90,6 +90,7 @@ end
90
90
  class Gosu::Window
91
91
  # Backwards compatibility:
92
92
  # Class methods that have been turned into module methods.
93
+
93
94
  def self.button_id_to_char(id)
94
95
  Gosu.button_id_to_char(id)
95
96
  end
@@ -99,7 +100,8 @@ class Gosu::Window
99
100
  end
100
101
 
101
102
  # Backwards compatibility:
102
- # Instance methods taht have been turned into module methods.
103
+ # Instance methods that have been turned into module methods.
104
+
103
105
  %w(draw_line draw_triangle draw_quad
104
106
  flush gl clip_to record
105
107
  transform translate rotate scale
@@ -108,6 +110,16 @@ class Gosu::Window
108
110
  Gosu.send method, *args, &block
109
111
  end
110
112
  end
113
+
114
+ # Call Thread.pass every tick, which may or may not be necessary for friendly co-existence with
115
+ # Ruby's Thread class.
116
+
117
+ alias _tick tick
118
+
119
+ def tick
120
+ Thread.pass
121
+ _tick
122
+ end
111
123
  end
112
124
 
113
125
  # Release OpenAL resources during Ruby's shutdown, not Gosu's.
@@ -167,55 +167,50 @@ double Gosu::Window::updateInterval() const
167
167
  return pimpl->updateInterval;
168
168
  }
169
169
 
170
- namespace GosusDarkSide
170
+ void Gosu::Window::show()
171
171
  {
172
- // TODO: Find a way for this to fit into Gosu's design.
173
- // This can point to a function that wants to be called every
174
- // frame, e.g. rb_thread_schedule.
175
- typedef void (*HookOfHorror)();
176
- HookOfHorror oncePerTick = 0;
172
+ unsigned long timeBeforeTick = milliseconds();
173
+
174
+ while (tick()) {
175
+ // Sleep to keep this loop from eating 100% CPU.
176
+ unsigned long tickTime = milliseconds() - timeBeforeTick;
177
+ if (tickTime < updateInterval())
178
+ sleep(updateInterval() - tickTime);
179
+
180
+ timeBeforeTick = milliseconds();
181
+ }
177
182
  }
178
183
 
179
- void Gosu::Window::show()
184
+ bool Gosu::Window::tick()
180
185
  {
181
- while (true) {
182
- unsigned long startTime = milliseconds();
183
-
184
- SDL_Event e;
185
- while (SDL_PollEvent(&e)) {
186
- if (e.type == SDL_QUIT)
187
- return;
188
- else
189
- input().feedSDLEvent(&e);
190
- }
191
-
192
- Song::update();
193
-
194
- input().update();
195
-
196
- update();
197
-
198
- SDL_ShowCursor(needsCursor());
199
-
200
- if (needsRedraw()) {
201
- ensureCurrentContext();
202
- if (graphics().begin()) {
203
- draw();
204
- graphics().end();
205
- FPS::registerFrame();
206
- }
207
-
208
- SDL_GL_SwapWindow(sharedWindow());
209
-
210
- if (GosusDarkSide::oncePerTick) GosusDarkSide::oncePerTick();
186
+ SDL_Event e;
187
+ while (SDL_PollEvent(&e)) {
188
+ if (e.type == SDL_QUIT)
189
+ return false;
190
+ else
191
+ input().feedSDLEvent(&e);
192
+ }
193
+
194
+ Song::update();
195
+
196
+ input().update();
197
+
198
+ update();
199
+
200
+ SDL_ShowCursor(needsCursor());
201
+
202
+ if (needsRedraw()) {
203
+ ensureCurrentContext();
204
+ if (graphics().begin()) {
205
+ draw();
206
+ graphics().end();
207
+ FPS::registerFrame();
211
208
  }
212
209
 
213
- // Sleep to keep this loop from eating 100% CPU.
214
- unsigned long frameTime = milliseconds() - startTime;
215
- if (frameTime < pimpl->updateInterval) {
216
- sleep(pimpl->updateInterval - frameTime);
217
- }
210
+ SDL_GL_SwapWindow(sharedWindow());
218
211
  }
212
+
213
+ return true;
219
214
  }
220
215
 
221
216
  void Gosu::Window::close()
@@ -113,6 +113,11 @@ void Gosu::Window::show()
113
113
  {
114
114
  }
115
115
 
116
+ bool Gosu::Window::tick()
117
+ {
118
+ return true;
119
+ }
120
+
116
121
  void Gosu::Window::close()
117
122
  {
118
123
  throw std::logic_error("Cannot close windows manually on iOS");
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.10.1.2
4
+ version: 0.10.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-08-26 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  2D game development library.
@@ -155,9 +155,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
155
  version: 1.8.2
156
156
  required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - '>='
158
+ - - '>'
159
159
  - !ruby/object:Gem::Version
160
- version: '0'
160
+ version: 1.3.1
161
161
  requirements: []
162
162
  rubyforge_project:
163
163
  rubygems_version: 2.0.14