gosu 1.5.0 → 2.0.0.pre6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +233 -0
  3. data/dependencies/SDL/include/SDL_assert.h +320 -0
  4. data/dependencies/SDL/include/SDL_atomic.h +414 -0
  5. data/dependencies/SDL/include/SDL_audio.h +1500 -0
  6. data/dependencies/SDL/include/{SDL3/SDL_bits.h → SDL_bits.h} +27 -47
  7. data/dependencies/SDL/include/{SDL3/SDL_blendmode.h → SDL_blendmode.h} +55 -59
  8. data/dependencies/SDL/include/SDL_clipboard.h +141 -0
  9. data/dependencies/SDL/include/SDL_config.h +331 -0
  10. data/dependencies/SDL/include/SDL_cpuinfo.h +594 -0
  11. data/dependencies/SDL/include/{SDL3/SDL_egl.h → SDL_egl.h} +8 -11
  12. data/dependencies/SDL/include/SDL_endian.h +348 -0
  13. data/dependencies/SDL/include/SDL_error.h +163 -0
  14. data/dependencies/SDL/include/SDL_events.h +1166 -0
  15. data/dependencies/SDL/include/SDL_filesystem.h +149 -0
  16. data/dependencies/SDL/include/SDL_gamecontroller.h +1074 -0
  17. data/dependencies/SDL/include/SDL_gesture.h +117 -0
  18. data/dependencies/SDL/include/SDL_guid.h +100 -0
  19. data/dependencies/SDL/include/SDL_haptic.h +1341 -0
  20. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  21. data/dependencies/SDL/include/SDL_hints.h +2613 -0
  22. data/dependencies/SDL/include/SDL_joystick.h +1069 -0
  23. data/dependencies/SDL/include/SDL_keyboard.h +353 -0
  24. data/dependencies/SDL/include/SDL_keycode.h +358 -0
  25. data/dependencies/SDL/include/SDL_loadso.h +115 -0
  26. data/dependencies/SDL/include/{SDL3/SDL_locale.h → SDL_locale.h} +24 -40
  27. data/dependencies/SDL/include/SDL_log.h +404 -0
  28. data/dependencies/SDL/include/SDL_main.h +282 -0
  29. data/dependencies/SDL/include/{SDL3/SDL_messagebox.h → SDL_messagebox.h} +48 -85
  30. data/dependencies/SDL/include/{SDL3/SDL_metal.h → SDL_metal.h} +29 -29
  31. data/dependencies/SDL/include/{SDL3/SDL_misc.h → SDL_misc.h} +12 -13
  32. data/dependencies/SDL/include/SDL_mouse.h +464 -0
  33. data/dependencies/SDL/include/SDL_mutex.h +545 -0
  34. data/dependencies/SDL/include/SDL_name.h +33 -0
  35. data/dependencies/SDL/include/{SDL3/SDL_opengl.h → SDL_opengl.h} +252 -1221
  36. data/dependencies/SDL/include/{SDL3/SDL_opengles.h → SDL_opengles.h} +7 -6
  37. data/dependencies/SDL/include/{SDL3/SDL_opengles2.h → SDL_opengles2.h} +11 -10
  38. data/dependencies/SDL/include/SDL_pixels.h +644 -0
  39. data/dependencies/SDL/include/SDL_platform.h +261 -0
  40. data/dependencies/SDL/include/{SDL3/SDL_power.h → SDL_power.h} +19 -40
  41. data/dependencies/SDL/include/SDL_quit.h +58 -0
  42. data/dependencies/SDL/include/SDL_rect.h +376 -0
  43. data/dependencies/SDL/include/SDL_render.h +1924 -0
  44. data/dependencies/SDL/include/SDL_revision.h +7 -0
  45. data/dependencies/SDL/include/SDL_rwops.h +841 -0
  46. data/dependencies/SDL/include/{SDL3/SDL_scancode.h → SDL_scancode.h} +68 -60
  47. data/dependencies/SDL/include/SDL_sensor.h +322 -0
  48. data/dependencies/SDL/include/SDL_shape.h +155 -0
  49. data/dependencies/SDL/include/SDL_stdinc.h +838 -0
  50. data/dependencies/SDL/include/SDL_surface.h +997 -0
  51. data/dependencies/SDL/include/SDL_system.h +623 -0
  52. data/dependencies/SDL/include/SDL_syswm.h +386 -0
  53. data/dependencies/SDL/include/{SDL3/SDL_test.h → SDL_test.h} +22 -16
  54. data/dependencies/SDL/include/{SDL3/SDL_test_assert.h → SDL_test_assert.h} +34 -27
  55. data/dependencies/SDL/include/{SDL3/SDL_test_common.h → SDL_test_common.h} +52 -109
  56. data/dependencies/SDL/include/{SDL3/SDL_test_compare.h → SDL_test_compare.h} +14 -22
  57. data/dependencies/SDL/include/{SDL3/SDL_test_crc32.h → SDL_test_crc32.h} +30 -27
  58. data/dependencies/SDL/include/{SDL3/SDL_test_font.h → SDL_test_font.h} +49 -50
  59. data/dependencies/SDL/include/{SDL3/SDL_test_fuzzer.h → SDL_test_fuzzer.h} +79 -64
  60. data/dependencies/SDL/include/{SDL3/SDL_test_harness.h → SDL_test_harness.h} +30 -47
  61. data/dependencies/SDL/include/SDL_test_images.h +78 -0
  62. data/dependencies/SDL/include/{SDL3/SDL_platform.h → SDL_test_log.h} +26 -25
  63. data/dependencies/SDL/include/{SDL3/SDL_test_md5.h → SDL_test_md5.h} +28 -21
  64. data/dependencies/SDL/include/{SDL3/SDL_test_memory.h → SDL_test_memory.h} +16 -19
  65. data/dependencies/SDL/include/SDL_test_random.h +115 -0
  66. data/dependencies/SDL/include/SDL_thread.h +464 -0
  67. data/dependencies/SDL/include/SDL_timer.h +222 -0
  68. data/dependencies/SDL/include/SDL_touch.h +150 -0
  69. data/dependencies/SDL/include/{SDL3/SDL_copying.h → SDL_types.h} +9 -2
  70. data/dependencies/SDL/include/SDL_version.h +204 -0
  71. data/dependencies/SDL/include/SDL_video.h +2178 -0
  72. data/dependencies/SDL/include/SDL_vulkan.h +215 -0
  73. data/dependencies/SDL/include/begin_code.h +187 -0
  74. data/dependencies/SDL/include/{SDL3/SDL_close_code.h → close_code.h} +6 -7
  75. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  76. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  77. data/dependencies/SDL_sound/SDL_sound.c +215 -136
  78. data/dependencies/SDL_sound/SDL_sound.h +725 -0
  79. data/dependencies/SDL_sound/SDL_sound_aiff.c +54 -55
  80. data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
  81. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +41 -24
  82. data/dependencies/SDL_sound/SDL_sound_flac.c +12 -32
  83. data/dependencies/SDL_sound/SDL_sound_internal.h +48 -33
  84. data/dependencies/SDL_sound/SDL_sound_modplug.c +29 -21
  85. data/dependencies/SDL_sound/SDL_sound_mp3.c +13 -35
  86. data/dependencies/SDL_sound/SDL_sound_raw.c +15 -14
  87. data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
  88. data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
  89. data/dependencies/SDL_sound/SDL_sound_vorbis.c +25 -34
  90. data/dependencies/SDL_sound/SDL_sound_wav.c +82 -86
  91. data/dependencies/SDL_sound/dr_flac.h +1281 -1845
  92. data/dependencies/SDL_sound/dr_mp3.h +617 -1035
  93. data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
  94. data/dependencies/SDL_sound/libmodplug/libmodplug.h +4 -5
  95. data/dependencies/SDL_sound/libmodplug/load_ams.c +3 -6
  96. data/dependencies/SDL_sound/libmodplug/load_dsm.c +1 -2
  97. data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
  98. data/dependencies/SDL_sound/libmodplug/modplug.h +1 -2
  99. data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
  100. data/dependencies/SDL_sound/libmodplug/sndfile.c +0 -3
  101. data/dependencies/SDL_sound/libmodplug/sndmix.c +3 -7
  102. data/dependencies/SDL_sound/stb_vorbis.h +343 -397
  103. data/dependencies/mojoAL/AL/alc.h +2 -2
  104. data/dependencies/mojoAL/mojoal.c +1878 -2113
  105. data/dependencies/stb/stb_image.h +1381 -1192
  106. data/dependencies/stb/stb_image_write.h +129 -329
  107. data/dependencies/stb/stb_truetype.h +60 -304
  108. data/dependencies/utf8proc/utf8proc.c +75 -133
  109. data/dependencies/utf8proc/utf8proc.h +50 -131
  110. data/dependencies/utf8proc/utf8proc_data.h +15658 -16213
  111. data/ext/gosu-ffi/extconf.rb +28 -11
  112. data/ext/gosu-ffi/gosu-ffi.def +0 -3
  113. data/ffi/Gosu.cpp +29 -52
  114. data/ffi/Gosu.h +4 -4
  115. data/ffi/Gosu_Color.cpp +36 -80
  116. data/ffi/Gosu_FFI_internal.h +13 -12
  117. data/ffi/Gosu_Font.cpp +11 -16
  118. data/ffi/Gosu_Font.h +4 -4
  119. data/ffi/Gosu_Image.cpp +36 -69
  120. data/ffi/Gosu_Image.h +5 -16
  121. data/include/Gosu/Bitmap.hpp +1 -1
  122. data/include/Gosu/Color.hpp +4 -5
  123. data/include/Gosu/Graphics.hpp +0 -2
  124. data/include/Gosu/Image.hpp +1 -1
  125. data/include/Gosu/Math.hpp +5 -5
  126. data/include/Gosu/Utility.hpp +1 -27
  127. data/include/Gosu/Version.hpp +2 -2
  128. data/lib/SDL2.dll +0 -0
  129. data/lib/gosu/channel.rb +0 -1
  130. data/lib/gosu/color.rb +13 -36
  131. data/lib/gosu/compat.rb +14 -106
  132. data/lib/gosu/constants.rb +24 -24
  133. data/lib/gosu/ffi.rb +13 -24
  134. data/lib/gosu/font.rb +13 -19
  135. data/lib/gosu/gosu.rb +61 -101
  136. data/lib/gosu/image.rb +34 -72
  137. data/lib/gosu/sample.rb +0 -1
  138. data/lib/gosu/song.rb +0 -1
  139. data/lib/gosu/text_input.rb +1 -15
  140. data/lib/gosu/window.rb +10 -31
  141. data/lib64/SDL2.dll +0 -0
  142. data/rdoc/gosu.rb +0 -2
  143. data/src/Audio.cpp +16 -22
  144. data/src/AudioFileSDLSound.cpp +5 -5
  145. data/src/BinPacker.cpp +4 -5
  146. data/src/Bitmap.cpp +9 -16
  147. data/src/Buffer.cpp +14 -5
  148. data/src/ClipRectStack.hpp +83 -17
  149. data/src/Directories.cpp +1 -1
  150. data/src/DrawOp.hpp +17 -14
  151. data/src/DrawOpQueue.hpp +31 -25
  152. data/src/Font.cpp +1 -1
  153. data/src/GosuGLView.cpp +7 -1
  154. data/src/Graphics.cpp +25 -32
  155. data/src/GraphicsImpl.hpp +24 -0
  156. data/src/Image.cpp +2 -2
  157. data/src/Input.cpp +70 -66
  158. data/src/Macro.cpp +26 -43
  159. data/src/Macro.hpp +16 -22
  160. data/src/Math.cpp +7 -20
  161. data/src/OffScreenTarget.cpp +10 -3
  162. data/src/OpenGLContext.cpp +8 -7
  163. data/src/OpenGLContext.hpp +2 -2
  164. data/src/RenderState.hpp +54 -30
  165. data/src/Resolution.cpp +38 -48
  166. data/src/TexChunk.cpp +2 -2
  167. data/src/TextInput.cpp +9 -9
  168. data/src/Texture.cpp +1 -1
  169. data/src/TiledDrawable.cpp +7 -6
  170. data/src/TrueTypeFontUnix.cpp +9 -12
  171. data/src/Utility.cpp +26 -39
  172. data/src/UtilityWin.cpp +2 -6
  173. data/src/Window.cpp +34 -54
  174. metadata +93 -99
  175. data/dependencies/SDL/include/SDL3/SDL.h +0 -91
  176. data/dependencies/SDL/include/SDL3/SDL_assert.h +0 -710
  177. data/dependencies/SDL/include/SDL3/SDL_asyncio.h +0 -550
  178. data/dependencies/SDL/include/SDL3/SDL_atomic.h +0 -692
  179. data/dependencies/SDL/include/SDL3/SDL_audio.h +0 -2382
  180. data/dependencies/SDL/include/SDL3/SDL_begin_code.h +0 -553
  181. data/dependencies/SDL/include/SDL3/SDL_camera.h +0 -535
  182. data/dependencies/SDL/include/SDL3/SDL_clipboard.h +0 -331
  183. data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +0 -374
  184. data/dependencies/SDL/include/SDL3/SDL_dialog.h +0 -343
  185. data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +0 -234
  186. data/dependencies/SDL/include/SDL3/SDL_endian.h +0 -645
  187. data/dependencies/SDL/include/SDL3/SDL_error.h +0 -226
  188. data/dependencies/SDL/include/SDL3/SDL_events.h +0 -1651
  189. data/dependencies/SDL/include/SDL3/SDL_filesystem.h +0 -537
  190. data/dependencies/SDL/include/SDL3/SDL_gamepad.h +0 -1657
  191. data/dependencies/SDL/include/SDL3/SDL_gpu.h +0 -4637
  192. data/dependencies/SDL/include/SDL3/SDL_guid.h +0 -106
  193. data/dependencies/SDL/include/SDL3/SDL_haptic.h +0 -1461
  194. data/dependencies/SDL/include/SDL3/SDL_hidapi.h +0 -571
  195. data/dependencies/SDL/include/SDL3/SDL_hints.h +0 -5041
  196. data/dependencies/SDL/include/SDL3/SDL_init.h +0 -508
  197. data/dependencies/SDL/include/SDL3/SDL_intrin.h +0 -410
  198. data/dependencies/SDL/include/SDL3/SDL_iostream.h +0 -1379
  199. data/dependencies/SDL/include/SDL3/SDL_joystick.h +0 -1385
  200. data/dependencies/SDL/include/SDL3/SDL_keyboard.h +0 -615
  201. data/dependencies/SDL/include/SDL3/SDL_keycode.h +0 -348
  202. data/dependencies/SDL/include/SDL3/SDL_loadso.h +0 -145
  203. data/dependencies/SDL/include/SDL3/SDL_log.h +0 -541
  204. data/dependencies/SDL/include/SDL3/SDL_main.h +0 -704
  205. data/dependencies/SDL/include/SDL3/SDL_main_impl.h +0 -149
  206. data/dependencies/SDL/include/SDL3/SDL_mouse.h +0 -813
  207. data/dependencies/SDL/include/SDL3/SDL_mutex.h +0 -1117
  208. data/dependencies/SDL/include/SDL3/SDL_oldnames.h +0 -1339
  209. data/dependencies/SDL/include/SDL3/SDL_pen.h +0 -198
  210. data/dependencies/SDL/include/SDL3/SDL_pixels.h +0 -1441
  211. data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +0 -497
  212. data/dependencies/SDL/include/SDL3/SDL_process.h +0 -441
  213. data/dependencies/SDL/include/SDL3/SDL_properties.h +0 -572
  214. data/dependencies/SDL/include/SDL3/SDL_rect.h +0 -528
  215. data/dependencies/SDL/include/SDL3/SDL_render.h +0 -3034
  216. data/dependencies/SDL/include/SDL3/SDL_revision.h +0 -56
  217. data/dependencies/SDL/include/SDL3/SDL_sensor.h +0 -321
  218. data/dependencies/SDL/include/SDL3/SDL_stdinc.h +0 -6186
  219. data/dependencies/SDL/include/SDL3/SDL_storage.h +0 -686
  220. data/dependencies/SDL/include/SDL3/SDL_surface.h +0 -1769
  221. data/dependencies/SDL/include/SDL3/SDL_system.h +0 -840
  222. data/dependencies/SDL/include/SDL3/SDL_test_log.h +0 -83
  223. data/dependencies/SDL/include/SDL3/SDL_thread.h +0 -602
  224. data/dependencies/SDL/include/SDL3/SDL_time.h +0 -249
  225. data/dependencies/SDL/include/SDL3/SDL_timer.h +0 -454
  226. data/dependencies/SDL/include/SDL3/SDL_touch.h +0 -184
  227. data/dependencies/SDL/include/SDL3/SDL_tray.h +0 -544
  228. data/dependencies/SDL/include/SDL3/SDL_version.h +0 -198
  229. data/dependencies/SDL/include/SDL3/SDL_video.h +0 -3497
  230. data/dependencies/SDL/include/SDL3/SDL_vulkan.h +0 -287
  231. data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
  232. data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
  233. data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +0 -755
  234. data/lib/SDL3.dll +0 -0
  235. data/lib64/SDL3.dll +0 -0
  236. data/src/ClipRectStack.cpp +0 -38
  237. /data/dependencies/SDL/include/{SDL3/SDL_opengl_glext.h → SDL_opengl_glext.h} +0 -0
  238. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2.h → SDL_opengles2_gl2.h} +0 -0
  239. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2ext.h → SDL_opengles2_gl2ext.h} +0 -0
  240. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2platform.h → SDL_opengles2_gl2platform.h} +0 -0
  241. /data/dependencies/SDL/include/{SDL3/SDL_opengles2_khrplatform.h → SDL_opengles2_khrplatform.h} +0 -0
