gosu 0.7.35 → 0.7.36.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,16 +19,16 @@ namespace Gosu
19
19
  public:
20
20
  //! Loads an image from a given filename that can be drawn onto
21
21
  //! graphics.
22
- //! This constructor can handle PNG and BMP images. A color key of #ff00ff is
23
- //! automatically applied to BMP type images. For more flexibility, use the
24
- //! corresponding constructor that uses a Bitmap object.
22
+ //! This constructor can handle PNG and BMP images. A color key of #ff00ff is
23
+ //! automatically applied to BMP type images. For more flexibility, use the
24
+ //! corresponding constructor that uses a Bitmap object.
25
25
  Image(Graphics& graphics, const std::wstring& filename,
26
26
  bool tileable = false);
27
27
  //! Loads a portion of the the image at the given filename that can be
28
28
  //! drawn onto graphics.
29
- //! This constructor can handle PNG and BMP images. A color key of #ff00ff is
30
- //! automatically applied to BMP type images. For more flexibility, use the
31
- //! corresponding constructor that uses a Bitmap object.
29
+ //! This constructor can handle PNG and BMP images. A color key of #ff00ff is
30
+ //! automatically applied to BMP type images. For more flexibility, use the
31
+ //! corresponding constructor that uses a Bitmap object.
32
32
  Image(Graphics& graphics, const std::wstring& filename, unsigned srcX,
33
33
  unsigned srcY, unsigned srcWidth, unsigned srcHeight,
34
34
  bool tileable = false);
@@ -80,8 +80,8 @@ namespace Gosu
80
80
  ImageData& getData() const;
81
81
  };
82
82
 
83
- //! Convenience function that splits a BMP or PNG file into an array
84
- //! of small rectangles and creates images from them.
83
+ //! Convenience function that splits a BMP or PNG file into an array
84
+ //! of small rectangles and creates images from them.
85
85
  //! \param tileWidth If positive, specifies the width of one tile in
86
86
  //! pixels. If negative, the bitmap is divided into -tileWidth rows.
87
87
  //! \param tileHeight See tileWidth.
@@ -33,42 +33,42 @@
33
33
 
34
34
  namespace Gosu
