gosu 0.7.38 → 0.7.39

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,10 +10,11 @@ Gosu::TexChunk::TexChunk(Graphics& graphics, Transforms& transforms, DrawOpQueue
10
10
  texture(texture), x(x), y(y), w(w), h(h), padding(padding)
11
11
  {
12
12
  info.texName = texture->texName();
13
- info.left = float(x) / texture->size();
14
- info.top = float(y) / texture->size();
15
- info.right = float(x + w) / texture->size();
16
- info.bottom = float(y + h) / texture->size();
13
+ float textureSize = texture->size();
14
+ info.left = x / textureSize;
15
+ info.top = y / textureSize;
16
+ info.right = (x + w) / textureSize;
17
+ info.bottom = (y + h) / textureSize;
17
18
  }
18
19
 
19
20
  Gosu::TexChunk::~TexChunk()
@@ -27,25 +28,31 @@ void Gosu::TexChunk::draw(double x1, double y1, Color c1,
27
28
  double x4, double y4, Color c4,
28
29
  ZPos z, AlphaMode mode) const
29
30
  {
30
- DrawOp newDrawOp(transforms->back());
31
+ DrawOp op;
32
+ op.renderState.texName = texName();
33
+ op.renderState.transform = &transforms->back();
34
+ op.renderState.mode = mode;
31
35
 
32
36
  reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
33
37
 
34
- newDrawOp.usedVertices = 4;
35
- newDrawOp.vertices[0] = DrawOp::Vertex(x1, y1, c1);
36
- newDrawOp.vertices[1] = DrawOp::Vertex(x2, y2, c2);
38
+ op.verticesOrBlockIndex = 4;
39
+ op.vertices[0] = DrawOp::Vertex(x1, y1, c1);
40
+ op.vertices[1] = DrawOp::Vertex(x2, y2, c2);
37
41
  // TODO: Should be harmonized
38
42
  #ifdef GOSU_IS_IPHONE
39
- newDrawOp.vertices[2] = DrawOp::Vertex(x3, y3, c3);
40
- newDrawOp.vertices[3] = DrawOp::Vertex(x4, y4, c4);
43
+ op.vertices[2] = DrawOp::Vertex(x3, y3, c3);
44
+ op.vertices[3] = DrawOp::Vertex(x4, y4, c4);
41
45
  #else
42
- newDrawOp.vertices[3] = DrawOp::Vertex(x3, y3, c3);
43
- newDrawOp.vertices[2] = DrawOp::Vertex(x4, y4, c4);
46
+ op.vertices[3] = DrawOp::Vertex(x3, y3, c3);
47
+ op.vertices[2] = DrawOp::Vertex(x4, y4, c4);
44
48
  #endif
45
- newDrawOp.chunk = this;
46
- newDrawOp.mode = mode;
49
+ op.left = info.left;
50
+ op.top = info.top;
51
+ op.right = info.right;
52
+ op.bottom = info.bottom;
47
53
 
48
- queues->back().scheduleDrawOp(newDrawOp, z);
54
+ op.z = z;
55
+ queues->back().scheduleDrawOp(op);
49
56
  }
50
57
 
51
58
  const Gosu::GLTexInfo* Gosu::TexChunk::glTexInfo() const
@@ -84,7 +91,7 @@ void Gosu::TexChunk::insert(const Bitmap& original, int x, int y)
84
91
  bitmap = &alternate;
85
92
  }
86
93
 
87
- glBindTexture(GL_TEXTURE_2D, texture->texName());
94
+ glBindTexture(GL_TEXTURE_2D, texName());
88
95
  glTexSubImage2D(GL_TEXTURE_2D, 0, this->x + x, this->y + y, bitmap->width(), bitmap->height(),
89
96
  Color::GL_FORMAT, GL_UNSIGNED_BYTE, bitmap->data());
90
97
  }
@@ -19,18 +19,18 @@ class Gosu::TexChunk : public Gosu::ImageData
19
19
 
20
20
  // Cached for faster access.
21
21
  GLTexInfo info;
22
-
22
+
23
23
  public:
24
24
  TexChunk(Graphics& graphics, Transforms& transforms, DrawOpQueueStack& queues,
25
25
  std::tr1::shared_ptr<Texture> texture, int x, int y, int w, int h, int padding);
26
26
  ~TexChunk();
27
27
 
28
- unsigned int width() const
28
+ int width() const
29
29
  {
30
30
  return w;
31
31
  }
32
32
 