data/lib/gosu/compat.rb CHANGED
@@ -9,36 +9,26 @@ module Gosu
9
9
  klass.class_eval {
10
10
  old = "_deprecated_#{name}"
11
11
  alias_method old, name
12
- define_method name do |*args, **kwargs, &block|
12
+ define_method name do |*args, &block|
13
13
  Gosu.deprecation_message(self, name, repl)
14
- send old, *args, **kwargs, &block
14
+ send old, *args, &block
15
15
  end
16
16
  }
17
17
  end
18
18
 
19
- # The old C extension accepted options as a trailing Hash (`options = {}`).
20
- # -> Convert this to keyword arguments to support e.g. `super(640, 480, options)`.
21
- # Returns the args and kwargs to pass to the new method.
22
- def self.extract_legacy_options(args, kwargs, method_name)
23
- return args, kwargs unless kwargs.empty? and args.last.is_a?(Hash)
24
-
25
- deprecation_message("Passing options as a Hash to #{method_name} has been deprecated, use keyword arguments instead")
26
- return args[0...-1], args.last
27
- end
28
-
29
19
  def self.deprecation_message(klass_or_full_message, name = nil, repl = nil)
30
20
  @@_deprecations_shown ||= {}
31
21
 
32
22
  msg = if klass_or_full_message.is_a?(String) and name.nil? and repl.nil?
