gosu 0.7.43 → 0.7.44

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,14 +53,14 @@ namespace Gosu
53
53
  //! \param fontHeight Height of the font in pixels.
54
54
  //! \param lineSpacing Spacing between two lines of text in pixels. Can be negative to make
55
55
  //! text stick together more closely.
56
- //! \param maxWidth Width of the bitmap that will be returned. Text
56
+ //! \param width Width of the bitmap that will be returned. Text
57
57
  //! will be split into multiple lines to avoid drawing over the right
58
58
  //! border. When a single word is too long, it will be truncated.
59
59
  //! \param fontFlags Binary combination of members of the FontFlags
60
60
  //! enum.
61
61
  Bitmap createText(const std::wstring& text,
62
62
  const std::wstring& fontName, unsigned fontHeight,
63
- int lineSpacing, unsigned maxWidth, TextAlign align,
63
+ int lineSpacing, unsigned width, TextAlign align,
64
64
  unsigned fontFlags = 0);
65
65
 
66
66
  //! Registers a new HTML-style entity that can subsequently be used
@@ -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 43
7
- #define GOSU_VERSION "0.7.43"
6
+ #define GOSU_POINT_VERSION 44
7
+ #define GOSU_VERSION "0.7.44"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  " " \
@@ -21,7 +21,12 @@ namespace Gosu
21
21
  static ALCdevice* alDevice;
22
22
  static ALCcontext* alContext;
23
23
 
24
- enum { NUM_SOURCES = 32 }; // This is what the iPhone supports, I hear.
24
+ #ifdef GOSU_IS_IPHONE
25
+ // iOS system limit (possibly not for newer devices)
26
+ enum { NUM_SOURCES = 32 };
27
+ #else
28
+ enum { NUM_SOURCES = 255 };
29
+ #endif
25
30
  static ALuint alSources[NUM_SOURCES];
26
31
  static ALuint currentToken;
27
32
  static ALuint currentTokens[NUM_SOURCES];
@@ -91,4 +96,9 @@ namespace Gosu
91
96
  ALuint ALChannelManagement::currentTokens[NUM_SOURCES];
92
97
 
93
98
  std::auto_ptr<ALChannelManagement> alChannelManagement;
99
+
100
+ void releaseAllOpenALResources()
101
+ {
102
+ alChannelManagement.reset();
103
+ }
94
104
  }
@@ -96,6 +96,7 @@ namespace Gosu { bool isExtension(const wchar_t* str, const wchar_t* ext); }
96
96
 
97
97
  void Gosu::loadImageFile(Bitmap& bitmap, const std::wstring& filename)
98
98
  {
99
+ ObjRef<NSAutoreleasePool> pool([NSAutoreleasePool new]);
99
100
  ObjRef<NSString> filenameRef([[NSString alloc] initWithUTF8String: wstringToUTF8(filename).c_str()]);
100
101
  ObjRef<APPLE_IMAGE> image([[APPLE_IMAGE alloc] initWithContentsOfFile: filenameRef.obj()]);
101
102
  if (!image.get())
@@ -48,8 +48,6 @@ namespace Gosu
48
48
  };
49
49
  }
50
50
 
51
- #include <GosuImpl/Graphics/RenderState.hpp>
52
-
53
51
  namespace Gosu
54
52
  {
55
53
  class Texture;
@@ -66,12 +64,6 @@ namespace Gosu
66
64
  GLuint color;
67
65
  GLfloat vertices[3];
68
66
  };
69
- struct VertexArray
70
- {
71
- RenderState renderState;
72
- std::vector<ArrayVertex> vertices;
73
- };
74
- typedef std::list<VertexArray> VertexArrays;
75
67
 
76
68
  template<typename T>