35
35
  {
36
- //! Very lightweight class that identifies a button (keyboard, mouse or other device).
37
- class Button
38
- {
39
- unsigned id_;
40
-
41
- public:
42
- //! For internal use.
43
- explicit Button(unsigned id) : id_(id) {}
44
- //! For internal use.
45
- unsigned id() const { return id_; }
36
+ //! Very lightweight class that identifies a button (keyboard, mouse or other device).
37
+ class Button
38
+ {
39
+ unsigned id_;
40
+
41
+ public:
42
+ //! For internal use.
43
+ explicit Button(unsigned id) : id_(id) {}
44
+ //! For internal use.
45
+ unsigned id() const { return id_; }
46
46
 
47
- //! Default constructor; == noButton.
48
- Button() : id_(noButton) {}
47
+ //! Default constructor; == noButton.
48
+ Button() : id_(noButton) {}
49
49
 
50
- //! Conversion from ButtonName constants.
51
- Button(ButtonName name) : id_(name) {}
52
- };
50
+ //! Conversion from ButtonName constants.
51
+ Button(ButtonName name) : id_(name) {}
52
+ };
53
53
 
54
- //! Tests whether two Buttons identify the same physical button.
55
- inline bool operator==(Button lhs, Button rhs)
56
- {
57
- return lhs.id() == rhs.id();
58
- }
59
- inline bool operator!=(Button lhs, Button rhs)
60
- {
61
- return !(lhs == rhs);
62
- }
54
+ //! Tests whether two Buttons identify the same physical button.
55
+ inline bool operator==(Button lhs, Button rhs)
56
+ {
57
+ return lhs.id() == rhs.id();
58
+ }
59
+ inline bool operator!=(Button lhs, Button rhs)
60
+ {
61
+ return !(lhs == rhs);
62
+ }
63
63
  inline bool operator<(Button lhs, Button rhs)
64
64
  {
65
65
  return lhs.id() < rhs.id();
66
66
  }
67
-
67
+
68
68
  //! Struct that saves information about a touch on the surface of a multi-
69
69
  //! touch device.
70
- //! Available even on non-iPhone platforms to make it easier to compile the
71
- //! same source for multiple platforms.
70
+ //! Available even on non-iPhone platforms to make it easier to compile the
71
+ //! same source for multiple platforms.
72
72
  struct Touch
73
73
  {
74
74
  //! Allows for identification of a touch across calls.
@@ -79,13 +79,13 @@ namespace Gosu
79
79
  typedef std::vector<Touch> Touches;
80
80
 
81
81
  //! Manages initialization and shutdown of the input system. Only one Input
82
- //! instance can exist per application.
82
+ //! instance can exist per application.
83
83
  class Input
84
84
  {
85
85
  struct Impl;
86
86
  const std::auto_ptr<Impl> pimpl;
87
87
 
88
- public:
88
+ public:
89
89
  #ifdef GOSU_IS_WIN
90
90
  Input(HWND window);
91
91
  #endif
@@ -113,9 +113,9 @@ namespace Gosu
113
113
  //! given character, or noButton.
114
114
  static Button charToId(wchar_t ch);
115
115
 
116
- //! Returns true if a button is currently pressed.
116
+ //! Returns true if a button is currently pressed.
117
117
  //! Updated every tick.
118
- bool down(Button btn) const;
118
+ bool down(Button btn) const;
119
119
 
120
120
  //! Returns the horizontal position of the mouse relative to the top
121
121
  //! left corner of the window given to Input's constructor.
@@ -143,12 +143,12 @@ namespace Gosu
143
143
  //! mouse is and calls onButtonUp/onButtonDown, if assigned.
144
144
  void update();
145
145
 
146
- //! Assignable events that are called by update. You can bind these to your own functions.
147
- //! If you use the Window class, it will assign forward these to its own methods.
146
+ //! Assignable events that are called by update. You can bind these to your own functions.
147
+ //! If you use the Window class, it will assign forward these to its own methods.
148
148
  std::tr1::function<void (Button)> onButtonDown, onButtonUp;
149
149
 
150
- //! Assignable events that are called by update. You can bind these to your own functions.
151
- //! If you use the Window class, it will assign forward these to its own methods.
150
+ //! Assignable events that are called by update. You can bind these to your own functions.
151
+ //! If you use the Window class, it will assign forward these to its own methods.
152
152
  std::tr1::function<void (Touch)> onTouchBegan, onTouchMoved, onTouchEnded;
153
153
 
154
154
  //! Returns the currently active TextInput instance, or 0.
@@ -3,8 +3,8 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 7
6
- #define GOSU_POINT_VERSION 35
7
- #define GOSU_VERSION "0.7.35"
6
+ #define GOSU_POINT_VERSION 36
7
+ #define GOSU_VERSION "0.7.36.2"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  "May contain `ogg', `vorbis' libraries (c) 2002-2008 Xiph.org Foundation" \
@@ -21,7 +21,7 @@
21
21
  namespace Gosu
22
22
  {
23
23
  //! Convenient all-in-one class that serves as the foundation of a standard
24
- //! Gosu application. Manages initialization of all of Gosu's core components
24
+ //! Gosu application. Manages initialization of all of Gosu's core components
25
25
  //! and provides timing functionality.
26
26
  //! Note that you should really only use one instance of this class at the same time.
27
27
  //! This may or may not change later.
@@ -43,7 +43,8 @@ namespace Gosu
43
43
 
44
44
  double updateInterval() const;
45
45
 
46
- //! Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
46
+ //! Enters a modal loop where the Window is visible on screen and
47
+ //! receives calls to draw, update etc.
47
48
  void show();
48
49
  //! Closes the window if it is currently shown.
49
50
  void close();
@@ -61,9 +62,9 @@ namespace Gosu
61
62
  //! By default, the window is redrawn all the time.
62
63
  virtual bool needsRedraw() const { return true; }
63
64
 
64
- //! If this function returns true, the system arrow cursor is drawn while
65
- //! over the window.
66
- virtual bool needsCursor() const { return false; }
65
+ //! If this function returns true, the system arrow cursor is drawn while
66
+ //! over the window.
67
+ virtual bool needsCursor() const { return false; }
67
68
 
68
69
  //! This function is called when the window loses focus on some platforms.
69
70
  //! Most importantly, it is called on the iPhone or iPad when the user
@@ -3,6 +3,7 @@
3
3
  #include <Gosu/Platform.hpp>
4
4
  #include <Gosu/TR1.hpp>
5
5
  #include <Gosu/Utility.hpp>
6
+ #include <stdexcept>
6
7
  #include <vector>
7
8
  #include <FreeImage.h>
8
9
 
@@ -75,10 +76,33 @@ namespace
75
76
  {
76
77
  return ((Gosu::Writer*)handle)->position();
77
78
  }
79
+
80
+ // TODO: This is not thread safe!
81
+
82
+ std::string lastFreeImageError;
83
+
84
+ void DLL_CALLCONV FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message)
85
+ {
86
+ lastFreeImageError = (message && message[0]) ? message : "Unknown error";
87
+ if (fif != FIF_UNKNOWN)
88
+ if (const char* format = FreeImage_GetFormatFromFIF(fif))
89
+ lastFreeImageError += std::string(" (in ") + format + " parser)";
90
+ }
91
+
92
+ void checkForFreeImageErrors(bool value = true)
93
+ {
94
+ if (!value || !lastFreeImageError.empty())
95
+ {
96
+ std::string message = lastFreeImageError;
97
+ if (message.empty())
98
+ message = "Unknown error";
99
+ else
100
+ lastFreeImageError.clear();
101
+ throw std::runtime_error(message);
102
+ }
103
+ }
78
104
  }
79
105
 
80
- // TODO: error checking w/ FreeImage_SetOutputMessage?
81
-
82
106
  namespace Gosu
83
107
  {
84
108
  void FI(loadImageFile)(Bitmap& bitmap, const std::wstring& filename)
@@ -91,7 +115,7 @@ namespace Gosu
91
115
  FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(utf8Filename.c_str());
92
116
  FIBITMAP* fib = FreeImage_Load(fif, utf8Filename.c_str(), GOSU_FIFLAGS);
93
117
  #endif
94
-
118
+ checkForFreeImageErrors(fib);
95
119
  fibToBitmap(bitmap, fib, fif);
96
120
  }
97
121
 
@@ -103,7 +127,7 @@ namespace Gosu
103
127
  FIMEMORY* fim = FreeImage_OpenMemory(&data[0], data.size());
104
128
  FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(fim);
105
129
  FIBITMAP* fib = FreeImage_LoadFromMemory(fif, fim, GOSU_FIFLAGS);
106
-
130
+ checkForFreeImageErrors(fib);
107
131
  fibToBitmap(bitmap, fib, fif);
108
132
  }
109
133
 
@@ -119,6 +143,7 @@ namespace Gosu
119
143
  FreeImage_Save(fif, fib, utf8Filename.c_str());
120
144
  #endif
121
145
  FreeImage_Unload(fib);
146
+ checkForFreeImageErrors();
122
147
  }
