gosu 0.14.6.pre1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa8da5cf8c3c455ebaa47ee8e9dc31091fcc2ecc10afce1acac4fb4802cd0b9a
4
- data.tar.gz: 12c781dbcbda39f7417b8afcbb4fc72e7998fb5574fa0dfed15d4e4b2c0e97fb
3
+ metadata.gz: 9ba5fe75439828dc20ce57aaeca27e464ae1aba262f743febf5405fc6fac738b
4
+ data.tar.gz: 7f7b333a69fb3435ebc09c3c6b2c7ebd647f68cdc2b689d85a13bd6e66583241
5
5
  SHA512:
6
- metadata.gz: a84524ee920802fa45abf1bcf980c6bd0ec0456a3b47c42ee3bc139e4c364261f6fb1369e2456dd886a5bc0eae8f8903b21a9a80c930abc14fad665f13253d8a
7
- data.tar.gz: 43cc93051d22b7ddbf49987dd50efd70b001752acab675e29235f351e7a30d318acb11ed9853937ead8024185d494fc6d872307a961cef3a37ddca4f09e84442
6
+ metadata.gz: 266afe66c7524c6b0efaca9c7c0eef37494c33f27bc896c2d6777ef8bbe86d2238ebb1c4866ad6a599f9e3d9a56a8304fe2c47b8c58e6295707152571828c5a6
7
+ data.tar.gz: '0038955bca0bbaa7bc374aa389abc4416786fe900b6eb9011db60194c1129b9823bdc6df896f4a929fde5258f0d0ddac746e0d8f44b3bff8617e3dacaedc89dc'
@@ -3,8 +3,8 @@
3
3
  #include <string>
4
4
 
5
5
  #define GOSU_MAJOR_VERSION 0
6
- #define GOSU_MINOR_VERSION 14
7
- #define GOSU_POINT_VERSION 6
6
+ #define GOSU_MINOR_VERSION 15
7
+ #define GOSU_POINT_VERSION 0
8
8
 
9
9
  namespace Gosu