33
23
  [ "DEPRECATION WARNING: #{klass_or_full_message},
34
- \n#Called from #{caller.reject { |line| line.start_with?(__dir__) }.first(DEPRECATION_STACKTRACE_LINES)}"
24
+ \n#Called from #{caller[1, DEPRECATION_STACKTRACE_LINES]}"
35
25
  ]
36
26
  else
37
27
  # Class method deprecation warnings result in something like this:
38
28
  # #<Class:Gosu::Window>::button_id_to_char is deprecated
39
29
  # Remove the instance-inspect stuff to make it look a bit better:
40
- target = if klass_or_full_message.kind_of?(Module)
41
- "#{klass_or_full_message.to_s.gsub(/#<Class:(.*)>/, '\1')}::"
30
+ if klass_or_full_message.kind_of?(Module)
31
+ target = "#{klass_or_full_message.to_s.gsub(/#<Class:(.*)>/, '\1')}::"
42
32
  else
43
33
  "#{klass_or_full_message.class}#"
44
34
  end
@@ -65,36 +55,18 @@ end
65
55
  Gosu.deprecate Gosu::Color, :bgr, :none
66
56
  Gosu.deprecate Gosu::Color, :abgr, :none
67
57
 
68
- class Gosu::Color
69
- alias_method :initialize_without_rgb, :initialize
70
-
71
- # The C++ constructor Color(red, green, blue) used to be available in Ruby as well.
72
- def initialize(*args)
73
- if args.size == 3
74
- Gosu.deprecation_message("Color.new(r, g, b) has been deprecated, use Color.rgb(r, g, b) instead")
75
- initialize_without_rgb(255, *args)
76
- else
77
- initialize_without_rgb(*args)
78
- end
79
- end
80
- end
81
-
82
58
  # No need to pass a Window to Image.