123
148
 
124
149
  void FI(saveImageFile)(const Bitmap& bitmap, Gosu::Writer writer,
@@ -131,5 +156,6 @@ namespace Gosu
131
156
  FreeImageIO fio = { NULL, WriteProc, SeekProc, TellProc };
132
157
  FreeImage_SaveToHandle(fif, fib, &fio, &writer);
133
158
  FreeImage_Unload(fib);
159
+ checkForFreeImageErrors();
134
160
  }
135
161
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -26,7 +26,7 @@
26
26
  %typemap(in) wchar_t {
27
27
  VALUE localTemporary = rb_obj_as_string($input);
28
28
  std::wstring localTemporary2 = Gosu::utf8ToWstring(StringValueCStr(localTemporary));
29
- $1 = localTemporary2.empty() ? 0 : localTemporary2.at(0);
29
+ $1 = localTemporary2.empty() ? 0 : localTemporary2.at(0);
30
30
  }
31
31
  %typemap(out) wchar_t {
32
32
  if ($1 == 0)
@@ -203,7 +203,7 @@ namespace GosusDarkSide
203
203
 
204
204
  void yieldToOtherRubyThreads()
205
205
  {
206
- rb_thread_schedule();
206
+ rb_thread_schedule();
207
207
  }
208
208
  }