10
10
  {
@@ -68,9 +68,14 @@ module Gosu
68
68
  end
69
69
  end
70
70
 
71
+ # These were useful for working with Direct3D and the Win32 API a long time ago,
72
+ # there was never a real reason to have them available in Ruby.
73
+ Gosu.deprecate Gosu::Color, :bgr, :none
74
+ Gosu.deprecate Gosu::Color, :abgr, :none
75
+
71
76
  # No need to pass a Window to Image.
72
77
  class Gosu::Image
73
- alias initialize_without_window initialize
78
+ alias_method :initialize_without_window, :initialize
74
79
 
75
80
  def initialize(*args)
76
81
  if args[0].is_a? Gosu::Window
@@ -86,7 +91,7 @@ class Gosu::Image
86
91
  end
87
92
 
88
93
  class << self
89
- alias from_text_without_window from_text
94
+ alias_method :from_text_without_window, :from_text
90
95
  end
91
96
 
92
97
  def self.from_text(*args)
@@ -105,7 +110,7 @@ end
105
110
 
106
111
  # No need to pass a Window to Sample.
107
112
  class Gosu::Sample
108
- alias initialize_without_window initialize
113
+ alias_method :initialize_without_window, :initialize
109
114
 
110
115
  def initialize(*args)
111
116
  if args.first.is_a? Gosu::Window
@@ -118,7 +123,7 @@ end
118
123
 
119
124
  # No need to pass a Window to Song.
120
125
  class Gosu::Song
121
- alias initialize_without_window initialize
126
+ alias_method :initialize_without_window, :initialize
122
127
 
123
128
  def initialize(*args)
124
129
  if args.first.is_a? Gosu::Window
@@ -28,6 +28,12 @@ class Gosu::Font
28
28
  end
29
29
 
30
30
  class Gosu::Image
31
+ BlobHelper = Struct.new(:columns, :rows, :to_blob)
32
+
33
+ def self.from_blob(width, height, rgba = "\0\0\0\0" * (width * height))
34
+ self.new(BlobHelper.new(width, height, rgba))
35
+ end
36
+
31
37
  # from_markup will stop parsing markup in Gosu 1.0.
32
38
  def self.from_markup(*args)
33
39
  self.from_text(*args)
@@ -54,7 +60,7 @@ module Gosu
54
60
  FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
55
61
  CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
56
62
 
57
- alias hash gl
63
+ alias_method :hash, :gl
58
64
  def eql?(other)
59
65
  gl == other.gl
60
66
  end
@@ -65,7 +71,7 @@ class Gosu::Window
65
71
  # Call Thread.pass every tick, which may or may not be necessary for friendly co-existence with
66
72
  # Ruby's Thread class.
67
73
 
68
- alias _tick tick
74
+ alias_method :_tick, :tick
69
75
 
70
76
  def tick
71
77
  Thread.pass
@@ -3,7 +3,7 @@
3
3
  # compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
4
4
  # custom debugging help:
5
5
  class Gosu::Window
6
- alias initialize_without_hash initialize
6
+ alias_method :initialize_without_hash, :initialize
7
7
 
8
8
  def initialize width, height, *args
9
9
  if args.empty? or args.first.is_a? Hash
@@ -40,7 +40,7 @@ class Gosu::Window
40
40
  $gosu_gl_blocks = nil
41
41
  end
42
42
 
43
- alias show_internal show
43
+ alias_method :show_internal, :show
44
44
  def show
45
45
  show_internal
46
46
  # Try to format the message nicely, without any useless patching that we are
@@ -68,7 +68,13 @@ module Gosu
68
68
  end
69
69
  end
70
70
 
71
- # SWIG will not let me rename my method to '[]=', so use alias here.
71
+ # SWIG somehow maps the instance method "argb" as an overload of the class
72
+ # method of the same name.
73
+ class Gosu::Color
74
+ alias_method :argb, :to_i
75
+ end
76
+
77
+ # SWIG will not let me rename my method to '[]=', so use alias_method here.
72
78
  class Gosu::Font
73
- alias []= set_image
79
+ alias_method :[]=, :set_image
74
80
  end
@@ -190,10 +190,19 @@ module Gosu
190
190
 
191
191
  # @!endgroup
192
192
 
193
- # Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed order in memory and its integer value may vary depending on your system's byte order.
193
+ ##
194
+ # @return [Integer] a 32-bit representation of the color in 0xAARRGGBB format.
195
+ def argb; end
196
+
197
+ alias_method :to_i, :argb
198
+
199
+ # Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed format in memory and its integer value may vary depending on your system's byte order.
194
200
  #
195
201
  # @return [Integer] a 32-bit OpenGL color.
196
202
  def gl; end
203
+
204
+ # Returns an OpenGL integer constant that identifies the RGBA color format that Gosu uses.
205
+ GL_FORMAT = :some_integer
197
206
 
198
207
  ##
199
208
  # @return [Color] a copy of the color.
@@ -348,6 +357,14 @@ module Gosu
348
357
  # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki
349
358
  def initialize(source, options = {}); end
350
359
 
360
+ ##
361
+ # Creates a new image with the given dimensions and RGBA pixel data.
362
+ #
363
+ # @param [Integer] width Width of the image in pixels.
364
+ # @param [Integer] height Height of the image in pixels.
365
+ # @param [String] rgba A string containing raw binary image data, with either one byte ('uint8') or four bytes ('float') per RGBA component.
366
+ def self.from_blob(width, height, rgba = "\0\0\0\0" * (width * height)); end
367
+
351
368
  ##
352
369
  # Creates a reusable image from one or more lines of text.
353
370
  #
@@ -68,7 +68,7 @@ struct Gosu::Graphics::Impl
68
68
  {
69
69
  glPushAttrib(GL_ALL_ATTRIB_BITS);
70
70
  glDisable(GL_BLEND);
71
- // Reset the colour to white to avoid surprises.
71
+ // Reset the color to white to avoid surprises.
72
72
  // https://www.libgosu.org/cgi-bin/mwf/topic_show.pl?pid=9115#pid9115
73
73
  glColor4ubv(reinterpret_cast<const GLubyte*>(&Color::WHITE));
74
74
  while (glGetError() != GL_NO_ERROR);
@@ -287,13 +287,16 @@ Gosu::Image Gosu::Graphics::render(int width, int height, const function<void ()
287
287
 
288
288
  // This is the actual render-to-texture step.
289
289
  Image result = OffScreenTarget(width, height, image_flags).render([&] {
290
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
290
291
  glClearColor(0, 0, 0, 0);
291
292
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
293
+ glEnable(GL_BLEND);
292
294
  queues.emplace_back(QM_RENDER_TO_TEXTURE);
293
295
  f();
294
296
  queues.back().perform_draw_ops_and_code();
295
297
  queues.pop_back();
296
298
  glFlush();
299
+ glPopAttrib();
297
300
  });
298
301
 
299
302
  // Restore previous matrix and glViewport.
@@ -110,7 +110,6 @@ namespace Gosu
110
110
  void ensure_current_context();
111
111
 
112
112
  inline std::string escape_markup(const std::string& text) {
113
- // Escape all markup and delegate to layout_markup.
114
113
  auto markup = text;
115
114
  for (std::string::size_type pos = 0; pos < markup.length(); ++pos) {
116
115
  if (markup[pos] == '&') {
@@ -119,17 +119,25 @@ bool Gosu::MarkupParser::parse_markup()
119
119
 
120
120
  bool Gosu::MarkupParser::parse_escape_entity()
121
121
  {
122
+ auto translate_to = [this](char ch) {
123
+ if (word_state == ADDING_WHITESPACE) {
124
+ flush_to_consumer();
125
+ word_state = ADDING_WORD;
126
+ }
127
+ add_composed_substring(u32string(1, ch));
128
+ };
129
+
122
130
  // These are not entities (images) but escapes for markup characters.
123
131
  if (match_and_skip("&lt;")) {
124
- add_composed_substring(u32string(1, '<'));
132
+ translate_to('<');
125
133
  return true;
126
134
  }
127
135
  if (match_and_skip("&gt;")) {
128
- add_composed_substring(u32string(1, '>'));
136
+ translate_to('>');
129
137
  return true;
130
138
  }
131
139
  if (match_and_skip("&amp;")) {
132
- add_composed_substring(u32string(1, '&'));
140
+ translate_to('&');
133
141
  return true;
134
142
  }
135
143
 
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 3.0.12
3
+ * Version 4.0.1
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
@@ -332,6 +332,7 @@ template <typename T> T SwigValueInit() {
332
332
  /* Flags for pointer conversions */
333
333
  #define SWIG_POINTER_DISOWN 0x1
334
334
  #define SWIG_CAST_NEW_MEMORY 0x2
335
+ #define SWIG_POINTER_NO_NULL 0x4
335
336
 
336
337
  /* Flags for new pointer objects */
337
338
  #define SWIG_POINTER_OWN 0x1
@@ -970,6 +971,9 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
970
971
  #ifndef RSTRUCT_PTR
971
972
  # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
972
973
  #endif
974
+ #ifndef RTYPEDDATA_P
975
+ # define RTYPEDDATA_P(x) (TYPE(x) != T_DATA)
976
+ #endif
973
977
 
974
978
 
975
979
 
@@ -1193,7 +1197,7 @@ void Ruby_Format_OverloadedError(
1193
1197
  /* -----------------------------------------------------------------------------
1194
1198
  * rubytracking.swg
1195
1199
  *
1196
- * This file contains support for tracking mappings from
1200
+ * This file contains support for tracking mappings from
1197
1201
  * Ruby objects to C++ objects. This functionality is needed
1198
1202
  * to implement mark functions for Ruby's mark and sweep
1199
1203
  * garbage collector.
@@ -1220,7 +1224,7 @@ extern "C" {
1220
1224
  #endif
1221
1225
 
1222
1226
  /* Global hash table to store Trackings from C/C++
1223
- structs to Ruby Objects.
1227
+ structs to Ruby Objects.
1224
1228
  */
1225
1229
  static st_table* swig_ruby_trackings = NULL;
1226
1230
 
@@ -1234,7 +1238,7 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1234
1238
  /* Create a hash table to store Trackings from C++
1235
1239
  objects to Ruby objects. */
1236
1240
 
1237
- /* Try to see if some other .so has already created a
1241
+ /* Try to see if some other .so has already created a
1238
1242
  tracking hash table, which we keep hidden in an instance var
1239
1243
  in the SWIG module.
1240
1244
  This is done to allow multiple DSOs to share the same
@@ -1293,13 +1297,14 @@ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1293
1297
 
1294
1298
  /* This is a helper method that unlinks a Ruby object from its
1295
1299
  underlying C++ object. This is needed if the lifetime of the
1296
- Ruby object is longer than the C++ object */
1300
+ Ruby object is longer than the C++ object. */
1297
1301
  SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1298
1302
  VALUE object = SWIG_RubyInstanceFor(ptr);
1299
1303
 
1300
1304
  if (object != Qnil) {
1301
- if (TYPE(object) != T_DATA)
1302
- abort();
1305
+ // object might have the T_ZOMBIE type, but that's just
1306
+ // because the GC has flagged it as such for a deferred
1307
+ // destruction. Until then, it's still a T_DATA object.
1303
1308
  DATA_PTR(object) = 0;
1304
1309
  }
1305
1310
  }
@@ -1532,10 +1537,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1532
1537
  swig_class *sklass;
1533
1538
  VALUE klass;
1534
1539
  VALUE obj;
1535
-
1540
+
1536
1541
  if (!ptr)
1537
1542
  return Qnil;
1538
-
1543
+
1544
+ assert(type);
1539
1545
  if (type->clientdata) {
1540
1546
  sklass = (swig_class *) type->clientdata;
1541
1547
 
@@ -1543,7 +1549,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1543
1549
  track = sklass->trackObjects;
1544
1550
  if (track) {
1545
1551
  obj = SWIG_RubyInstanceFor(ptr);
1546
-
1552
+
1547
1553
  /* Check the object's type and make sure it has the correct type.
1548
1554
  It might not in cases where methods do things like
1549
1555
  downcast methods. */
@@ -1575,7 +1581,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1575
1581
  obj = Data_Wrap_Struct(klass, 0, 0, ptr);
1576
1582
  }
1577
1583
  rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1578
-
1584
+
1579
1585
  return obj;
1580
1586
  }
1581
1587
 
@@ -1607,7 +1613,7 @@ typedef struct {
1607
1613
  SWIGRUNTIME swig_ruby_owntype
1608
1614
  SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) {
1609
1615
  swig_ruby_owntype oldown = {0, 0};
1610
- if (obj) {
1616
+ if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) {
1611
1617
  oldown.datafree = RDATA(obj)->dfree;
1612
1618
  RDATA(obj)->dfree = own.datafree;
1613
1619
  }
@@ -1626,9 +1632,9 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1626
1632
  if (NIL_P(obj)) {
1627
1633
  if (ptr)
1628
1634
  *ptr = 0;
1629
- return SWIG_OK;
1635
+ return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
1630
1636
  } else {
1631
- if (TYPE(obj) != T_DATA) {
1637
+ if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) {
1632
1638
  return SWIG_ERROR;
1633
1639
  }
1634
1640
  Data_Get_Struct(obj, void, vptr);
@@ -1723,7 +1729,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
1723
1729
  return rb_str_new2(result);
1724
1730
  }
1725
1731
 
1726
- /* Convert a packed value value */
1732
+ /* Convert a packed pointer value */
1727
1733
  SWIGRUNTIME int
1728
1734
  SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
1729
1735
  swig_cast_info *tc;
@@ -1995,43 +2001,6 @@ namespace Swig {
1995
2001
  }
1996
2002
  };
1997
2003
 
1998
- /* unknown exception handler */
1999
- class UnknownExceptionHandler {
2000
- #ifdef SWIG_DIRECTOR_UEH
2001
- static void handler() {
2002
- try {
2003
- throw;
2004
- } catch (DirectorException& e) {
2005
- std::cerr << "SWIG Director exception caught:" << std::endl
2006
- << e.what() << std::endl;
2007
- } catch (std::exception& e) {
2008
- std::cerr << "std::exception caught: "<< e.what() << std::endl;
2009
- } catch (...) {
2010
- std::cerr << "Unknown exception caught." << std::endl;
2011
- }
2012
- std::cerr << std::endl
2013
- << "Ruby interpreter traceback:" << std::endl;
2014
- std::cerr << std::endl;
2015
- std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl
2016
- << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
2017
- << std::endl
2018
- << "Exception is being re-thrown, program will like abort/terminate." << std::endl;
2019
- throw;
2020
- }
2021
-
2022
- public:
2023
- std::unexpected_handler old;
2024
- UnknownExceptionHandler(std::unexpected_handler nh = handler) {
2025
- old = std::set_unexpected(nh);
2026
- }
2027
-
2028
- ~UnknownExceptionHandler() {
2029
- std::set_unexpected(old);
2030
- }
2031
- #endif
2032
- };
2033
-
2034
-
2035
2004
  /* Type mismatch in the return value from a Ruby method call */
2036
2005
  class DirectorTypeMismatchException : public DirectorException {
2037
2006
  public:
@@ -2221,7 +2190,7 @@ static VALUE mGosu;
2221
2190
  #define SWIG_RUBY_THREAD_END_BLOCK
2222
2191
 
2223
2192
 
2224
- #define SWIGVERSION 0x030012
2193
+ #define SWIGVERSION 0x040001
2225
2194
  #define SWIG_VERSION SWIGVERSION
2226
2195
 
2227
2196
 
@@ -2519,7 +2488,7 @@ SWIG_ruby_failed(void)
2519
2488
  }
2520
2489
 
2521
2490
 
2522
- /*@SWIG:/usr/local/Cellar/swig/3.0.12/share/swig/3.0.12/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2491
+ /*@SWIG:/usr/local/Cellar/swig/4.0.1/share/swig/4.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2523
2492
  SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
2524
2493
  {
2525
2494
  VALUE obj = args[0];
@@ -2561,7 +2530,7 @@ SWIG_From_unsigned_SS_int (unsigned int value)
2561
2530
  #include <string>
2562
2531
 
2563
2532
 
2564
- /*@SWIG:/usr/local/Cellar/swig/3.0.12/share/swig/3.0.12/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2533
+ /*@SWIG:/usr/local/Cellar/swig/4.0.1/share/swig/4.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2565
2534
  SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
2566
2535
  {
2567
2536
  VALUE obj = args[0];
@@ -2628,6 +2597,9 @@ SWIGINTERN Gosu::Color Gosu_Color_argb__SWIG_1(Gosu::Color::Channel a,Gosu::Colo
2628
2597
  SWIGINTERN Gosu::Color Gosu_Color_argb__SWIG_2(std::uint32_t argb){
2629
2598
  return Gosu::Color(argb);
2630
2599
  }
2600
+ SWIGINTERN std::uint32_t Gosu_Color_to_i(Gosu::Color const *self){
2601
+ return self->argb();
2602
+ }
2631
2603
  SWIGINTERN Gosu::Color Gosu_Color_dup(Gosu::Color const *self){
2632
2604
  return *self;
2633
2605
  }
@@ -2763,7 +2735,7 @@ SWIG_AsPtr_std_string (VALUE obj, std::string **val)
2763
2735
  }
2764
2736
 
2765
2737
 
2766
- /*@SWIG:/usr/local/Cellar/swig/3.0.12/share/swig/3.0.12/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2738
+ /*@SWIG:/usr/local/Cellar/swig/4.0.1/share/swig/4.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2767
2739
  SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
2768
2740
  {
2769
2741
  VALUE obj = args[0];
@@ -3195,10 +3167,10 @@ SwigDirector_TextInput::~SwigDirector_TextInput() {
3195
3167
  }
3196
3168
 
3197
3169
  std::string SwigDirector_TextInput::filter(std::string text) const {
3198
- std::string c_result ;
3199
3170
  VALUE obj0 = Qnil ;
3200
3171
  VALUE SWIGUNUSED result;
3201
3172
 
3173
+ std::string c_result;
3202
3174
  obj0 = SWIG_From_std_string(static_cast< std::string >(text));
3203
3175
  result = rb_funcall(swig_get_self(), rb_intern("filter"), 1,obj0);
3204
3176
  std::string *swig_optr = 0;
@@ -3224,15 +3196,15 @@ SwigDirector_Window::~SwigDirector_Window() {
3224
3196
  void SwigDirector_Window::show() {
3225
3197
  VALUE SWIGUNUSED result;
3226
3198
 
3227
- result = rb_funcall(swig_get_self(), rb_intern("show"), 0, NULL);
3199
+ result = rb_funcall(swig_get_self(), rb_intern("show"), 0, Qnil);
3228
3200
  }
3229
3201
 
3230
3202
 
3231
3203
  bool SwigDirector_Window::tick() {
3232
- bool c_result ;
3204
+ bool c_result = SwigValueInit< bool >() ;
3233
3205
  VALUE SWIGUNUSED result;
3234
3206
 
3235
- result = rb_funcall(swig_get_self(), rb_intern("tick"), 0, NULL);
3207
+ result = rb_funcall(swig_get_self(), rb_intern("tick"), 0, Qnil);
3236
3208
  bool swig_val;
3237
3209
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3238
3210
  if (!SWIG_IsOK(swig_res)) {
@@ -3246,29 +3218,29 @@ bool SwigDirector_Window::tick() {
3246
3218
  void SwigDirector_Window::close() {
3247
3219
  VALUE SWIGUNUSED result;
3248
3220
 
3249
- result = rb_funcall(swig_get_self(), rb_intern("close"), 0, NULL);
3221
+ result = rb_funcall(swig_get_self(), rb_intern("close"), 0, Qnil);
3250
3222
  }
3251
3223
 
3252
3224
 
3253
3225
  void SwigDirector_Window::update() {
3254
3226
  VALUE SWIGUNUSED result;
3255
3227
 
3256
- result = rb_funcall(swig_get_self(), rb_intern("protected_update"), 0, NULL);
3228
+ result = rb_funcall(swig_get_self(), rb_intern("protected_update"), 0, Qnil);
3257
3229
  }
3258
3230
 
3259
3231
 
3260
3232
  void SwigDirector_Window::draw() {
3261
3233
  VALUE SWIGUNUSED result;
3262
3234
 
3263
- result = rb_funcall(swig_get_self(), rb_intern("protected_draw_2"), 0, NULL);
3235
+ result = rb_funcall(swig_get_self(), rb_intern("protected_draw_2"), 0, Qnil);
3264
3236
  }
3265
3237
 
3266
3238
 
3267
3239
  bool SwigDirector_Window::needs_redraw() const {
3268
- bool c_result ;
3240
+ bool c_result = SwigValueInit< bool >() ;
3269
3241
  VALUE SWIGUNUSED result;
3270
3242
 
3271
- result = rb_funcall(swig_get_self(), rb_intern("protected_needs_redraw?"), 0, NULL);
3243
+ result = rb_funcall(swig_get_self(), rb_intern("protected_needs_redraw?"), 0, Qnil);
3272
3244
  bool swig_val;
3273
3245
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3274
3246
  if (!SWIG_IsOK(swig_res)) {
@@ -3280,10 +3252,10 @@ bool SwigDirector_Window::needs_redraw() const {
3280
3252
 
3281
3253
 
3282
3254
  bool SwigDirector_Window::needs_cursor() const {
3283
- bool c_result ;
3255
+ bool c_result = SwigValueInit< bool >() ;
3284
3256
  VALUE SWIGUNUSED result;
3285
3257
 
3286
- result = rb_funcall(swig_get_self(), rb_intern("protected_needs_cursor?"), 0, NULL);
3258
+ result = rb_funcall(swig_get_self(), rb_intern("protected_needs_cursor?"), 0, Qnil);
3287
3259
  bool swig_val;
3288
3260
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3289
3261
  if (!SWIG_IsOK(swig_res)) {
@@ -3297,14 +3269,14 @@ bool SwigDirector_Window::needs_cursor() const {
3297
3269
  void SwigDirector_Window::lose_focus() {
3298
3270
  VALUE SWIGUNUSED result;
3299
3271
 
3300
- result = rb_funcall(swig_get_self(), rb_intern("protected_lose_focus"), 0, NULL);
3272
+ result = rb_funcall(swig_get_self(), rb_intern("protected_lose_focus"), 0, Qnil);
3301
3273
  }
3302
3274
 
3303
3275
 
3304
3276
  void SwigDirector_Window::release_memory() {
3305
3277
  VALUE SWIGUNUSED result;
3306
3278
 
3307
- result = rb_funcall(swig_get_self(), rb_intern("release_memory"), 0, NULL);
3279
+ result = rb_funcall(swig_get_self(), rb_intern("release_memory"), 0, Qnil);
3308
3280
  }
3309
3281
 
3310
3282
 
@@ -5016,6 +4988,44 @@ fail:
5016
4988
  }
5017
4989
 
5018
4990
 
4991
+ /*
4992
+ Document-method: Gosu::Color.to_i
4993
+
4994
+ call-seq:
4995
+ to_i -> std::uint32_t
4996
+
4997
+ Convert Color to an Integer.
4998
+ */
4999
+ SWIGINTERN VALUE
5000
+ _wrap_Color_to_i(int argc, VALUE *argv, VALUE self) {
5001
+ Gosu::Color *arg1 = (Gosu::Color *) 0 ;
5002
+ void *argp1 = 0 ;
5003
+ int res1 = 0 ;
5004
+ std::uint32_t result;
5005
+ VALUE vresult = Qnil;
5006
+
5007
+ if ((argc < 0) || (argc > 0)) {
5008
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
5009
+ }
5010
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Color, 0 | 0 );
5011
+ if (!SWIG_IsOK(res1)) {
5012
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Color const *","to_i", 1, self ));
5013
+ }
5014
+ arg1 = reinterpret_cast< Gosu::Color * >(argp1);
5015
+ {
5016
+ try {
5017
+ result = Gosu_Color_to_i((Gosu::Color const *)arg1);
5018
+ }
5019
+ catch (const std::exception& e) {
5020
+ SWIG_exception(SWIG_RuntimeError, e.what());
5021
+ }
5022
+ }
5023
+ vresult = SWIG_From_unsigned_SS_long(static_cast< unsigned long >(result));
5024
+ return vresult;
5025
+ fail:
5026
+ return Qnil;
5027
+ }
5028
+
5019
5029
 
5020
5030
  /*
5021
5031
  Document-method: Gosu::Color.dup
@@ -5056,7 +5066,6 @@ fail:
5056
5066
  }
5057
5067
 
5058
5068
 
5059
-
5060
5069
  /*
5061
5070
  Document-method: Gosu::Color.inspect
5062
5071
 
@@ -5096,7 +5105,6 @@ fail:
5096
5105
  }
5097
5106
 
5098
5107
 
5099
-
5100
5108
  /*
5101
5109
  Document-method: Gosu::Color.==
5102
5110
 
@@ -5699,7 +5707,7 @@ SWIGINTERN VALUE _wrap_new_Font(int nargs, VALUE *args, VALUE self) {
5699
5707
  if (argc == 3) {
5700
5708
  int _v;
5701
5709
  void *vptr = 0;
5702
- int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gosu__Window, 0);
5710
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gosu__Window, SWIG_POINTER_NO_NULL);
5703
5711
  _v = SWIG_CheckState(res);
5704
5712
  if (_v) {
5705
5713
  int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
@@ -7125,7 +7133,7 @@ SWIGINTERN VALUE _wrap_Image_load_tiles(int nargs, VALUE *args, VALUE self) {
7125
7133
  if (argc == 5) {
7126
7134
  int _v;
7127
7135
  void *vptr = 0;
7128
- int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gosu__Window, 0);
7136
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gosu__Window, SWIG_POINTER_NO_NULL);
7129
7137
  _v = SWIG_CheckState(res);
7130
7138
  if (_v) {
7131
7139
  _v = (argv[1] != 0);
@@ -7298,7 +7306,6 @@ fail:
7298
7306
  }
7299
7307
 
7300
7308
 
7301
-
7302
7309
  /*
7303
7310
  Document-method: Gosu::Image.insert
7304
7311
 
@@ -7353,7 +7360,6 @@ fail:
7353
7360
  }
7354
7361
 
7355
7362
 
7356
-
7357
7363
  /*
7358
7364
  Document-method: Gosu::Image.inspect
7359
7365
 
@@ -11589,7 +11595,7 @@ SWIG_InitializeModule(void *clientdata) {
11589
11595
 
11590
11596
  /* Now work on filling in swig_module.types */
11591
11597
  #ifdef SWIGRUNTIME_DEBUG
11592
- printf("SWIG_InitializeModule: size %d\n", swig_module.size);
11598
+ printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size);
11593
11599
  #endif
11594
11600
  for (i = 0; i < swig_module.size; ++i) {
11595
11601
  swig_type_info *type = 0;
@@ -11597,7 +11603,7 @@ SWIG_InitializeModule(void *clientdata) {
11597
11603
  swig_cast_info *cast;
11598
11604
 
11599
11605
  #ifdef SWIGRUNTIME_DEBUG
11600
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
11606
+ printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
11601
11607
  #endif
11602
11608
 
11603
11609
  /* if there is another module already loaded */
@@ -11673,7 +11679,7 @@ SWIG_InitializeModule(void *clientdata) {
11673
11679
  for (i = 0; i < swig_module.size; ++i) {
11674
11680
  int j = 0;
11675
11681
  swig_cast_info *cast = swig_module.cast_initial[i];
11676
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
11682
+ printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
11677
11683
  while (cast->type) {
11678
11684
  printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
11679
11685
  cast++;
@@ -11741,8 +11747,8 @@ SWIGEXPORT void Init_gosu(void) {
11741
11747
  rb_define_const(mGosu, "VERSION", SWIG_From_std_string(static_cast< std::string >(Gosu::VERSION)));
11742
11748
  rb_define_const(mGosu, "LICENSES", SWIG_From_std_string(static_cast< std::string >(Gosu::LICENSES)));
11743
11749
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
11744
- rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(14)));
11745
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(5)));
11750
+ rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(15)));
11751
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(0)));
11746
11752
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
11747
11753
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
11748
11754
  rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
@@ -11786,6 +11792,7 @@ SWIGEXPORT void Init_gosu(void) {
11786
11792
  rb_define_singleton_method(SwigClassColor.klass, "rgb", VALUEFUNC(_wrap_Color_rgb), -1);
11787
11793
  rb_define_singleton_method(SwigClassColor.klass, "rgba", VALUEFUNC(_wrap_Color_rgba), -1);
11788
11794
  rb_define_singleton_method(SwigClassColor.klass, "argb", VALUEFUNC(_wrap_Color_argb), -1);
11795
+ rb_define_method(SwigClassColor.klass, "to_i", VALUEFUNC(_wrap_Color_to_i), -1);
11789
11796
  rb_define_method(SwigClassColor.klass, "dup", VALUEFUNC(_wrap_Color_dup), -1);
11790
11797
  rb_define_method(SwigClassColor.klass, "inspect", VALUEFUNC(_wrap_Color_inspect), -1);
11791
11798
  rb_define_method(SwigClassColor.klass, "==", VALUEFUNC(_wrap_Color___eq__), -1);
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 3.0.12
3
+ * Version 4.0.1
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
@@ -82,39 +82,49 @@ Gosu::Bitmap Gosu::TexChunk::to_bitmap() const
82
82
  return texture->to_bitmap(x, y, w, h);
83
83
  }
84
84
 
85
- void Gosu::TexChunk::insert(const Bitmap& original, int x, int y)
85
+ void Gosu::TexChunk::insert(const Bitmap& original_bitmap, int x, int y)
86
86
  {
87
- Bitmap alternate;
88
- const Bitmap* bitmap = &original;
87
+ Bitmap clipped_bitmap;
88
+ const Bitmap* bitmap = &original_bitmap;
89
89
 
90
- if (x < 0 || y < 0 || x + original.width() > w || y + original.height() > h) {
91
- int offset_x = 0, offset_y = 0;
92
- int trimmed_width = original.width(), trimmed_height = original.height();
90
+ // If inserting the bitmap at the given position exceeds the boundaries of the space allocated
91
+ // for this image on the texture, we need to clip the bitmap and insert the clipped version
92
+ // instead.
93
+ if (x < 0 || y < 0 || x + original_bitmap.width() > w || y + original_bitmap.height() > h) {
94
+ // How many pixels to remove at the top and left sides.
95
+ int clip_left = 0, clip_top = 0;
96
+ // How large the clipped version needs to be.
97
+ int clipped_width = original_bitmap.width(), clipped_height = original_bitmap.height();
98
+
99
+ // Clip away pixels on the left side, if necessary.
93
100
  if (x < 0) {
94
- offset_x = x;
95
- trimmed_width += x;
101
+ clip_left = -x;
102
+ clipped_width -= -x;
96
103
  x = 0;
97
104
  }
105
+ // Clip away pixels at the top, if necessary.
98
106
  if (y < 0) {
99
- offset_y = y;
100
- trimmed_height += y;
107
+ clip_top = -y;
108
+ clipped_height -= -y;
101
109
  y = 0;
102
110
  }
103
- if (x + trimmed_width > w) {
104
- trimmed_width -= (w - x - trimmed_width);
111
+ // Clip away pixels on the right side, if necessary.
112
+ if (x + clipped_width > w) {
113
+ clipped_width = (w - x);
105
114
  }
106
- if (y + trimmed_height > h) {
107
- trimmed_height -= (h - y - trimmed_height);
115
+ // Clip away pixels on the bottom, if necessary.
116
+ if (y + clipped_height > h) {
117
+ clipped_height = (h - y);
108
118
  }
109
119
 
110
- if (trimmed_width <= 0 || trimmed_height <= 0) return;
120
+ if (clipped_width <= 0 || clipped_height <= 0) return;
111
121
 
112
- alternate.resize(trimmed_width, trimmed_height);
113
- alternate.insert(original, offset_x, offset_y);
114
- bitmap = &alternate;
122
+ clipped_bitmap.resize(clipped_width, clipped_height);
123
+ clipped_bitmap.insert(original_bitmap, -clip_left, -clip_top);
124
+ bitmap = &clipped_bitmap;
115
125
  }
116
126
 
117
127
  glBindTexture(GL_TEXTURE_2D, tex_name());
118
128
  glTexSubImage2D(GL_TEXTURE_2D, 0, this->x + x, this->y + y, bitmap->width(), bitmap->height(),
119
- Color::GL_FORMAT, GL_UNSIGNED_BYTE, bitmap->data());
129
+ Color::GL_FORMAT, GL_UNSIGNED_BYTE, bitmap->data());
120
130
  }
@@ -33,6 +33,7 @@ Gosu::Bitmap Gosu::layout_text(const string& text, const string& font_name,
33
33
  double font_height, double line_spacing,
34
34
  int width, Alignment align, unsigned font_flags)
35
35
  {
36
+ // Escape all markup and delegate to layout_markup.
36
37
  return layout_markup(escape_markup(text), font_name,
37
38
  font_height, line_spacing,
38
39
  width, align, font_flags);
@@ -58,7 +58,7 @@ void Gosu::TextBuilder::flush_current_line(EndOfLineReason reason)
58
58
  }
59
59
 
60
60
  double whitespace_factor = 1.0;
61
- if (align == AL_JUSTIFY && reason == LINE_TOO_LONG) {
61
+ if (align == AL_JUSTIFY && whitespace_width != 0 && reason == LINE_TOO_LONG) {
62
62
  whitespace_factor = (result.width() - words_width) / whitespace_width;
63
63
  }
64
64
 
@@ -132,7 +132,7 @@ void Gosu::TextBuilder::feed_word(vector<FormattedString>&& word)
132
132
  current_line.emplace_back(new_word);
133
133
  current_line_width += new_word.width;
134
134
 
135
- if (current_line_width > result.width() || new_word.is_end_of_line) {
136
- flush_current_line(new_word.is_end_of_line ? END_OF_PARAGRAPH : LINE_TOO_LONG);
135
+ if (new_word.is_end_of_line) {
136
+ flush_current_line(END_OF_PARAGRAPH);
137
137
  }
138
138
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.6.pre1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-18 00:00:00.000000000 Z
11
+ date: 2020-01-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  2D game development library.
@@ -163,11 +163,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
163
  version: 1.9.3
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ">"
166
+ - - ">="
167
167
  - !ruby/object:Gem::Version
168
- version: 1.3.1
168
+ version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.0.3
170
+ rubygems_version: 3.0.6
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: 2D game development library.