77
69
  bool isPToTheLeftOfAB(T xa, T ya,
@@ -4,6 +4,7 @@
4
4
  #include <Gosu/GraphicsBase.hpp>
5
5
  #include <Gosu/Color.hpp>
6
6
  #include <GosuImpl/Graphics/Common.hpp>
7
+ #include <GosuImpl/Graphics/RenderState.hpp>
7
8
  #include <GosuImpl/Graphics/TexChunk.hpp>
8
9
  #include <cassert>
9
10
 
@@ -63,7 +64,7 @@ namespace Gosu
63
64
  #endif
64
65
 
65
66
  #ifdef GOSU_IS_IPHONE
66
- if (renderState.texName != NO_TEXTURE)
67
+ if (renderState.texture)
67
68
  {
68
69
  spriteTexcoords[spriteCounter*12 + 0] = left;
69
70
  spriteTexcoords[spriteCounter*12 + 1] = top;
@@ -92,7 +93,7 @@ namespace Gosu
92
93
  for (unsigned i = 0; i < verticesOrBlockIndex; i++)
93
94
  {
94
95
  glColor4ubv(reinterpret_cast<const GLubyte*>(&vertices[i].c));
95
- if (renderState.texName != NO_TEXTURE)
96
+ if (renderState.texture)
96
97
  switch (i)
97
98
  {
98
99
  case 0:
@@ -111,7 +111,7 @@ class Gosu::Macro : public Gosu::ImageData
111
111
  // 0, 0, 0, 0, 0, 0, leftCell7, rightCell7 | origRightSide7
112
112
  // 0, 0, 0, 0, 0, 0, 0, remCell8 | rightSide8
113
113
 
114
- // Use the remainding value in row 8 to eliminate the right value in row 7.
114
+ // Use the remaining value in row 8 to eliminate the right value in row 7.
115
115
  // Row7 = Row7 - factor87 * Row8
116
116
  Float factor87 = rightCell7 / remCell8;
117
117
  Float remCell7 = leftCell7;
@@ -165,7 +165,7 @@ class Gosu::Macro : public Gosu::ImageData
165
165
 
166
166
  void drawVertexArrays(Float x1, Float y1, Float x2, Float y2, Float x3, Float y3, Float x4, Float y4) const
167
167
  {
168
- // TODO: Macros should not be split up because they have different transforms! This is insane.
168
+ // TODO: Macros should not be split up just because they have different transforms! This is insane.
169
169
  // They should be premultiplied and have the same transform by definition. Then, the transformation
170
170
  // only had to be performed here once.
171
171
 
@@ -2,37 +2,38 @@
2
2
  #define GOSUIMPL_GRAPHICS_RENDERSTATE_HPP
3
3
 
4
4
  #include <GosuImpl/Graphics/Common.hpp>
5
+ #include <GosuImpl/Graphics/Texture.hpp>
5
6
 
6
7
  // Properties that potentially need to be changed between each draw operation.
7
8
  // This does not include the color or vertex data of the actual quads.
8
9
  struct Gosu::RenderState
9
10
  {
10
- GLuint texName;
11
+ std::tr1::shared_ptr<Texture> texture;
11
12
  const Transform* transform;
12
13
  ClipRect clipRect;
13
14
  AlphaMode mode;
14
15
 
15
16
  RenderState()
16
- : texName(NO_TEXTURE), transform(0), mode(amDefault)
17
+ : transform(0), mode(amDefault)
17
18
  {
18
19
  clipRect.width = NO_CLIPPING;
19
20
  }
20
21
 
21
22
  bool operator==(const RenderState& rhs) const
22
23
  {
23
- return texName == rhs.texName && transform == rhs.transform &&
24
+ return texture == rhs.texture && transform == rhs.transform &&
24
25
  clipRect == rhs.clipRect && mode == rhs.mode;
25
26
  }
26
27
 
27
28
  void applyTexture() const
28
29
  {
29
- if (texName == NO_TEXTURE)
30
- glDisable(GL_TEXTURE_2D);
31
- else
30
+ if (texture)
32
31
  {
33
32
  glEnable(GL_TEXTURE_2D);
34
- glBindTexture(GL_TEXTURE_2D, texName);
33
+ glBindTexture(GL_TEXTURE_2D, texture->texName());
35
34
  }
35
+ else
36
+ glDisable(GL_TEXTURE_2D);
36
37
  }
37
38
 
38
39
  void applyAlphaMode() const
@@ -105,7 +106,7 @@ public:
105
106
  ClipRect noClipping;
106
107
  noClipping.width = NO_CLIPPING;
107
108
  setClipRect(noClipping);
108
- setTexName(NO_TEXTURE);
109
+ setTexture(std::tr1::shared_ptr<Texture>());
109
110
  // Return to previous MV matrix
110
111
  glMatrixMode(GL_MODELVIEW);
111
112
  glPopMatrix();
@@ -113,29 +114,29 @@ public:
113
114
 
114
115
  void setRenderState(const RenderState& rs)
115
116
  {
116
- setTexName(rs.texName);
117
+ setTexture(rs.texture);
117
118
  setTransform(rs.transform);
118
119
  setClipRect(rs.clipRect);
119
120
  setAlphaMode(rs.mode);
120
121
  }
121
122
 
122
- void setTexName(GLuint newTexName)
123
+ void setTexture(std::tr1::shared_ptr<Texture> newTexture)
123
124
  {
124
- if (newTexName == texName)
125
+ if (newTexture == texture)
125
126
  return;
126
127
 
127
- if (newTexName != NO_TEXTURE)
128
+ if (newTexture)
128
129
  {
129
130
  // New texture *is* really a texture - change to it.
130
131
 
131
- if (texName == NO_TEXTURE)
132
+ if (!texture)
132
133
  glEnable(GL_TEXTURE_2D);
133
- glBindTexture(GL_TEXTURE_2D, newTexName);
134
+ glBindTexture(GL_TEXTURE_2D, newTexture->texName());
134
135
  }
135
136
  else
136
137
  // New texture is NO_TEXTURE, disable texturing.
137
138
  glDisable(GL_TEXTURE_2D);
138
- texName = newTexName;
139
+ texture = newTexture;
139
140
  }
140
141
 
141
142
  void setTransform(const Transform* newTransform)
@@ -195,5 +196,15 @@ public:
195
196
  applyAlphaMode();
196
197
  }
197
198
  };
199
+
200
+ namespace Gosu
201
+ {
202
+ struct VertexArray
203
+ {
204
+ RenderState renderState;
205
+ std::vector<ArrayVertex> vertices;
206
+ };
207
+ typedef std::list<VertexArray> VertexArrays;
208
+ }
198
209
 
199
210
  #endif
@@ -28,7 +28,7 @@ void Gosu::TexChunk::draw(double x1, double y1, Color c1,
28
28
  ZPos z, AlphaMode mode) const
29
29
  {
30
30
  DrawOp op;
31
- op.renderState.texName = texName();
31
+ op.renderState.texture = texture;
32
32
  op.renderState.mode = mode;
33
33
 
34
34
  reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
@@ -301,18 +301,18 @@ namespace Gosu
301
301
 
302
302
  Gosu::Bitmap Gosu::createText(const wstring& text,
303
303
  const wstring& fontName, unsigned fontHeight, int lineSpacing,
304
- unsigned maxWidth, TextAlign align, unsigned fontFlags)
304
+ unsigned width, TextAlign align, unsigned fontFlags)
305
305
  {
306
306
  if (lineSpacing <= -static_cast<int>(fontHeight))
307
307
  throw logic_error("negative line spacing of more than line height impossible");
308
308
 
309
309
  FormattedString fs(text.c_str(), fontFlags);
310
310
  if (fs.length() == 0)
311
- return Bitmap(maxWidth, fontHeight);
311
+ return Bitmap(width, fontHeight);
312
312
 
313
313
  // Set up the builder object which will manage all the drawing and
314
314
  // conversions for us.
315
- TextBlockBuilder builder(fontName, fontHeight, lineSpacing, maxWidth, align);
315
+ TextBlockBuilder builder(fontName, fontHeight, lineSpacing, width, align);
316
316
 
317
317
  // Let the process* functions draw everything.
318
318
  processText(builder, fs);
@@ -182,6 +182,7 @@
182
182
 
183
183
  namespace Gosu {
184
184
  void enableUndocumentedRetrofication() { extern bool undocumentedRetrofication; undocumentedRetrofication = true; }
185
+ void releaseAllOpenALResources();
185
186
  void register_entity(const std::wstring& name, Gosu::Image* image) { registerEntity(name, image->getData().toBitmap()); }
186
187
  }
187
188
 
@@ -364,9 +365,12 @@ namespace Gosu
364
365
 
365
366
  %constant unsigned MAX_TEXTURE_SIZE = Gosu::MAX_TEXTURE_SIZE;
366
367
 
368
+ %rename("_release_all_openal_resources") releaseAllOpenALResources;
369
+
367
370
  namespace Gosu {
368
371
  std::string language();
369
372
  void enableUndocumentedRetrofication();
373
+ void releaseAllOpenALResources();
370
374
  void register_entity(const std::wstring& name, Gosu::Image* image);
371
375
  }
372
376
 
@@ -552,9 +556,9 @@ namespace Gosu {
552
556
  %newobject fromText7;
553
557
  static Gosu::Image* fromText7(Gosu::Window& window, const std::wstring& text,
554
558
  const std::wstring& fontName, unsigned fontHeight,
555
- int lineSpacing, unsigned maxWidth, TextAlign align)
559
+ int lineSpacing, unsigned width, TextAlign align)
556
560
  {
557
- Gosu::Bitmap bmp = Gosu::createText(text, fontName, fontHeight, lineSpacing, maxWidth, align);
561
+ Gosu::Bitmap bmp = Gosu::createText(text, fontName, fontHeight, lineSpacing, width, align);
558
562
  return new Gosu::Image(window.graphics(), bmp);
559
563
  }
560
564
  static std::vector<Gosu::Image*> loadTiles(Gosu::Window& window,
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 2.0.4
3
+ * Version 2.0.7
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 0x020004
2194
+ #define SWIGVERSION 0x020007
2195
2195
  #define SWIG_VERSION SWIGVERSION
2196
2196
 
2197
2197
 
@@ -2232,6 +2232,7 @@ static VALUE mGosu;
2232
2232
 
2233
2233
  namespace Gosu {
2234
2234
  void enableUndocumentedRetrofication() { extern bool undocumentedRetrofication; undocumentedRetrofication = true; }
2235
+ void releaseAllOpenALResources();
2235
2236
  void register_entity(const std::wstring& name, Gosu::Image* image) { registerEntity(name, image->getData().toBitmap()); }
2236
2237
  }
2237
2238
 
@@ -2431,7 +2432,7 @@ SWIG_ruby_failed(void)
2431
2432
  }
2432
2433
 
2433
2434
 
2434
- /*@SWIG:/usr/local/Cellar/swig/2.0.4/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2435
+ /*@SWIG:/usr/local/Cellar/swig/2.0.7/share/swig/2.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2435
2436
  SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
2436
2437
  {
2437
2438
  VALUE obj = args[0];
@@ -2473,7 +2474,7 @@ SWIG_From_unsigned_SS_int (unsigned int value)
2473
2474
  #include <string>
2474
2475
 
2475
2476
 
2476
- /*@SWIG:/usr/local/Cellar/swig/2.0.4/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2477
+ /*@SWIG:/usr/local/Cellar/swig/2.0.7/share/swig/2.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2477
2478
  SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
2478
2479
  {
2479
2480
  VALUE obj = args[0];
@@ -2573,7 +2574,7 @@ SWIG_From_bool (bool value)
2573
2574
  }
2574
2575
 
2575
2576
 
2576
- /*@SWIG:/usr/local/Cellar/swig/2.0.4/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2577
+ /*@SWIG:/usr/local/Cellar/swig/2.0.7/share/swig/2.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2577
2578
  SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
2578
2579
  {
2579
2580
  VALUE obj = args[0];
@@ -2699,8 +2700,8 @@ SWIGINTERN Gosu::Image *Gosu_Image_fromText4(Gosu::Window &window,std::wstring c
2699
2700
  Gosu::Bitmap bmp = Gosu::createText(text, fontName, fontHeight);
2700
2701
  return new Gosu::Image(window.graphics(), bmp);
2701
2702
  }
2702
- SWIGINTERN Gosu::Image *Gosu_Image_fromText7(Gosu::Window &window,std::wstring const &text,std::wstring const &fontName,unsigned int fontHeight,int lineSpacing,unsigned int maxWidth,Gosu::TextAlign align){
2703
- Gosu::Bitmap bmp = Gosu::createText(text, fontName, fontHeight, lineSpacing, maxWidth, align);
2703
+ SWIGINTERN Gosu::Image *Gosu_Image_fromText7(Gosu::Window &window,std::wstring const &text,std::wstring const &fontName,unsigned int fontHeight,int lineSpacing,unsigned int width,Gosu::TextAlign align){
2704
+ Gosu::Bitmap bmp = Gosu::createText(text, fontName, fontHeight, lineSpacing, width, align);
2704
2705
  return new Gosu::Image(window.graphics(), bmp);
2705
2706
  }
2706
2707
  SWIGINTERN std::vector< Gosu::Image * > Gosu_Image_loadTiles(Gosu::Window &window,VALUE source,int tileWidth,int tileHeight,bool tileable){
@@ -3723,6 +3724,24 @@ fail:
3723
3724
  }
3724
3725
 
3725
3726
 
3727
+ SWIGINTERN VALUE
3728
+ _wrap__release_all_openal_resources(int argc, VALUE *argv, VALUE self) {
3729
+ if ((argc < 0) || (argc > 0)) {
3730
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3731
+ }
3732
+ {
3733
+ try {
3734
+ Gosu::releaseAllOpenALResources();
3735
+ } catch (const std::exception& e) {
3736
+ SWIG_exception(SWIG_RuntimeError, e.what());
3737
+ }
3738
+ }
3739
+ return Qnil;
3740
+ fail:
3741
+ return Qnil;
3742
+ }
3743
+
3744
+
3726
3745
  SWIGINTERN VALUE
3727
3746
  _wrap_register_entity(int argc, VALUE *argv, VALUE self) {
3728
3747
  std::wstring *arg1 = 0 ;
@@ -3757,7 +3776,7 @@ fail:
3757
3776
  }
3758
3777
 
3759
3778
 
3760
- swig_class SwigClassColor;
3779
+ static swig_class SwigClassColor;
3761
3780
 
3762
3781
  SWIGINTERN VALUE
3763
3782
  _wrap_new_Color__SWIG_0(int argc, VALUE *argv, VALUE self) {
@@ -5258,7 +5277,7 @@ _wrap_cyan_get(VALUE self) {
5258
5277
  }
5259
5278
 
5260
5279
 
5261
- swig_class SwigClassFont;
5280
+ static swig_class SwigClassFont;
5262
5281
 
5263
5282
  SWIGINTERN VALUE
5264
5283
  _wrap_Font_name(int argc, VALUE *argv, VALUE self) {
@@ -5882,7 +5901,7 @@ free_Gosu_Font(Gosu::Font *arg1) {
5882
5901
  delete arg1;
5883
5902
  }
5884
5903
 
5885
- swig_class SwigClassGLTexInfo;
5904
+ static swig_class SwigClassGLTexInfo;
5886
5905
 
5887
5906
  SWIGINTERN VALUE
5888
5907
  _wrap_GLTexInfo_tex_name_set(int argc, VALUE *argv, VALUE self) {
@@ -6195,7 +6214,7 @@ free_Gosu_GLTexInfo(Gosu::GLTexInfo *arg1) {
6195
6214
  delete arg1;
6196
6215
  }
6197
6216
 
6198
- swig_class SwigClassImage;
6217
+ static swig_class SwigClassImage;
6199
6218
 
6200
6219
  SWIGINTERN VALUE
6201
6220
  _wrap_Image_width(int argc, VALUE *argv, VALUE self) {
@@ -7529,7 +7548,7 @@ fail:
7529
7548
  }
7530
7549
 
7531
7550
 
7532
- swig_class SwigClassSampleInstance;
7551
+ static swig_class SwigClassSampleInstance;
7533
7552
 
7534
7553
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
7535
7554
  SWIGINTERN VALUE
@@ -7839,7 +7858,7 @@ free_Gosu_SampleInstance(Gosu::SampleInstance *arg1) {
7839
7858
  delete arg1;
7840
7859
  }
7841
7860
 
7842
- swig_class SwigClassSample;
7861
+ static swig_class SwigClassSample;
7843
7862
 
7844
7863
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
7845
7864
  SWIGINTERN VALUE
@@ -8022,7 +8041,7 @@ free_Gosu_Sample(Gosu::Sample *arg1) {
8022
8041
  delete arg1;
8023
8042
  }
8024
8043
 
8025
- swig_class SwigClassSong;
8044
+ static swig_class SwigClassSong;
8026
8045
 
8027
8046
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
8028
8047
  SWIGINTERN VALUE
@@ -8333,7 +8352,7 @@ fail:
8333
8352
  }
8334
8353
 
8335
8354
 
8336
- swig_class SwigClassTextInput;
8355
+ static swig_class SwigClassTextInput;
8337
8356
 
8338
8357
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
8339
8358
  SWIGINTERN VALUE
@@ -8664,7 +8683,7 @@ fail:
8664
8683
  }
8665
8684
 
8666
8685
 
8667
- swig_class SwigClassWindow;
8686
+ static swig_class SwigClassWindow;
8668
8687
 
8669
8688
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
8670
8689
  SWIGINTERN VALUE
@@ -11228,8 +11247,8 @@ SWIGEXPORT void Init_gosu(void) {
11228
11247
  SWIG_RubyInitializeTrackings();
11229
11248
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
11230
11249
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(7)));
11231
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(43)));
11232
- rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.43"));
11250
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(44)));
11251
+ rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.44"));
11233
11252
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
11234
11253
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
11235
11254
  rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
@@ -11249,6 +11268,7 @@ SWIGEXPORT void Init_gosu(void) {
11249
11268
  rb_define_const(mGosu, "MAX_TEXTURE_SIZE", SWIG_From_unsigned_SS_int(static_cast< unsigned int >(Gosu::MAX_TEXTURE_SIZE)));
11250
11269
  rb_define_module_function(mGosu, "language", VALUEFUNC(_wrap_language), -1);
11251
11270
  rb_define_module_function(mGosu, "enable_undocumented_retrofication", VALUEFUNC(_wrap_enable_undocumented_retrofication), -1);
11271
+ rb_define_module_function(mGosu, "_release_all_openal_resources", VALUEFUNC(_wrap__release_all_openal_resources), -1);
11252
11272
  rb_define_module_function(mGosu, "register_entity", VALUEFUNC(_wrap_register_entity), -1);
11253
11273
 
11254
11274
  SwigClassColor.klass = rb_define_class_under(mGosu, "Color", rb_cObject);
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 2.0.4
3
+ * Version 2.0.7
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,6 +9,7 @@
9
9
  namespace Gosu { typedef SOCKET SocketHandle; }
10
10
  typedef int socklen_t;
11
11
  #else
12
+ #include <unistd.h>
12
13
  #include <sys/errno.h>
13
14
  #include <sys/socket.h>
14
15
  #include <netinet/in.h>
@@ -9,10 +9,16 @@ void Gosu::sleep(unsigned milliseconds)
9
9
 
10
10
  unsigned long Gosu::milliseconds()
11
11
  {
12
+ static unsigned long start = 0;
13
+
12
14
  timeval tp;
13
15
  gettimeofday(&tp, NULL);
16
+
17
+ if (!start)
18
+ start = tp.tv_usec / 1000UL + tp.tv_sec * 1000UL;
19
+
14
20
  // Truncate to 2^30, C++ users shouldn't mind and Ruby users will
15
21
  // have a happy GC on 32-bit systems.
16
22
  // No, don't ask why this is an unsigned long then :)
17
- return (tp.tv_usec / 1000UL + tp.tv_sec * 1000UL) & 0x1fffffff;
23
+ return (tp.tv_usec / 1000UL + tp.tv_sec * 1000UL - start) & 0x1fffffff;
18
24
  }
@@ -17,15 +17,16 @@ namespace
17
17
 
18
18
  unsigned long Gosu::milliseconds()
19
19
  {
20
- static bool init = false;
21
- if (!init)
20
+ static unsigned long start = 0;
21
+
22
+ if (!start)
22
23
  {
23
24
  if (::timeBeginPeriod(1) != TIMERR_NOERROR)
24
25
  std::atexit(resetTGT);
25
- init = true;
26
+ start = ::timeGetTime();
26
27
  }
27
28
  // Truncate to 2^30, C++ users shouldn't mind and Ruby users will
28
29
  // have a happy GC on 32-bit systems.
29
30
  // No, don't ask why this is an unsigned long then :)
30
- return ::timeGetTime() & 0x1fffffff;
31
+ return (::timeGetTime() - start) & 0x1fffffff;
31
32
  }
@@ -72,4 +72,7 @@ class Gosu::Window
72
72
  def char_to_button_id(ch)
73
73
  self.class.char_to_button_id(ch)
74
74
  end
75
- end
75
+ end
76
+
77
+ # Release OpenAL resources during Ruby's shutdown, not Gosu's.
78
+ at_exit { Gosu::_release_all_openal_resources }
@@ -93,7 +93,6 @@ else
93
93
  pkg_config("vorbisfile")
94
94
  pkg_config("openal")
95
95
  pkg_config("sndfile")
96
- pkg_config("xinerama")
97
96
 
98
97
  have_header('SDL_ttf.h') if have_library('SDL_ttf', 'TTF_RenderUTF8_Blended')
99
98
  have_header('FreeImage.h') if have_library('freeimage', 'FreeImage_ConvertFromRawBits')
@@ -0,0 +1,5 @@
1
+ = Drawing with Colors
2
+
3
+ Almost all image drawing functions accept modulation colors. The colors of all pixels on the source image will be multiplied with these colors, where a channel value of 255 corresponds to the maximum value of 1.0. This means modulation colors can be used only to reduce particular channels of an image.
4
+
5
+ The most obvious use of this is to supply a color with an alpha value less than 255 so the image will drawn transparently, but you can also use this to darken images or to draw them in a different hue (which works best if the original image is mostly grayscale).
@@ -0,0 +1,5 @@
1
+ = Order of Corners
2
+
3
+ In all functions that expect arguments for all four corners of a rectangle or quadrilateral, you can either pass clockwise coordinates, or coordinates in the following order (a Z shape):
4
+
5
+ http://www.libgosu.org/wiki_images/corner_indices.png
@@ -0,0 +1,11 @@
1
+ = Tileability
2
+
3
+ Functions related to image creation accept a boolean "tileable" argument. This is a consequence of using 3D hardware acceleration. Try to notice the subtle difference between these two, overstretched images:
4
+
5
+ http://www.libgosu.org/wiki_images/hard_borders.png
6
+
7
+ When you draw an image with stretching factors other than 1.0 (10.0 in this case) or at odd coordinates, it will become interpolated—which, in general, is much better than getting all pixel-y.
8
+
9
+ But take a look at the image's borders. The image of the left girl was created with tileable set to 'false' (the default) and the borders fade out. The image of the right girl, which was created with tileable set to 'true, does not fade out at all, but just ends on its borders.
10
+
11
+ While most images should not be tileable, you should always pass true for map tiles.
@@ -0,0 +1,5 @@
1
+ = Z-Ordering
2
+
3
+ All drawing operations in Gosu accept a floating-point value called "z" (technically, a double). Things drawn with a higher z position will be drawn over those with a lower one. If two things have the same z position, they will be drawn in the order the drawing functions were called.
4
+
5
+ If you do not wish to use z ordering, just pass the same constant all the time.
@@ -0,0 +1,596 @@
1
+ # Version string of the form "0.1.2" or "0.1.2.3".
2
+ GOSU_VERSION = :a_string
3
+ # First component of the version.
4
+ GOSU_MAJOR_VERSION = :a_fixnum
5
+ # Second component of the version.
6
+ GOSU_MINOR_VERSION = :a_fixnum
7
+ # Third component of the version.
8
+ GOSU_POINT_VERSION = :a_fixnum
9
+ # A long block of legal copy that your game is obliged to display somewhere.
10
+ GOSU_COPYRIGHT_NOTICE = :a_string
11
+
12
+ module Gosu
13
+ Kb0 = :implementation_defined
14
+ Kb1 = :implementation_defined
15
+ Kb2 = :implementation_defined
16
+ Kb3 = :implementation_defined
17
+ Kb4 = :implementation_defined
18
+ Kb5 = :implementation_defined
19
+ Kb6 = :implementation_defined
20
+ Kb7 = :implementation_defined
21
+ Kb8 = :implementation_defined
22
+ Kb9 = :implementation_defined
23
+ KbA = :implementation_defined
24
+ KbB = :implementation_defined
25
+ KbC = :implementation_defined
26
+ KbD = :implementation_defined
27
+ KbE = :implementation_defined
28
+ KbF = :implementation_defined
29
+ KbG = :implementation_defined
30
+ KbH = :implementation_defined
31
+ KbI = :implementation_defined
32
+ KbJ = :implementation_defined
33
+ KbK = :implementation_defined
34
+ KbL = :implementation_defined
35
+ KbM = :implementation_defined
36
+ KbN = :implementation_defined
37
+ KbO = :implementation_defined
38
+ KbP = :implementation_defined
39
+ KbQ = :implementation_defined
40
+ KbR = :implementation_defined
41
+ KbS = :implementation_defined
42
+ KbT = :implementation_defined
43
+ KbU = :implementation_defined
44
+ KbV = :implementation_defined
45
+ KbW = :implementation_defined
46
+ KbX = :implementation_defined
47
+ KbY = :implementation_defined
48
+ KbZ = :implementation_defined
49
+ KbBackspace = :implementation_defined
50
+ KbDelete = :implementation_defined
51
+ KbDown = :implementation_defined
52
+ KbEnd = :implementation_defined
53
+ # On Numpad
54
+ KbEnter = :implementation_defined
55
+ KbEscape = :implementation_defined
56
+ KbF1 = :implementation_defined
57
+ KbF10 = :implementation_defined
58
+ KbF11 = :implementation_defined
59
+ KbF12 = :implementation_defined
60
+ KbF2 = :implementation_defined
61
+ KbF3 = :implementation_defined
62
+ KbF4 = :implementation_defined
63
+ KbF5 = :implementation_defined
64
+ KbF6 = :implementation_defined
65
+ KbF7 = :implementation_defined
66
+ KbF8 = :implementation_defined
67
+ KbF9 = :implementation_defined
68
+ KbHome = :implementation_defined
69
+ KbInsert = :implementation_defined
70
+ KbLeft = :implementation_defined
71
+ KbLeftAlt = :implementation_defined
72
+ KbLeftControl = :implementation_defined
73
+ KbLeftShift = :implementation_defined
74
+ KbNumpad0 = :implementation_defined
75
+ KbNumpad1 = :implementation_defined
76
+ KbNumpad2 = :implementation_defined
77
+ KbNumpad3 = :implementation_defined
78
+ KbNumpad4 = :implementation_defined
79
+ KbNumpad5 = :implementation_defined
80
+ KbNumpad6 = :implementation_defined
81
+ KbNumpad7 = :implementation_defined
82
+ KbNumpad8 = :implementation_defined
83
+ KbNumpad9 = :implementation_defined
84
+ KbNumpadAdd = :implementation_defined
85
+ KbNumpadDivide = :implementation_defined
86
+ KbNumpadMultiply = :implementation_defined
87
+ KbNumpadSubtract = :implementation_defined
88
+ KbPageDown = :implementation_defined
89
+ KbPageUp = :implementation_defined
90
+ # Above the right shift key
91
+ KbReturn = :implementation_defined
92
+ KbRight = :implementation_defined
93
+ KbRightAlt = :implementation_defined
94
+ KbRightControl = :implementation_defined
95
+ KbRightShift = :implementation_defined
96
+ KbSpace = :implementation_defined
97
+ KbTab = :implementation_defined
98
+ KbUp = :implementation_defined
99
+ MsLeft = :implementation_defined
100
+ MsMiddle = :implementation_defined
101
+ MsRight = :implementation_defined
102
+ MsWheelDown = :implementation_defined
103
+ MsWheelUp = :implementation_defined
104
+ GpButton0 = :implementation_defined
105
+ GpButton1 = :implementation_defined
106
+ GpButton10 = :implementation_defined
107
+ GpButton11 = :implementation_defined
108
+ GpButton12 = :implementation_defined
109
+ GpButton13 = :implementation_defined
110
+ GpButton14 = :implementation_defined
111
+ GpButton15 = :implementation_defined
112
+ GpButton2 = :implementation_defined
113
+ GpButton3 = :implementation_defined
114
+ GpButton4 = :implementation_defined
115
+ GpButton5 = :implementation_defined
116
+ GpButton6 = :implementation_defined
117
+ GpButton7 = :implementation_defined
118
+ GpButton8 = :implementation_defined
119
+ GpButton9 = :implementation_defined
120
+ GpDown = :implementation_defined
121
+ GpLeft = :implementation_defined
122
+ GpRight = :implementation_defined
123
+ GpUp = :implementation_defined
124
+
125
+ # Represents an ARGB color value with 8 bits for each channel. Can be
126
+ # replaced by literals of the form 0xaarrggbb in all of Gosu.
127
+ class Color
128
+ attr_accessor :alpha, :red, :green, :blue, :hue, :saturation, :value
129
+
130
+ # a:: Integer from 0..255
131
+ # r:: Integer from 0..255
132
+ # g:: Integer from 0..255
133
+ # b:: Integer from 0..255
134
+ def initialize(a, r, g, b); end
135
+ # Initializes a color from an 0xrrggbbaa integer.
136
+ def initialize(argb); end
137
+
138
+ def dup; end
139
+
140
+ # Same as the constructor, but with an explicit order.
141
+ def self.rgba(r, g, b, a); end
142
+
143
+ # Initializes a color from an 0xrrggbbaa integer.
144
+ def self.rgba(rgba); end
145
+
146
+ # Same as the constructor, but with an explicit order.
147
+ def self.argb(a, r, g, b); end
148
+
149
+ # Initializes a color from an 0xrrggbbaa integer.
150
+ def self.argb(argb); end
151
+
152
+ # Converts a HSV triple into a color. Same as from_ahsv with alpha set to 255.
153
+ # h:: Integer from 0..360
154
+ # s:: Float from 0..1
155
+ # v:: Float from 0..1.
156
+ def self.from_hsv(h, s, v); end
157
+
158
+ # Converts a HSV triple into a color, with a given alpha.
159
+ # a:: Integer from 0..255
160
+ # h:: Integer from 0..360
161
+ # s:: Float from 0..1
162
+ # v:: Float from 0..1.
163
+ def self.from_ahsv(a, h, s, v); end
164
+
165
+ # 32-bit unsigned value for use with OpenGL ('RGBA' octet in memory).
166
+ def gl; end
167
+
168
+ # constant
169
+ NONE = Gosu::Color.argb(0x00000000)
170
+ # constant
171
+ BLACK = Gosu::Color.argb(0xff000000)
172
+ # constant
173
+ GRAY = Gosu::Color.argb(0xff808080)
174
+ # constant
175
+ WHITE = Gosu::Color.argb(0xffffffff)
176
+ # constant
177
+ AQUA = Gosu::Color.argb(0xff00ffff)
178
+ # constant
179
+ RED = Gosu::Color.argb(0xffff0000)
180
+ # constant
181
+ GREEN = Gosu::Color.argb(0xff00ff00)
182
+ # constant
183
+ BLUE = Gosu::Color.argb(0xff0000ff)
184
+ # constant
185
+ YELLOW = Gosu::Color.argb(0xffffff00)
186
+ # constant
187
+ FUCHSIA = Gosu::Color.argb(0xffff00ff)
188
+ # constant
189
+ CYAN = Gosu::Color.argb(0xff00ffff)
190
+ end
191
+
192
+ # A font can be used to draw text on a Window object very flexibly.
193
+ # Fonts are ideal for small texts that change regularly. For large,
194
+ # static texts you should use Image#from_text.
195
+ class Font
196
+ attr_reader :name, :height
197
+
198
+ # font_name:: Name of a system font, or a filename to a TTF file (must contain '/').
199
+ # height:: Height of the font, in pixels.
200
+ def initialize(window, font_name, height); end
201
+
202
+ # Sets the image to be used for a certain character. Must not be called twice for the same character, or after the character has been drawn already.
203
+ def []=(character, image); end
204
+
205
+ # Draws text so the top left corner of the text is at (x; y).
206
+ #
207
+ # Characters are created internally as needed.
208
+ def draw(text, x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
209
+
210
+ # Draws text at a position relative to (x; y).
211
+ # rel_x:: Determines where the text is drawn horizontally. If relX is 0.0, the text will be to the right of x, if it is 1.0, the text will be to the left of x, if it is 0.5, it will be centered on x. Of course, all real numbers are possible values.
212
+ # rel_y:: See rel_x.
213
+ def draw_rel(text, x, y, z, rel_x, rel_y, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
214
+
215
+ # Returns the width, in pixels, the given text would occupy if drawn.
216
+ def text_width(text, factor_x=1); end
217
+
218
+ # Analogous to draw, but rotates the text by a given angle.
219
+ # @deprecated Use a combination of Window#rotate and Font#draw instead.
220
+ def draw_rot(text, x, y, z, angle, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
221
+ end
222
+
223
+ # Provides functionality for drawing rectangular images.
224
+ class Image
225
+ attr_reader :width, :height
226
+
227
+ # Loads an image from a given filename that can be drawn onto the
228
+ # given window. See the Gosu wiki for a list of supported formats.
229
+ #
230
+ # A color key of #ff00ff is automatically applied to BMP type images.
231
+ def initialize(window, filename_or_rmagick_image, tileable); end
232
+
233
+ # Loads an image from a given filename that can be drawn onto the
234
+ # given window. See the Gosu wiki for a list of supported formats.
235
+ #
236
+ # A color key of #ff00ff is automatically applied to BMP type images.
237
+ #
238
+ # This constructor only loads a sub-rectangle of the given file. Because
239
+ # every call of this constructor will open the image again, it is preferable
240
+ # to use Image#load_tiles when possible.
241
+ def initialize(window, filename_or_rmagick_image, tileable, src_x, src_y, src_width, src_height); end
242
+
243
+ # Draws the image so its upper left corner is at (x; y).
244
+ def draw(x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
245
+
246
+ # center_x:: Relative horizontal position of the rotation center on the image. 0 is the left border, 1 is the right border, 0.5 is the center (and default)
247
+ # center_y:: See center_x.
248
+ def draw_rot(x, y, z, angle, center_x=0.5, center_y=0.5, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
249
+
250
+ # Like Window#draw_quad, but with this texture instead of colors. Can be used to implement advanced, non-rectangular drawing techniques and takes four points and the modulation color at each of them.
251
+ # The points can be in clockwise order, or in a Z shape, starting at the top left.
252
+ def draw_as_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z, mode=:default); end
253
+
254
+ # Creates an Image containing a line of text.
255
+ #
256
+ # The text is always rendered in white. If you want to draw it in a
257
+ # different color, just modulate it by the target color.
258
+ # font_name:: Name of a system font, or a filename to a TTF file (must contain '/').
259
+ # font_height:: Height of the font in pixels.
260
+ def self.from_text(window, text, font_name, font_height); end
261
+
262
+ # Creates an Image that is filled with the text given to the function.
263
+ #
264
+ # The text may contain line breaks.
265
+ #
266
+ # The text is always rendered in white. If you want to draw it in a
267
+ # different color, just modulate it by the target color.
268
+ # font_name:: Name of a system font, or a filename to a TTF file (must contain '/').
269
+ # font_height:: Height of the font in pixels.
270
+ # line_spacing:: Spacing between two lines of text in pixels.
271
+ # max_width:: Width of the bitmap that will be returned. Text will be split into multiple lines to avoid drawing over the right border. When a single word is too long, it will be truncated.
272
+ # align:: One of :left, :right, :center or :justify.
273
+ def self.from_text(window, text, font_name, font_height, line_spacing, max_width, align); end
274
+
275
+ # Convenience function that splits an image file into an array of small rectangles and
276
+ # creates images from these. Returns the Array containing Image instances.
277
+ #
278
+ # A color key of #ff00ff is automatically applied to BMP type images.
279
+ #
280
+ # tile_width:: If positive, specifies the width of one tile in pixels. If negative, the bitmap is divided into -tile_width rows.
281
+ # tile_height:: See tile_width.
282
+ def self.load_tiles(window, filename_or_rmagick_image, tile_width, tile_height, tileable); end
283
+
284
+ # See examples/OpenGLIntegration.rb.
285
+ def gl_tex_info; end
286
+
287
+ # Returns the associated texture contents as binary string of RGBA values.
288
+ # Useful for use with RMagick (Magick::Image.from_blob).
289
+ def to_blob; end
290
+
291
+ # Overwrites all or parts of the Image. x and y can be negative or otherwise out of
292
+ # bounds, the incoming image data is clipped to the current image size.
293
+ # This can be used to e.g. overwrite parts of a landscape.
294
+ def insert(filename_or_rmagick_image, x, y); end
295
+
296
+ # Saves the texture contents as an image file. Useful, for example, to
297
+ # pre-render text on a development machine with proper fonts installed.
298
+ # The file format is determined from the file extension. See the Gosu
299
+ # wiki for a list of portably supported formats.
300
+ def save(filename); end
301
+ end
302
+
303
+ # A sample is a short sound that is completely loaded in memory, can be
304
+ # played multiple times at once and offers very flexible playback
305
+ # parameters. Use samples for everything that's not music.
306
+ class Sample
307
+ def initialize(window, filename); end
308
+
309
+ # Plays the sample without panning.
310
+ #
311
+ # Returns a SampleInstance.
312
+ # volume:: Can be anything from 0.0 (silence) to 1.0 (full volume).
313
+ # speed:: Playback speed is only limited by the underlying audio library, and can accept very high or low values. Use 1.0 for normal playback speed.
314
+ def play(vol=1, speed=1, looping=false); end
315
+
316
+ # Plays the sample with panning. Even if pan is 0.0, the sample will
317
+ # not be as loud as if it were played by calling play() due to the
318
+ # way the panning works.
319
+ #
320
+ # Returns a SampleInstance.
321
+ # volume:: Can be anything from 0.0 (silence) to 1.0 (full volume).
322
+ # speed:: Playback speed is only limited by the underlying audio library, and can accept very high or low values. Use 1.0 for normal playback speed.
323
+ def play_pan(pan=0, vol=1, speed=1, looping=false); end
324
+ end
325
+
326
+ # An instance of a Sample playing. Can be used to stop sounds dynamically,
327
+ # or to check if they are finished.
328
+ # It is recommended that you throw away sample instances if possible,
329
+ # as they could accidentally refer to other sounds being played after
330
+ # a very long time has passed.
331
+ class SampleInstance
332
+ attr_writer :volume
333
+ attr_writer :speed
334
+ attr_writer :pan
335
+
336
+ # Stops this instance of a sound being played. Calling this twice, or too late, does not do any harm. You can nil out the reference to the instance afterwards as it will be useless.
337
+ def stop; end
338
+ # Pauses this instance to be resumed afterwards. It will still keep a channel filled while paused.
339
+ def pause; end
340
+ def paused?; end
341
+ def resume; end
342
+ def playing?; end
343
+ end
344
+
345
+ # Songs are less flexible than samples in that they can only be played
346
+ # one at a time and without panning or speed parameters.
347
+ class Song
348
+ # Returns the song currently being played or paused, or nil if
349
+ # no song has been played yet or the last song has finished
350
+ # playing.
351
+ def self.current_song; end
352
+
353
+ attr_accessor :volume
354
+
355
+ def initialize(window, filename); end
356
+
357
+ # Starts or resumes playback of the song. This will stop all other
358
+ # songs and set the current song to this object.
359
+ def play(looping=false); end
360
+
361
+ # Pauses playback of the song. It is not considered being played.
362
+ # current_song will stay the same.
363
+ def pause; end
364
+
365
+ # Returns true if the song is the current song, but in paused
366
+ # mode.
367
+ def paused?; end
368
+
369
+ # Stops playback of this song if it is currently played or paused.
370
+ # Afterwards, current_song will return 0.
371
+ def stop; end
372
+
373
+ # Returns true if the song is currently playing.
374
+ def playing?; end
375
+ end
376
+
377
+ # TextInput instances are invisible objects that build a text string from input,
378
+ # using the current operating system's keyboard layout.
379
+ #
380
+ # At its most basic form, you only need to create a new TextInput instance and
381
+ # pass it to your window via text_input=. Until you call this function again,
382
+ # passing nil, the TextInput object will build a text that can be accessed via
383
+ # TextInput#text.
384
+ #
385
+ # A TextInput object is purely abstract, though; drawing the input field is left
386
+ # to the user. As with most of Gosu, how this is handled is completely left open.
387
+ #
388
+ # TextInput only aims to provide enough code for your own GUIs to build upon.
389
+ class TextInput
390
+ attr_accessor :text
391
+ attr_accessor :caret_pos
392
+ attr_accessor :selection_start
393
+
394
+ # Overridable filter that is applied to all new text that is entered.
395
+ # Allows for context-sensitive filtering/extending/... of the text.
396
+ # The text will be inserted at caretPos afterwards.
397
+ def filter text_in
398
+ text_in
399
+ end
400
+ end
401
+
402
+ # Main class that serves as the foundation of a standard
403
+ # Gosu application. Manages initialization of all of Gosu's core components
404
+ # and provides timing functionality.
405
+ #
406
+ # Note that all coordinates, even the mouse position, are in client
407
+ # coordinates relative to the window. This means that the mouse position
408
+ # can be negative or larger than the window size.
409
+ #
410
+ # Note that you should really only use one instance of this class at the same time. This may or may not change later.
411
+ #
412
+ # Right now, having two or more windows and loading samples or songs on both of them will result in an exception.
413
+ class Window
414
+ attr_accessor :caption
415
+ attr_accessor :mouse_x
416
+ attr_accessor :mouse_y
417
+ attr_accessor :text_input
418
+ attr_reader :width, :height
419
+ attr_reader :fullscreen?
420
+ attr_reader :update_interval
421
+
422
+ # update_interval:: Interval in milliseconds between two calls
423
+ # to the update member function. The default means the game will run
424
+ # at 60 FPS, which is ideal on standard 60 Hz TFT screens.
425
+ def initialize(width, height, fullscreen, update_interval=16.666666); end
426
+
427
+ # Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
428
+ def show; end
429
+
430
+ # Tells the window to end the current show loop as soon as possible.
431
+ def close; end
432
+
433
+ # Called every update_interval milliseconds while the window is being
434
+ # shown. Your application's main game logic goes here.
435
+ def update; end
436
+
437
+ # Called after every update and when the OS wants the window to
438
+ # repaint itself. Your application's rendering code goes here.
439
+ def draw; end
440
+
441
+ # Can be overriden to give the game a chance to say no to being redrawn.
442
+ # This is not a definitive answer. The operating system can still cause
443
+ # redraws for one reason or another.
444
+ #
445
+ # By default, the window is redrawn all the time (i.e. Window#needs_redraw?
446
+ # always returns true.)
447
+ def needs_redraw?; end
448
+
449
+ # Can be overriden to show the system cursor when necessary, e.g. in level
450
+ # editors or other situations where introducing a custom cursor is not
451
+ # desired.
452
+ def needs_cursor?; end
453
+
454
+ # Called before update when the user pressed a button while the
455
+ # window had the focus.
456
+ def button_down(id); end
457
+ # Same as buttonDown. Called then the user released a button.
458
+ def button_up(id); end
459
+
460
+ # Returns true if a button is currently pressed. Updated every tick.
461
+ def button_down?(id); end
462
+
463
+ # Draws a line from one point to another (last pixel exclusive).
464
+ # Note: OpenGL lines are not reliable at all and may have a missing pixel at the start
465
+ # or end point. Please only use this for debugging purposes. Otherwise, use a quad or
466
+ # image to simulate lines, or contribute a better draw_line to Gosu.
467
+ def draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default); end
468
+
469
+ def draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default); end
470
+
471
+ # Draws a rectangle (two triangles) with given corners and corresponding
472
+ # colors.
473
+ # The points can be in clockwise order, or in a Z shape.
474
+ def draw_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z=0, mode=:default); end
475
+
476
+ # Flushes all drawing operations to OpenGL so that Z-ordering can start anew. This
477
+ # is useful when drawing several parts of code on top of each other that use conflicting
478
+ # z positions.
479
+ def flush; end
480
+
481
+ # For custom OpenGL calls. Executes the given block in a clean OpenGL environment.
482
+ # Use the ruby-opengl gem to access OpenGL function (if you manage to get it to work).
483
+ # IF no z position is given, it will execute the given block immediately, otherwise,
484
+ # the code will be scheduled to be called between Gosu drawing operations.
485
+ #
486
+ # Note: You cannot call Gosu rendering functions within this block, and you can only
487
+ # call the gl function in the call tree of Window#draw.
488
+ #
489
+ # See examples/OpenGLIntegration.rb for an example.
490
+ def gl(z=nil, &custom_gl_code); end
491
+
492
+ # Limits the drawing area to a given rectangle while evaluating the code inside of the block.
493
+ def clip_to(x, y, w, h, &rendering_code); end
494
+
495
+ # Returns a Gosu::Image that containes everything rendered within the given block. It can be
496
+ # used to optimize rendering of many static images, e.g. the map. There are still several
497
+ # restrictions that you will be informed about via exceptions.
498
+ #
499
+ # The returned Gosu::Image will have the width and height you pass as arguments, regardless
500
+ # of how the area you draw on. It is important to pass accurate values if you plan on using
501
+ # Gosu::Image#draw_as_quad or Gosu::Image#draw_rot with the result later.
502
+ #
503
+ # @return [Gosu::Image]
504
+ def record(width, height, &rendering_code); end
505
+
506
+ # Rotates everything drawn in the block around (around_x, around_y).
507
+ def rotate(angle, around_x=0, around_y=0, &rendering_code); end
508
+
509
+ # Scales everything drawn in the block by a factor.
510
+ def scale(factor_x, factor_y=factor_x, &rendering_code); end
511
+
512
+ # Scales everything drawn in the block by a factor for each dimension.
513
+ def scale(factor_x, factor_y, around_x, around_y, &rendering_code); end
514
+
515
+ # Moves everything drawn in the block by an offset in each dimension.
516
+ def translate(x, y, &rendering_code); end
517
+
518
+ # Applies a free-form matrix rotation to everything drawn in the block.
519
+ def transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, &rendering_code); end
520
+
521
+ # Returns the character a button usually produces, or nil. To implement real text-input
522
+ # facilities, look at the TextInput class instead.
523
+ def self.button_id_to_char(id); end
524
+
525
+ # Returns the button that has to be pressed to produce the given character, or nil.
526
+ def self.char_to_button_id(char); end
527
+
528
+ # @deprecated Use Window#mouse_x= and Window#mouse_y= instead.
529
+ def set_mouse_position(x, y); end
530
+ end
531
+
532
+ # Contains information about the underlying OpenGL texture and the u/v space used for image data.
533
+ #
534
+ # Can be retrieved from some images to use them in OpenGL operations. nil will be returned instead by images that are too large for a single texture.)
535
+ #
536
+ # See examples/OpenGLIntegration.rb.
537
+ class GLTexInfo
538
+ attr_reader :tex_name, :left, :right, :top, :bottom
539
+ end
540
+
541
+ # Returns a random double between min (inclusive) and max (exclusive).
542
+ def random(min, max); end
543
+
544
+ # Returns the horizontal distance between the origin and the point to which you would get if you moved radius pixels in the direction specified by angle.
545
+ def offset_x(angle, dist); end
546
+
547
+ # Returns the vertical distance between the origin and the point to which you would get if you moved radius pixels in the direction specified by angle.
548
+ def offset_y(angle, dist); end
549
+
550
+ # Returns the angle from point 1 to point 2 in degrees, where 0.0 means upwards. Returns 0 if both points are equal.
551
+ def angle(x1, y1, x2, y2); end
552
+
553
+ # Returns the smallest angle that can be added to angle1 to get to angle2 (can be negative if counter-clockwise movement is shorter).
554
+ def angle_diff(angle1, angle2); end
555
+
556
+ # Returns the distance between two points.
557
+ def distance(x1, y1, x2, y2); end
558
+
559
+ # Incrementing, possibly wrapping millisecond timer.
560
+ def milliseconds(); end
561
+
562
+ # Returns the name of a neutral font that is available on the current
563
+ # platform.
564
+ def default_font_name(); end
565
+
566
+ # Returns the width, in pixels, of the user's primary screen.
567
+ def screen_width(); end
568
+
569
+ # Returns the height, in pixels, of the user's primary screen.
570
+ def screen_height(); end
571
+
572
+ # Returns the user's preferred language, at the moment of calling the function. Expect return
573
+ # values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans'. You can rely only on the first two letters
574
+ # being a common language abbreviation.
575
+ def language(); end
576
+ end
577
+
578
+ # Small additions to Numeric to make it easier to integrate Gosu with
579
+ # libraries that use radians, like Chipmunk.
580
+ class ::Numeric
581
+ # Returns <tt>self * 180.0 / Math::PI + 90</tt>.
582
+ # Translates between Gosu's angle system (where 0° is at the top) and
583
+ # radians (where 0 is at the right).
584
+ def radians_to_gosu(); end
585
+
586
+ # Returns <tt>(self - 90) * Math::PI / 180.0</tt>
587
+ # Translates between Gosu's angle system (where 0° is at the top) and
588
+ # radians (where 0 is at the right).
589
+ def gosu_to_radians(); end
590
+
591
+ # Scales a degree value to radians.
592
+ def degrees_to_radians(); end
593
+
594
+ # Scales a radian value to degrees.
595
+ def radians_to_degrees(); end
596
+ end
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 85
5
- prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 43
10
- version: 0.7.43
4
+ version: 0.7.44
11
5
  platform: ruby
12
6
  authors:
13
7
  - Julian Raschke
@@ -15,7 +9,8 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2012-03-18 00:00:00 Z
12
+ date: 2012-07-16 00:00:00 +08:00
13
+ default_executable:
19
14
  dependencies: []
20
15
 
21
16
  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"
@@ -89,6 +84,11 @@ files:
89
84
  - examples/media/Space.png
90
85
  - examples/media/Star.png
91
86
  - examples/media/Starfighter.bmp
87
+ - reference/gosu.rb
88
+ - reference/Drawing_with_Colors.rdoc
89
+ - reference/Order_of_Corners.rdoc
90
+ - reference/Tileability.rdoc
91
+ - reference/Z_Ordering.rdoc
92
92
  - GosuImpl/Async.cpp
93
93
  - GosuImpl/Audio/ALChannelManagement.hpp
94
94
  - GosuImpl/Audio/AudioFile.hpp
@@ -182,6 +182,7 @@ files:
182
182
  - GosuImpl/WinUtility.cpp
183
183
  - GosuImpl/X11vroot.h
184
184
  - linux/extconf.rb
185
+ has_rdoc: true
185
186
  homepage: http://www.libgosu.org/
186
187
  licenses: []
187
188
 
@@ -198,29 +199,21 @@ rdoc_options:
198
199
  require_paths:
199
200
  - lib
200
201
  required_ruby_version: !ruby/object:Gem::Requirement
201
- none: false
202
202
  requirements:
203
203
  - - ">="
204
204
  - !ruby/object:Gem::Version
205
- hash: 51
206
- segments:
207
- - 1
208
- - 8
209
- - 2
210
205
  version: 1.8.2
206
+ version:
211
207
  required_rubygems_version: !ruby/object:Gem::Requirement
212
- none: false
213
208
  requirements:
214
209
  - - ">="
215
210
  - !ruby/object:Gem::Version
216
- hash: 3
217
- segments:
218
- - 0
219
211
  version: "0"
212
+ version:
220
213
  requirements:
221
214
  - See https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
222
215
  rubyforge_project:
223
- rubygems_version: 1.8.16
216
+ rubygems_version: 1.3.5
224
217
  signing_key:
225
218
  specification_version: 3
226
219
  summary: 2D game development library.