209
209
 
@@ -216,8 +216,8 @@ namespace
216
216
 
217
217
  namespace Gosu
218
218
  {
219
- #ifdef GOSU_IS_WIN
220
- void ping_FreeImage()
219
+ #ifdef GOSU_IS_WIN
220
+ void requireFreeImageFor(const char* filename)
221
221
  {
222
222
  // Copied and pasted from MSDN.
223
223
  // TODO: Remove duplication, this is also in AudioAudiere.cpp
@@ -231,7 +231,9 @@ namespace Gosu
231
231
  }
232
232
  __except ((GetExceptionCode() == BAD_MOD) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
233
233
  {
234
- rb_raise(rb_eRuntimeError, "unable to locate FreeImage.dll");
234
+ rb_raise(rb_eRuntimeError,
235
+ "Could neither load image %s nor locate FreeImage.dll to retry with it",
236
+ filename);
235
237
  }
236
238
  #undef BAD_MOD
237
239
  #undef VcppException
@@ -250,15 +252,22 @@ namespace Gosu
250
252
  try {
251
253
  loadImageFile(bitmap, filename);
252
254
  return;
253
- } catch (const std::exception&) {
255
+ } catch (const std::exception&) {
254
256
  #ifdef GOSU_IS_WIN
255
- ping_FreeImage();
256
- loadImageFile_FreeImage(bitmap, filename);
257
+ requireFreeImageFor(filenameUTF8);
258
+ try {
259
+ loadImageFile_FreeImage(bitmap, filename);
260
+ }
261
+ catch (const std::runtime_error& error) {
262
+ rb_raise(rb_eRuntimeError,
263
+ "Could not load image %s using either GDI+ or FreeImage: %s",
264
+ filenameUTF8, error.what());
265
+ }
257
266
  return;
258
- #else
259
- throw;
260
- #endif
261
- }
267
+ #else
268
+ throw;
269
+ #endif
270
+ }
262
271
  }
263
272
 
264
273
  // Otherwise, try to call .to_blob on it (works with RMagick, TexPlay etc).
@@ -590,8 +599,8 @@ namespace Gosu {
590
599
  %include "../Gosu/ButtonsMac.hpp"
591
600
  %init %{
592
601
  GosusDarkSide::oncePerTick = GosusDarkSide::yieldToOtherRubyThreads;
593
- // While we are at it, to some healthy srand() - otherwise unavailable to Ruby people
594
- std::srand(static_cast<unsigned int>(std::time(0)));
602
+ // While we are at it, to some healthy srand() - otherwise unavailable to Ruby people
603
+ std::srand(static_cast<unsigned int>(std::time(0)));
595
604
  std::rand(); // and flush the first value
596
605
  %}
597
606
 
@@ -685,12 +694,12 @@ namespace Gosu {
685
694
  $self->input().setTextInput(ti);
686
695
  }
687
696
 
688
- double mouseX() const {
689
- return $self->input().mouseX();
690
- }
691
- double mouseY() const {
692
- return $self->input().mouseY();
693
- }
697
+ double mouseX() const {
698
+ return $self->input().mouseX();
699
+ }
700
+ double mouseY() const {
701
+ return $self->input().mouseY();
702
+ }
694
703
  void setMousePosition(double x, double y) {
695
704
  $self->input().setMousePosition(x, y);
696
705
  }
@@ -701,12 +710,12 @@ namespace Gosu {
701
710
  $self->input().setMousePosition($self->input().mouseX(), y);
702
711
  }
703
712
 
704
- int width() const {
705
- return $self->graphics().width();
706
- }
707
- int height() const {
708
- return $self->graphics().height();
709
- }
713
+ int width() const {
714
+ return $self->graphics().width();
715
+ }
716
+ int height() const {
717
+ return $self->graphics().height();
718
+ }
710
719
  bool fullscreen() const {
711
720
  return $self->graphics().fullscreen();
712
721
  }
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 2.0.3
3
+ * Version 2.0.4
4
4
  *
5
5
  * This file is not intended to be easily readable and contains a number of
6
6
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -2191,7 +2191,7 @@ static VALUE mGosu;
2191
2191
  #define SWIG_RUBY_THREAD_END_BLOCK
2192
2192
 
2193
2193
 
2194
- #define SWIGVERSION 0x020003
2194
+ #define SWIGVERSION 0x020004
2195
2195
  #define SWIG_VERSION SWIGVERSION
2196
2196
 
2197
2197
 
@@ -2274,7 +2274,7 @@ namespace GosusDarkSide
2274
2274
 
2275
2275
  void yieldToOtherRubyThreads()
2276
2276
  {
2277
- rb_thread_schedule();
2277
+ rb_thread_schedule();
2278
2278
  }
2279
2279
  }