33
- unsigned int height() const
33
+ int height() const
34
34
  {
35
35
  return h;
36
36
  }
@@ -40,14 +40,6 @@ public:
40
40
  return info.texName;
41
41
  }
42
42
 
43
- void getCoords(float& left, float& top, float& right, float& bottom) const
44
- {
45
- left = info.left;
46
- top = info.top;
47
- right = info.right;
48
- bottom = info.bottom;
49
- }
50
-
51
43
  void draw(double x1, double y1, Color c1,
52
44
  double x2, double y2, Color c2,
53
45
  double x3, double y3, Color c3,
@@ -36,12 +36,12 @@ Gosu::Texture::Texture(unsigned size)
36
36
  else
37
37
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
38
38
 
39
- #ifdef GOSU_IS_WIN
40
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
41
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
42
- #else
39
+ #ifdef GL_CLAMP_TO_EDGE
43
40
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
44
41
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
42
+ #else
43
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
44
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
45
45
  #endif
46
46
  }
47
47
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  typedef UIAccelerationValue Acceleration[3];
4
4
 
5
- @interface AccelerometerReader : NSObject {
5
+ @interface AccelerometerReader : NSObject <UIAccelerometerDelegate> {
6
6
  Acceleration acceleration;
7
7
  }
8
8
  -(AccelerometerReader*)initWithUpdateInterval:(float)updateInterval;
@@ -767,10 +767,10 @@ namespace Gosu {
767
767
  $self->graphics().endClipping();
768
768
  }
769
769
  %newobject record;
770
- Gosu::Image* record() {
770
+ Gosu::Image* record(int width, int height) {
771
771
  $self->graphics().beginRecording();
772
772
  rb_yield(Qnil);
773
- return new Gosu::Image($self->graphics().endRecording());
773
+ return new Gosu::Image($self->graphics().endRecording(width, height));
774
774
  }
775
775
  void transform(double m0, double m1, double m2, double m3, double m4, double m5, double m6, double m7,
776
776
  double m8, double m9, double m10, double m11, double m12, double m13, double m14, double m15) {
@@ -2823,10 +2823,10 @@ SWIGINTERN void Gosu_Window_clipTo(Gosu::Window *self,double x,double y,double w
2823
2823
  rb_yield(Qnil);
2824
2824
  self->graphics().endClipping();
2825
2825
  }
2826
- SWIGINTERN Gosu::Image *Gosu_Window_record(Gosu::Window *self){
2826
+ SWIGINTERN Gosu::Image *Gosu_Window_record(Gosu::Window *self,int width,int height){
2827
2827
  self->graphics().beginRecording();
2828
2828
  rb_yield(Qnil);
2829
- return new Gosu::Image(self->graphics().endRecording());
2829
+ return new Gosu::Image(self->graphics().endRecording(width, height));
2830
2830
  }
2831
2831
  SWIGINTERN void Gosu_Window_transform(Gosu::Window *self,double m0,double m1,double m2,double m3,double m4,double m5,double m6,double m7,double m8,double m9,double m10,double m11,double m12,double m13,double m14,double m15){
2832
2832
  Gosu::Transform transform = {
@@ -10359,22 +10359,38 @@ fail:
10359
10359
  SWIGINTERN VALUE
10360
10360
  _wrap_Window_record(int argc, VALUE *argv, VALUE self) {
10361
10361
  Gosu::Window *arg1 = (Gosu::Window *) 0 ;
10362
+ int arg2 ;
10363
+ int arg3 ;
10362
10364
  void *argp1 = 0 ;
10363
10365
  int res1 = 0 ;
10366
+ int val2 ;
10367
+ int ecode2 = 0 ;
10368
+ int val3 ;
10369
+ int ecode3 = 0 ;
10364
10370
  Gosu::Image *result = 0 ;
10365
10371
  VALUE vresult = Qnil;
10366
10372
 
10367
- if ((argc < 0) || (argc > 0)) {
10368
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
10373
+ if ((argc < 2) || (argc > 2)) {
10374
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
10369
10375
  }
10370
10376
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Window, 0 | 0 );
10371
10377
  if (!SWIG_IsOK(res1)) {
10372
10378
  SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Window *","record", 1, self ));
10373
10379
  }
10374
10380
  arg1 = reinterpret_cast< Gosu::Window * >(argp1);
10381
+ ecode2 = SWIG_AsVal_int(argv[0], &val2);
10382
+ if (!SWIG_IsOK(ecode2)) {
10383
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","record", 2, argv[0] ));
10384
+ }
10385
+ arg2 = static_cast< int >(val2);
10386
+ ecode3 = SWIG_AsVal_int(argv[1], &val3);
10387
+ if (!SWIG_IsOK(ecode3)) {
10388
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","record", 3, argv[1] ));
10389
+ }
10390
+ arg3 = static_cast< int >(val3);
10375
10391
  {
10376
10392
  try {
10377
- result = (Gosu::Image *)Gosu_Window_record(arg1);
10393
+ result = (Gosu::Image *)Gosu_Window_record(arg1,arg2,arg3);
10378
10394
  } catch (const std::exception& e) {
10379
10395
  SWIG_exception(SWIG_RuntimeError, e.what());
10380
10396
  }
@@ -11227,8 +11243,8 @@ SWIGEXPORT void Init_gosu(void) {
11227
11243
  SWIG_RubyInitializeTrackings();
11228
11244
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
11229
11245
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(7)));
11230
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(38)));
11231
- rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.38"));
11246
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(39)));
11247
+ rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.39"));
11232
11248
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
11233
11249
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
11234
11250
  rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
@@ -8,6 +8,8 @@
8
8
  #include <algorithm>
9
9
  #include <vector>
10
10
 
11
+ #ifndef GOSU_IS_IPHONE
12
+
11
13
  #ifndef GOSU_IS_WIN
12
14
  #include <GosuImpl/Iconv.hpp>
13
15
  #endif
@@ -101,6 +103,8 @@ string Gosu::narrow(const wstring& ws)
101
103
  return string(buf.begin(), buf.end() - 1);
102
104
  }
103
105
 
106
+ #endif
107
+
104
108
  // TODO: This function needs to go into some internal header.
105
109
  namespace Gosu
106
110
  {
@@ -22,6 +22,8 @@
22
22
  #include <X11/Xutil.h>
23
23
  #include "X11vroot.h"
24
24
 
25
+ #include <X11/extensions/Xinerama.h>
26
+
25
27
  using namespace std::tr1::placeholders;
26
28
 
27
29
  namespace
@@ -236,20 +238,52 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen,
236
238
  Atom atoms[] = { XInternAtom(pimpl->display, "WM_DELETE_WINDOW", false) };
237
239
  XSetWMProtocols(pimpl->display, pimpl->window, atoms, 1);
238
240
 
241
+ // Get xinerama screen info
242
+ int screen_count = 0;
243
+ XineramaScreenInfo *screen_info = XineramaQueryScreens(pimpl->display, &screen_count);
244
+
245
+ // Holders for screen info
246
+ int screen_origin_x = 0;
247
+ int screen_origin_y = 0;
248
+ int screen_width = 0;
249
+ int screen_height = 0;
250
+
251
+ // Literal X screen, different from Xinerama screens
239
252
  Screen* screen = XScreenOfDisplay(pimpl->display,
240
253
  DefaultScreen(pimpl->display));
241
254
 
255
+ // Get origin/size from first xinerama screen if it
256
+ // exists; convention seems to be that the first
257
+ // screen is always the default screen with xinerama.
258
+ if(screen_info != NULL){
259
+ screen_origin_x = screen_info[0].x_org;
260
+ screen_origin_y = screen_info[0].y_org;
261
+ screen_width = screen_info[0].width;
262
+ screen_height = screen_info[0].height;
263
+
264
+ // ... or just use the whole X screen if we don't
265
+ // seem to have any xinerama information.
266
+ }else{
267
+ screen_width = screen->width;
268
+ screen_height = screen->height;
269
+ }
270
+
271
+ // Free the screen info, cause I guess we don't
272
+ // need it after this?
273
+ XFree(screen_info);
274
+
242
275
  if (fullscreen)
243
276
  {
244
- pimpl->width = screen->width;
245
- pimpl->height = screen->height;
246
- XMoveResizeWindow(pimpl->display, pimpl->window, 0, 0,
247
- screen->width, screen->height);
277
+ pimpl->width = screen_width;
278
+ pimpl->height = screen_height;
279
+ XMoveResizeWindow(pimpl->display, pimpl->window, screen_origin_x, screen_origin_y,
280
+ screen_width, screen_height);
248
281
 
249
282
  XSetWindowAttributes windowAttributes;
250
283
  windowAttributes.override_redirect = true;
251
284
  unsigned mask = CWOverrideRedirect;
252
285
  XChangeWindowAttributes(pimpl->display, pimpl->window, mask, &windowAttributes);
286
+
253
287
  }
254
288
  else
255
289
  ; // Window already has requested size
@@ -348,9 +382,11 @@ void Gosu::Window::show()
348
382
  // Make glx current
349
383
  glXMakeCurrent(pimpl->display, pimpl->window, pimpl->context);
350
384
 
351
- if (pimpl->fullscreen)
385
+ if (pimpl->fullscreen){
352
386
  XSetInputFocus(pimpl->display, pimpl->window, RevertToParent, CurrentTime);
353
-
387
+ XGrabPointer(pimpl->display, pimpl->window, true, 0, GrabModeAsync, GrabModeAsync, pimpl->window, None, CurrentTime);
388
+ }
389
+
354
390
  setCaption(pimpl->title);
355
391
 
356
392
  unsigned startTime, endTime;
@@ -65,9 +65,9 @@ class Star
65
65
  def initialize(animation)
66
66
  @animation = animation
67
67
  @color = Gosu::Color.new(0xff000000)
68
- @color.red = rand(255 - 40) + 40
69
- @color.green = rand(255 - 40) + 40
70
- @color.blue = rand(255 - 40) + 40
68
+ @color.red = rand(256 - 40) + 40
69
+ @color.green = rand(256 - 40) + 40
70
+ @color.blue = rand(256 - 40) + 40
71
71
  @x = rand * 640
72
72
  @y = rand * 480
73
73
  end
@@ -5,12 +5,12 @@ if defined? RUBY_PLATFORM and
5
5
  ENV['PATH'] = "#{File.dirname(__FILE__)};#{ENV['PATH']}"
6
6
  end
7
7
 
8
- if File.exist? "#{File.dirname(__FILE__)}/gosu.#{Config::CONFIG['DLEXT']}"
9
- require "gosu.#{Config::CONFIG['DLEXT']}"
8
+ if File.exist? "#{File.dirname(__FILE__)}/gosu.#{RbConfig::CONFIG['DLEXT']}"
9
+ require "gosu.#{RbConfig::CONFIG['DLEXT']}"
10
10
  elsif defined? RUBY_VERSION and RUBY_VERSION >= '1.9' then
11
- require "gosu.for_1_9.#{Config::CONFIG['DLEXT']}"
11
+ require "gosu.for_1_9.#{RbConfig::CONFIG['DLEXT']}"
12
12
  else
13
- require "gosu.for_1_8.#{Config::CONFIG['DLEXT']}"
13
+ require "gosu.for_1_8.#{RbConfig::CONFIG['DLEXT']}"
14
14
  end
15
15
 
16
16
  require "gosu/swig_patches"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 79
4
+ hash: 77
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 38
10
- version: 0.7.38
9
+ - 39
10
+ version: 0.7.39
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julian Raschke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-28 00:00:00 Z
18
+ date: 2011-11-19 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  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"
@@ -111,6 +111,7 @@ files:
111
111
  - GosuImpl/Graphics/BitmapUtils.cpp
112
112
  - GosuImpl/Graphics/BlockAllocator.cpp
113
113
  - GosuImpl/Graphics/BlockAllocator.hpp
114
+ - GosuImpl/Graphics/ClipRectStack.hpp
114
115
  - GosuImpl/Graphics/Color.cpp
115
116
  - GosuImpl/Graphics/Common.hpp
116
117
  - GosuImpl/Graphics/DrawOp.hpp
@@ -178,12 +179,19 @@ files:
178
179
  - GosuImpl/WinUtility.cpp
179
180
  - GosuImpl/X11vroot.h
180
181
  - linux/extconf.rb
181
- homepage: http://libgosu.org/
182
+ homepage: http://www.libgosu.org/
182
183
  licenses: []
183
184
 
184
185
  post_install_message:
185
- rdoc_options: []
186
-
186
+ rdoc_options:
187
+ - README.txt
188
+ - COPYING
189
+ - reference/gosu.rb
190
+ - reference/*.rdoc
191
+ - --title
192
+ - Gosu
193
+ - --main
194
+ - README.txt
187
195
  require_paths:
188
196
  - lib
189
197
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -209,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
217
  requirements:
210
218
  - See https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
211
219
  rubyforge_project:
212
- rubygems_version: 1.8.9
220
+ rubygems_version: 1.8.11
213
221
  signing_key:
214
222
  specification_version: 3
215
223
  summary: 2D game development library.