83
59
  class Gosu::Image
84
60
  alias_method :initialize_without_window, :initialize
85
61
 
86
62
  def initialize(*args, **kwargs)
87
- args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image#initialize")
88
-
89
63
  if args[0].is_a? Gosu::Window
90
- # Old method signature: initialize(window, file_or_image, tileable = false, *rect)
64
+ # Old method signature: initialize(window, file_or_image, tileable)
91
65
  Gosu.deprecation_message("Passing a Window to Image#initialize has been deprecated in Gosu 0.9, and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
92
66
  if args.size == 7
93
- initialize_without_window args[1], tileable: args[2], rect: args[3..-1], **kwargs
67
+ initialize_without_window args[1], tileable: args[2], rect: args[3..-1]
94
68
  elsif args.size == 3
95
- initialize_without_window args[1], tileable: args[2], **kwargs
96
- elsif args.size == 2
97
- initialize_without_window args[1], **kwargs
69
+ initialize_without_window args[1], tileable: args[2]
98
70
  else
99
71
  raise ArgumentError, "wrong number of arguments (given #{args.size})"
100
72
  end
@@ -105,19 +77,13 @@ class Gosu::Image
105
77
 
106
78
  class << self
107
79
  alias_method :from_text_without_window, :from_text
108
- alias_method :from_markup_without_hash, :from_markup
109
- alias_method :load_tiles_without_window, :load_tiles
110
80
  end
111
81
 
112
82
  def self.from_text(*args, **kwargs)
113
- args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image.from_text")
114
-
115
- if args.first.is_a? Gosu::Window and args.size == 4
116
- # Old method signature: from_text(window, text, font_name, font_height)
83
+ if args.size == 4
117
84
  Gosu.deprecation_message("Passing a Window to Image.from_text has been deprecated in Gosu 0.9 and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
118
85
  from_text_without_window(args[1], args[3], font: args[2])
119
- elsif args.first.is_a? Gosu::Window and args.size == 7
120
- # Old method signature: from_text(window, text, font_name, font_height, line_spacing, width, align)
86
+ elsif args.size == 7
121
87
  Gosu.deprecation_message("Passing a Window to Image.from_text has been deprecated in Gosu 0.9 and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
122
88
  from_text_without_window(args[1], args[3],
123
89
  font: args[2], spacing: args[4], width: args[5],
@@ -127,18 +93,14 @@ class Gosu::Image
127
93
  end
128
94
  end
129
95
 
130
- def self.from_markup(*args, **kwargs)
131
- args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image.from_markup")
132
- from_markup_without_hash(*args, **kwargs)
96
+ class << self
97
+ alias_method :load_tiles_without_window, :load_tiles
133
98
  end
134
99
 
135
100
  def self.load_tiles(*args, **kwargs)
136
- args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image.load_tiles")
137
-
138
101
  if args.first.is_a? Gosu::Window
139
102
  # Old method signature: load_tiles(window, file_or_image, w, h, tileable)
140
- Gosu.deprecation_message("Passing a Window to Image.load_tiles has been deprecated in Gosu 0.9, and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
141
- load_tiles_without_window(args[1], args[2], args[3], tileable: args[4], **kwargs)
103
+ load_tiles_without_window(args[1], args[2], args[3], tileable: args[4])
142
104
  else
143
105
  load_tiles_without_window(*args, **kwargs)
144
106
  end
@@ -171,23 +133,7 @@ class Gosu::Song
171
133
  end
172
134
  end
173
135
 
174
- # No need to pass a Window to Font.
175
136
  class Gosu::Font
176
- alias_method :initialize_without_window, :initialize
177
-
178
- # Old method signature: Font.new(window, name, height)
179
- def initialize(*args, **kwargs)
180
- args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Font#initialize")
181
-
182
- if args.first.is_a? Gosu::Window
183
- Gosu.deprecation_message("Passing a Window to Font#initialize has been deprecated in Gosu 0.9.")
184
- _, name, height = args
185
- initialize_without_window(height, name: name, **kwargs)
186
- else
187
- initialize_without_window(*args, **kwargs)
188
- end
189
- end
190
-
191
137
  alias_method :draw, :draw_markup
192
138
  Gosu.deprecate Gosu::Font, :draw, "Font#draw_text or Font#draw_markup"
193
139
 
@@ -201,16 +147,8 @@ class Gosu::Font
201
147
  Gosu.deprecate Gosu::Font, :draw_rot, "Font#draw with Gosu.rotate"
202
148
  end
203
149
 
150
+ # Moved some Window methods to the Gosu module.
204
151
  class Gosu::Window
205
- alias_method :initialize_without_hash, :initialize
206
-
207
- # Without this, an options Hash would be interpreted as the positional `fullscreen` argument.
208
- def initialize(*args, **kwargs)
209
- args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Window#initialize")
210
- initialize_without_hash(*args, **kwargs)
211
- end
212
-
213
- # Moved some Window methods to the Gosu module:
214
152
  # Class methods that have been turned into module methods.
215
153
  class << self
216
154
  def button_id_to_char(id)
@@ -240,33 +178,6 @@ class Gosu::Window
240
178
  Gosu.deprecate Gosu::Window, :set_mouse_position, "Window#mouse_x= and Window#mouse_y="
241
179
  end
242
180
 
243
- module Gosu
244
- alias_method :render_without_hash, :render
245
- module_function :render_without_hash
246
-
247
- module_function def render(*args, **kwargs, &block)
248
- args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Gosu.render")
249
- render_without_hash(*args, **kwargs, &block)
250
- end
251
- end
252
-
253
- # The SWIG-based C extension exported these functions from Math.hpp. They have users in the wild.
254
- module Gosu
255
- %w(degrees_to_radians radians_to_degrees).each do |helper|
256
- define_method helper do |angle|
257
- Gosu.deprecation_message("Gosu.#{helper}(angle) has been deprecated, use angle.#{helper} instead")
258
- angle.send(helper)
259
- end
260
- module_function helper
261
- end
262
-
263
- def normalize_angle(angle)
264
- Gosu.deprecation_message("Gosu.normalize_angle(angle) has been deprecated, use angle % 360.0 instead")
265
- angle % 360.0
266
- end
267
- module_function :normalize_angle
268
- end
269
-
270
181
  # Constants
271
182
  module Gosu
272
183
  # This was renamed because it's not actually a "copyright notice".
@@ -300,9 +211,6 @@ module Gosu
300
211
 
301
212
  deprecate_constant :Button
302
213
 
303
- # The size of the textures that Gosu uses internally (Gosu/Drawable.hpp). TexPlay relies on this.
304
- MAX_TEXTURE_SIZE = 1024
305
-
306
214
  def self.language
307
215
  @language_cache ||= (user_languages.first || "en_US")
308
216
  end
@@ -318,29 +318,27 @@ module GosuFFI
318
318
 
319
319
  constants.each do |const|
320
320
  attach_variable const, "Gosu_#{const}", :uint32
321
- # Reading an attached variable goes through FFI every time, which is too slow for every draw call.
322
- # The values never change, so read them once and store them as Ruby constants.
323
- value = GosuFFI.send(const)
324
- const_set(const, value)
325
- Gosu.const_set(const, value) if const =~ /^(KB|MS|GP)_/
321
+ Gosu.const_set(const, GosuFFI.send(const)) if const =~ /^(KB|MS|GP)_/
326
322
  end
327
323
 
328
324
  Gosu.const_set("VERSION", GosuFFI.Gosu_version())
329
325
  Gosu.const_set("LICENSES", GosuFFI.Gosu_licenses())
330
- Gosu.const_set("MAJOR_VERSION", MAJOR_VERSION)
331
- Gosu.const_set("MINOR_VERSION", MINOR_VERSION)
332
- Gosu.const_set("POINT_VERSION", POINT_VERSION)
326
+ Gosu.const_set("MAJOR_VERSION", GosuFFI.MAJOR_VERSION)
327
+ Gosu.const_set("MINOR_VERSION", GosuFFI.MINOR_VERSION)
328
+ Gosu.const_set("POINT_VERSION", GosuFFI.POINT_VERSION)
333
329
 
334
330
  # SEE: https://github.com/gosu/gosu/blob/master/Gosu/GraphicsBase.hpp
335
331
 
336
332
  def self.blend_mode(mode)
337
333
  case mode
338
334
  when :default
339
- BM_DEFAULT
335
+ GosuFFI.BM_DEFAULT
340
336
  when :additive, :add
341
- BM_ADD
337
+ GosuFFI.BM_ADD
342
338
  when :multiply
343
- BM_MULTIPLY
339
+ GosuFFI.BM_MULTIPLY
340
+ when Numeric
341
+ mode
344
342
  else
345
343
  raise ArgumentError, "No such blend mode: #{mode}"
346
344
  end
@@ -348,21 +346,23 @@ module GosuFFI
348
346
 
349
347
  def self.image_flags(retro: false, tileable: false)
350
348
  flags = 0
351
- flags |= IF_RETRO if retro
352
- flags |= IF_TILEABLE if tileable
349
+ flags |= GosuFFI.IF_RETRO if retro
350
+ flags |= GosuFFI.IF_TILEABLE if tileable
353
351
  flags
354
352
  end
355
353
 
356
354
  def self.font_alignment_flags(flags)
357
355
  case flags
358
356
  when :left
359
- AL_LEFT
357
+ GosuFFI.AL_LEFT
360
358
  when :right
361
- AL_RIGHT
359
+ GosuFFI.AL_RIGHT
362
360
  when :center
363
- AL_CENTER
361
+ GosuFFI.AL_CENTER
364
362
  when :justify
365
- AL_JUSTIFY
363
+ GosuFFI.AL_JUSTIFY
364
+ when Numeric
365
+ flags
366
366
  else
367
367
  raise ArgumentError, "No such font alignment: #{flags}"
368
368
  end
@@ -370,17 +370,17 @@ module GosuFFI
370
370
 
371
371
  def self.font_flags(bold, italic, underline)
372
372
  flags = 0
373
- flags |= FF_BOLD if bold
374
- flags |= FF_ITALIC if italic
375
- flags |= FF_UNDERLINE if underline
373
+ flags |= GosuFFI.FF_BOLD if bold
374
+ flags |= GosuFFI.FF_ITALIC if italic
375
+ flags |= GosuFFI.FF_UNDERLINE if underline
376
376
  flags
377
377
  end
378
378
 
379
379
  def self.window_flags(fullscreen: false, resizable: false, borderless: false)
380
- flags = WF_WINDOWED
381
- flags |= WF_FULLSCREEN if fullscreen
382
- flags |= WF_RESIZABLE if resizable
383
- flags |= WF_BORDERLESS if borderless
380
+ flags = GosuFFI.WF_WINDOWED
381
+ flags |= GosuFFI.WF_FULLSCREEN if fullscreen
382
+ flags |= GosuFFI.WF_RESIZABLE if resizable
383
+ flags |= GosuFFI.WF_BORDERLESS if borderless
384
384
  flags
385
385
  end
386
386
  end
data/lib/gosu/ffi.rb CHANGED
@@ -23,7 +23,7 @@ module GosuFFI
23
23
 
24
24
  attach_function :Gosu_fps, [], :int
25
25
  attach_function :Gosu_flush, [], :void
26
- attach_function :Gosu_milliseconds, [], :uint64
26
+ attach_function :Gosu_milliseconds, [], :long
27
27
  attach_function :Gosu_default_font_name, [], :string
28
28
  attach_function :Gosu_user_languages, [:_callback_with_string, :pointer], :void
29
29
 
@@ -50,12 +50,12 @@ module GosuFFI
50
50
  attach_function :Gosu_clipboard, [], :string
51
51
  attach_function :Gosu_set_clipboard, [:string], :void
52
52
 
53
- attach_function :Gosu_draw_line, [:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :bool
53
+ attach_function :Gosu_draw_line, [:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :void
54
54
  attach_function :Gosu_draw_triangle, [:double, :double, :uint32, :double, :double, :uint32,
55
- :double, :double, :uint32, :double, :uint32], :bool
55
+ :double, :double, :uint32, :double, :uint32], :void
56
56
  attach_function :Gosu_draw_quad, [:double, :double, :uint32, :double, :double, :uint32,
57
- :double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :bool
58
- attach_function :Gosu_draw_rect, [:double, :double, :double, :double, :uint32, :double, :uint32], :bool
57
+ :double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :void
58
+ attach_function :Gosu_draw_rect, [:double, :double, :double, :double, :uint32, :double, :uint32], :void
59
59
 
60
60
  attach_function :Gosu_offset_x, [:double, :double], :double
61
61
  attach_function :Gosu_offset_y, [:double, :double], :double
@@ -122,24 +122,23 @@ module GosuFFI
122
122
  attach_function :Gosu_Font_markup_width, [:pointer, :string], :double
123
123
 
124
124
  attach_function :Gosu_Font_draw_text, [:pointer, :string, :double, :double, :double,
125
- :double, :double, :uint32, :uint32], :bool
125
+ :double, :double, :uint32, :uint32], :void
126
126
  attach_function :Gosu_Font_draw_markup, [:pointer, :string, :double, :double, :double,
127
- :double, :double, :uint32, :uint32], :bool
127
+ :double, :double, :uint32, :uint32], :void
128
128
 
129
129
  attach_function :Gosu_Font_draw_text_rel, [:pointer, :string, :double, :double, :double,
130
- :double, :double, :double, :double, :uint32, :uint32], :bool
130
+ :double, :double, :double, :double, :uint32, :uint32], :void
131
131
  attach_function :Gosu_Font_draw_markup_rel, [:pointer, :string, :double, :double, :double,
132
- :double, :double, :double, :double, :uint32, :uint32], :bool
132
+ :double, :double, :double, :double, :uint32, :uint32], :void
133
133
 
134
134
  attach_function :Gosu_Font_set_image, [:pointer, :string, :uint32, :pointer], :void
135
135
 
136
136
  attach_function :Gosu_Image_create, [:string, :uint32], :pointer
137
- attach_function :Gosu_Image_create_from_rect, [:string, :int, :int, :int, :int, :uint32], :pointer
138
137
  attach_function :Gosu_Image_destroy, [:pointer], :void
139
138
 
140
139
  attach_function :Gosu_Image_create_from_markup, [:string, :string, :double, :int, :double, :uint32, :uint32, :uint32], :pointer
141
140
  attach_function :Gosu_Image_create_from_text, [:string, :string, :double, :int, :double, :uint32, :uint32, :uint32], :pointer
142
- attach_function :Gosu_Image_create_from_blob, [:pointer, :size_t, :int, :int, :int, :int, :int, :int, :uint32], :pointer
141
+ attach_function :Gosu_Image_create_from_blob, [:pointer, :ulong, :int, :int, :uint32], :pointer
143
142
  attach_function :Gosu_Image_create_from_subimage, [:pointer, :int, :int, :int, :int], :pointer
144
143
  attach_function :Gosu_Image_create_from_tiles, [:string, :int, :int, :_callback_with_image, :pointer, :uint32], :void
145
144
  attach_function :Gosu_Image_create_tiles_from_image, [:pointer, :int, :int, :_callback_with_image, :pointer, :uint32], :void
@@ -147,13 +146,11 @@ module GosuFFI
147
146
  attach_function :Gosu_Image_width, [:pointer], :int
148
147
  attach_function :Gosu_Image_height, [:pointer], :int
149
148
 
150
- attach_function :Gosu_Image_draw, [:pointer, :double, :double, :double, :double, :double, :uint32, :uint32], :bool
151
- attach_function :Gosu_Image_draw_quick, [:pointer, :double, :double, :double], :bool
149
+ attach_function :Gosu_Image_draw, [:pointer, :double, :double, :double, :double, :double, :uint32, :uint32], :void
152
150
  attach_function :Gosu_Image_draw_rot, [:pointer, :double, :double, :double, :double, :double, :double,
153
- :double, :double, :uint32, :uint32], :bool
154
- attach_function :Gosu_Image_draw_rot_quick, [:pointer, :double, :double, :double, :double], :bool
151
+ :double, :double, :uint32, :uint32], :void
155
152
  attach_function :Gosu_Image_draw_as_quad, [:pointer, :double, :double, :uint32, :double, :double, :uint32,
156
- :double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :bool
153
+ :double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :void
157
154
 
158
155
  attach_function :Gosu_Image_save, [:pointer, :string], :void
159
156
  attach_function :Gosu_Image_to_blob, [:pointer], :pointer
@@ -258,12 +255,4 @@ module GosuFFI
258
255
  end
259
256
  value
260
257
  end
261
-
262
- # Raises and forgets the first exception from a block passed to Gosu.gl(z), see Gosu.gl.
263
- def self.check_last_gl_error
264
- if (err = $gosu_gl_exception)
265
- $gosu_gl_exception = nil
266
- raise err
267
- end
268
- end
269
258
  end
data/lib/gosu/font.rb CHANGED
@@ -4,7 +4,6 @@ module Gosu
4
4
  __font = GosuFFI.Gosu_Font_create(height, name, GosuFFI.font_flags(bold, italic, underline), 0)
5
5
  GosuFFI.check_last_error
6
6
  @memory_pointer = FFI::AutoPointer.new(__font, GosuFFI.method(:Gosu_Font_destroy))
7
- self
8
7
  end
9
8
 
10
9
  def __pointer
@@ -16,40 +15,35 @@ module Gosu
16
15
  end
17
16
 
18
17
  def height
19
- # We can cache this, font sizes never change in Gosu.
20
- @height ||= GosuFFI.check_last_error(GosuFFI.Gosu_Font_height(__pointer))
18
+ GosuFFI.check_last_error(GosuFFI.Gosu_Font_height(__pointer))
21
19
  end
22
20
 
23
21
  def text_width(text, scale_x = 1)
24
22
  GosuFFI.check_last_error(GosuFFI.Gosu_Font_text_width(__pointer, text.to_s)) * scale_x
25
23
  end
26
24
 
27
- def markup_width(markup, scale_x = 1)
28
- GosuFFI.check_last_error(GosuFFI.Gosu_Font_markup_width(__pointer, markup.to_s)) * scale_x
25
+ def markup_width(text, scale_x = 1)
26
+ GosuFFI.check_last_error(GosuFFI.Gosu_Font_markup_width(__pointer, text.to_s)) * scale_x
29
27
  end
30
28
 
31
29
  def draw_text(text, x, y, z, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
32
- GosuFFI.check_last_error if not
33
- GosuFFI.Gosu_Font_draw_text(__pointer, text.to_s, x, y, z, scale_x, scale_y,
34
- GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
30
+ GosuFFI.Gosu_Font_draw_text(__pointer, text.to_s, x, y, z, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
31
+ GosuFFI.check_last_error
35
32
  end
36
33
 
37
- def draw_markup(markup, x, y, z, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
38
- GosuFFI.check_last_error if not
39
- GosuFFI.Gosu_Font_draw_markup(__pointer, markup.to_s, x, y, z, scale_x, scale_y,
40
- GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
34
+ def draw_markup(text, x, y, z, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
35
+ GosuFFI.Gosu_Font_draw_markup(__pointer, text.to_s, x, y, z, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
36
+ GosuFFI.check_last_error
41
37
  end
42
38
 
43
39
  def draw_text_rel(text, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
44
- GosuFFI.check_last_error if not
45
- GosuFFI.Gosu_Font_draw_text_rel(__pointer, text.to_s, x, y, z, rel_x, rel_y, scale_x, scale_y,
46
- GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
40
+ GosuFFI.Gosu_Font_draw_text_rel(__pointer, text.to_s, x, y, z, rel_x, rel_y, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
41
+ GosuFFI.check_last_error
47
42
  end
48
43
 
49
- def draw_markup_rel(markup, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
50
- GosuFFI.check_last_error if not
51
- GosuFFI.Gosu_Font_draw_markup_rel(__pointer, markup.to_s, x, y, z, rel_x, rel_y, scale_x, scale_y,
52
- GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
44
+ def draw_markup_rel(text, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
45
+ GosuFFI.Gosu_Font_draw_markup_rel(__pointer, text.to_s, x, y, z, rel_x, rel_y, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
46
+ GosuFFI.check_last_error
53
47
  end
54
48
 
55
49
  def []=(codepoint, image)