2280
2280
 
@@ -2287,8 +2287,8 @@ namespace
2287
2287
 
2288
2288
  namespace Gosu
2289
2289
  {
2290
- #ifdef GOSU_IS_WIN
2291
- void ping_FreeImage()
2290
+ #ifdef GOSU_IS_WIN
2291
+ void requireFreeImageFor(const char* filename)
2292
2292
  {
2293
2293
  // Copied and pasted from MSDN.
2294
2294
  // TODO: Remove duplication, this is also in AudioAudiere.cpp
@@ -2302,7 +2302,9 @@ namespace Gosu
2302
2302
  }
2303
2303
  __except ((GetExceptionCode() == BAD_MOD) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
2304
2304
  {
2305
- rb_raise(rb_eRuntimeError, "unable to locate FreeImage.dll");
2305
+ rb_raise(rb_eRuntimeError,
2306
+ "Could neither load image %s nor locate FreeImage.dll to retry with it",
2307
+ filename);
2306
2308
  }
2307
2309
  #undef BAD_MOD
2308
2310
  #undef VcppException
@@ -2321,15 +2323,22 @@ namespace Gosu
2321
2323
  try {
2322
2324
  loadImageFile(bitmap, filename);
2323
2325
  return;
2324
- } catch (const std::exception&) {
2326
+ } catch (const std::exception&) {
2325
2327
  #ifdef GOSU_IS_WIN
2326
- ping_FreeImage();
2327
- loadImageFile_FreeImage(bitmap, filename);
2328
+ requireFreeImageFor(filenameUTF8);
2329
+ try {
2330
+ loadImageFile_FreeImage(bitmap, filename);
2331
+ }
2332
+ catch (const std::runtime_error& error) {
2333
+ rb_raise(rb_eRuntimeError,
2334
+ "Could not load image %s using either GDI+ or FreeImage: %s",
2335
+ filenameUTF8, error.what());
2336
+ }
2328
2337
  return;
2329
- #else
2330
- throw;
2331
- #endif
2332
- }
2338
+ #else
2339
+ throw;
2340
+ #endif
2341
+ }
2333
2342
  }
2334
2343
 
2335
2344
  // Otherwise, try to call .to_blob on it (works with RMagick, TexPlay etc).
@@ -2437,7 +2446,7 @@ SWIG_ruby_failed(void)
2437
2446
  }
2438
2447
 
2439
2448
 
2440
- /*@SWIG:/usr/local/Cellar/swig/2.0.3/share/swig/2.0.3/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2449
+ /*@SWIG:/usr/local/Cellar/swig/2.0.4/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2441
2450
  SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
2442
2451
  {
2443
2452
  VALUE obj = args[0];
@@ -2479,7 +2488,7 @@ SWIG_From_unsigned_SS_int (unsigned int value)
2479
2488
  #include <string>
2480
2489
 
2481
2490
 
2482
- /*@SWIG:/usr/local/Cellar/swig/2.0.3/share/swig/2.0.3/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2491
+ /*@SWIG:/usr/local/Cellar/swig/2.0.4/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2483
2492
  SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
2484
2493
  {
2485
2494
  VALUE obj = args[0];
@@ -2595,7 +2604,7 @@ SWIG_From_bool (bool value)
2595
2604
  }
2596
2605
 
2597
2606
 
2598
- /*@SWIG:/usr/local/Cellar/swig/2.0.3/share/swig/2.0.3/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2607
+ /*@SWIG:/usr/local/Cellar/swig/2.0.4/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2599
2608
  SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
2600
2609
  {
2601
2610
  VALUE obj = args[0];
@@ -2786,11 +2795,11 @@ SWIGINTERN void Gosu_Window_setTextInput(Gosu::Window *self,Gosu::TextInput *ti)
2786
2795
  self->input().setTextInput(ti);
2787
2796
  }
2788
2797
  SWIGINTERN double Gosu_Window_mouseX(Gosu::Window const *self){
2789
- return self->input().mouseX();
2790
- }
2798
+ return self->input().mouseX();
2799
+ }
2791
2800
  SWIGINTERN double Gosu_Window_mouseY(Gosu::Window const *self){
2792
- return self->input().mouseY();
2793
- }
2801
+ return self->input().mouseY();
2802
+ }
2794
2803
  SWIGINTERN void Gosu_Window_setMousePosition(Gosu::Window *self,double x,double y){
2795
2804
  self->input().setMousePosition(x, y);
2796
2805
  }
@@ -2801,11 +2810,11 @@ SWIGINTERN void Gosu_Window_setMouseY(Gosu::Window *self,double y){
2801
2810
  self->input().setMousePosition(self->input().mouseX(), y);
2802
2811
  }
2803
2812
  SWIGINTERN int Gosu_Window_width(Gosu::Window const *self){
2804
- return self->graphics().width();
2805
- }
2813
+ return self->graphics().width();
2814
+ }
2806
2815
  SWIGINTERN int Gosu_Window_height(Gosu::Window const *self){
2807
- return self->graphics().height();
2808
- }
2816
+ return self->graphics().height();
2817
+ }
2809
2818
  SWIGINTERN bool Gosu_Window_fullscreen(Gosu::Window const *self){
2810
2819
  return self->graphics().fullscreen();
2811
2820
  }
@@ -11241,8 +11250,8 @@ SWIGEXPORT void Init_gosu(void) {
11241
11250
  SWIG_RubyInitializeTrackings();
11242
11251
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
11243
11252
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(7)));
11244
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(35)));
11245
- rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.35"));
11253
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(36)));
11254
+ rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.36.2"));
11246
11255
  rb_define_const(mGosu, "GOSU_COPYRIGHT_NOTICE", SWIG_FromCharPtr("May contain `ogg\', `vorbis\' libraries (c) 2002-2008 Xiph.org Foundation\n\nRedistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:\n\n- Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.\n\n- Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.\n\n- Neither the name of the Xiph.org Foundation nor the names of itscontributors may be used to endorse or promote products derived fromthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS``AS IS\'\' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOTLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATIONOR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANYTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."));
11247
11256
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
11248
11257
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 2.0.3
3
+ * Version 2.0.4
4
4
  *
5
5
  * This file is not intended to be easily readable and contains a number of
6
6
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -9,10 +9,10 @@ void Gosu::sleep(unsigned milliseconds)
9
9
 
10
10
  unsigned long Gosu::milliseconds()
11
11
  {
12
- timeval tp;
13
- gettimeofday(&tp, NULL);
12
+ timeval tp;
13
+ gettimeofday(&tp, NULL);
14
14
  // Truncate to 2^30, C++ users shouldn't mind and Ruby users will
15
15
  // have a happy GC on 32-bit systems.
16
16
  // No, don't ask why this is an unsigned long then :)
17
- return (tp.tv_usec / 1000UL + tp.tv_sec * 1000UL) & 0x1fffffff;
17
+ return (tp.tv_usec / 1000UL + tp.tv_sec * 1000UL) & 0x1fffffff;
18
18
  }
@@ -0,0 +1,116 @@
1
+ require 'gosu'
2
+
3
+ # Wrapper around Gosu 0.7 that provides the work-in-progress 0.8 interface
4
+
5
+ module Gosu
6
+ class Font
7
+ alias :initialize07 :initialize
8
+
9
+ def initialize *args
10
+ if args.first.is_a? Gosu::Window then
11
+ initialize07 *args
12
+ else
13
+ height = args[0]
14
+ options = args[1] || {}
15
+ name = options[:name] || Gosu::default_font_name
16
+ initialize07 $window, name, height
17
+ end
18
+ end
19
+ end
20
+
21
+ class Window
22
+ alias :initialize07 :initialize
23
+
24
+ def initialize width, height, *args
25
+ if args.empty? or args.first.is_a? Hash then
26
+ options = args.first || {}
27
+ fullscreen = !!options[:fullscreen]
28
+ update_interval = options[:update_interval] || 16.66
29
+ else
30
+ fullscreen, update_interval = *args
31
+ end
32
+ $window = initialize07 width, height, fullscreen, update_interval
33
+ end
34
+ end
35
+
36
+ class Image
37
+ alias :initialize07 :initialize
38
+
39
+ def initialize *args
40
+ if args.first.is_a? Gosu::Window then
41
+ initialize07 *args
42
+ else
43
+ source = args[0]
44
+ tileable = !args[1] || args[1][:tileable]
45
+ initialize07 $window, source, !!tileable
46
+ end
47
+ end
48
+
49
+ class <<self
50
+ alias load_tiles07 load_tiles
51
+ end
52
+
53
+ def self.load_tiles *args
54
+ if args.first.is_a? Gosu::Window then
55
+ load_tiles07 *args
56
+ else
57
+ source = args[0]
58
+ x, y = args[1..2]
59
+ tileable = !args[3] || args[3][:tileable]
60
+ load_tiles07 $window, source, x, y, !!tileable
61
+ end
62
+ end
63
+
64
+ def self.from_text *args
65
+ if args.first.is_a? Gosu::Window then
66
+ args.size == 4 ? from_text4(*args) : from_text7(*args)
67
+ else
68
+ text = args[0]
69
+ height = args[1]
70
+ options = args[2] || {}
71
+ font = options[:font] || Gosu::default_font_name
72
+ if width = options[:width] then
73
+ spacing = options[:spacing] || 0
74
+ align = options[:align] || :left
75
+ Gosu::Image.from_text7 $window, text, font, height, spacing, width, align
76
+ else
77
+ Gosu::Image.from_text4 $window, text, font, height
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ def self.draw_quad *args
84
+ $window.draw_quad *args
85
+ end
86
+
87
+ def self.clip_to *args
88
+ $window.clip_to *args do
89
+ yield
90
+ end
91
+ end
92
+
93
+ def self.translate *args
94
+ $window.translate *args do
95
+ yield
96
+ end
97
+ end
98
+
99
+ def self.scale *args
100
+ $window.scale *args do
101
+ yield
102
+ end
103
+ end
104
+
105
+ def self.rotate *args
106
+ $window.rotate *args do
107
+ yield
108
+ end
109
+ end
110
+
111
+ def self.transform *args
112
+ $window.transform *args do
113
+ yield
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,11 @@
1
+ # Replace the load path
2
+ $LOAD_PATH.clear
3
+ $LOAD_PATH << File.dirname(__FILE__)[0..-6]
4
+ $LOAD_PATH << $LOAD_PATH[0] + '/lib'
5
+ # Ruby portions of Gosu
6
+ require 'gosu/patches'
7
+ require 'gosu/swig_patches'
8
+ # Let the application know it is being run from the Mac app wrapper.
9
+ OSX_EXECUTABLE = true
10
+ # Main application
11
+ require 'Main'
@@ -0,0 +1,28 @@
1
+ require 'gosu'
2
+ require 'singleton'
3
+
4
+ module Gosu
5
+ class ZenWindow < Window
6
+ include Singleton
7
+
8
+ def initialize
9
+ super 800, 600, false
10
+ end
11
+ end
12
+ end
13
+
14
+ def set what, value
15
+ Gosu::ZenWindow.instance.send "#{what}=", value
16
+ end
17
+
18
+ def update(&proc)
19
+ Gosu::ZenWindow.send :define_method, :update, proc
20
+ end
21
+
22
+ # WIP - needs all other callbacks, even with arguments
23
+
24
+ # WIP - needs to be compatible with gosu/preview.rb later
25
+
26
+ at_exit do
27
+ Gosu::ZenWindow.instance.show
28
+ end
@@ -48,7 +48,7 @@ MAC_FILES = %w(
48
48
  )
49
49
 
50
50
  LINUX_FILES = %w(
51
- Audio/AudioSDL.cpp
51
+ Audio/AudioOpenAL.cpp
52
52
  Graphics/BitmapFreeImage.cpp
53
53
  Graphics/TextUnix.cpp
54
54
  InputX.cpp
@@ -88,8 +88,7 @@ else
88
88
  pango_config = "pkg-config pangoft2"
89
89
 
90
90
  $INCFLAGS << " `#{sdl_config} --cflags` `#{pango_config} --cflags`"
91
- $LDFLAGS << " `#{sdl_config} --libs` `#{pango_config} --libs` -lX11"
92
- have_header('SDL_mixer.h') if have_library('SDL_mixer', 'Mix_OpenAudio')
91
+ $LDFLAGS << " `#{sdl_config} --libs` `#{pango_config} --libs` -lXdamage -lX11"
93
92
  have_header('SDL_ttf.h') if have_library('SDL_ttf', 'TTF_RenderUTF8_Blended')
94
93
  have_header('gl.h') if have_library('GL', 'glMatrixMode')
95
94
  have_header('FreeImage.h') if have_library('freeimage', 'FreeImage_ConvertFromRawBits')
metadata CHANGED
@@ -1,25 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 69
4
+ hash: 227
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 35
10
- version: 0.7.35
9
+ - 36
10
+ - 2
11
+ version: 0.7.36.2
11
12
  platform: ruby
12
13
  authors:
13
14
  - Julian Raschke
14
- - Jan Luecker
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-12 00:00:00 Z
19
+ date: 2011-08-25 00:00:00 Z
20
20
  dependencies: []
21
21
 
22
- description: " 2D game development library.\n\n Gosu features easy to use and game-friendly interfaces to 2D graphics\n and text (accelerated by 3D hardware), sound samples and music as well as\n keyboard, mouse and gamepad/joystick input.\n\n Also includes demos for integration with RMagick, Chipmunk and Ruby-OpenGL.\n"
22
+ description: " 2D game development library.\n\n Gosu features easy to use and game-friendly interfaces to 2D graphics\n and text (accelerated by 3D hardware), sound samples and music as well as\n keyboard, mouse and gamepad/joystick input.\n\n Also includes demos for integration with RMagick, Chipmunk and OpenGL.\n"
23
23
  email: julian@raschke.de
24
24
  executables: []
25
25
 
@@ -60,9 +60,12 @@ files:
60
60
  - Gosu/Version.hpp
61
61
  - Gosu/Window.hpp
62
62
  - Gosu/WinUtility.hpp
63
- - lib/gosu.rb
64
63
  - lib/gosu/patches.rb
64
+ - lib/gosu/preview.rb
65
+ - lib/gosu/run.rb
65
66
  - lib/gosu/swig_patches.rb
67
+ - lib/gosu/zen.rb
68
+ - lib/gosu.rb
66
69
  - examples/ChipmunkIntegration.rb
67
70
  - examples/CptnRuby.rb
68
71
  - examples/MoreChipmunkAndRMagick.rb
@@ -206,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
209
  requirements:
207
210
  - See https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
208
211
  rubyforge_project:
209
- rubygems_version: 1.8.7
212
+ rubygems_version: 1.8.9
210
213
  signing_key:
211
214
  specification_version: 3
212
215
  summary: 2D game development library.