SDLRuby 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -19
  3. data/LICENSE.txt +21 -21
  4. data/README.md +31 -31
  5. data/Rakefile +12 -12
  6. data/SDLRuby.gemspec +38 -0
  7. data/examples/alert.rb +8 -0
  8. data/examples/window.rb +7 -0
  9. data/lib/SDLRuby/event/accessor.rb +2 -2
  10. data/lib/SDLRuby/event.rb +101 -101
  11. data/lib/SDLRuby/image/include/SDL_image.h.rb +61 -61
  12. data/lib/SDLRuby/mixer/include/SDL_mixer.h.rb +95 -95
  13. data/lib/SDLRuby/rw/operational.rb +116 -0
  14. data/lib/SDLRuby/rw/read_closure.rb +28 -0
  15. data/lib/SDLRuby/rw/seek_closure.rb +22 -0
  16. data/lib/SDLRuby/rw/size_closure.rb +21 -0
  17. data/lib/SDLRuby/rw/write_closure.rb +21 -0
  18. data/lib/SDLRuby/rw_ops/mem_close.rb +27 -0
  19. data/lib/SDLRuby/rw_ops/rw_object.rb +13 -107
  20. data/lib/SDLRuby/rw_ops.rb +40 -165
  21. data/lib/SDLRuby/sdl/include/SDL.h.rb +44 -44
  22. data/lib/SDLRuby/sdl/include/SDL_audio.h.rb +160 -160
  23. data/lib/SDLRuby/sdl/include/SDL_blendmode.h.rb +30 -30
  24. data/lib/SDLRuby/sdl/include/SDL_clipboard.h.rb +10 -10
  25. data/lib/SDLRuby/sdl/include/SDL_config.h.rb +13 -13
  26. data/lib/SDLRuby/sdl/include/SDL_cpuinfo.h.rb +27 -27
  27. data/lib/SDLRuby/sdl/include/SDL_endian.h.rb +12 -12
  28. data/lib/SDLRuby/sdl/include/SDL_error.h.rb +28 -28
  29. data/lib/SDLRuby/sdl/include/SDL_events.h.rb +472 -472
  30. data/lib/SDLRuby/sdl/include/SDL_filesystem.h.rb +6 -6
  31. data/lib/SDLRuby/sdl/include/SDL_gamecontroller.h.rb +147 -147
  32. data/lib/SDLRuby/sdl/include/SDL_gesture.h.rb +12 -12
  33. data/lib/SDLRuby/sdl/include/SDL_guid.h.rb +13 -13
  34. data/lib/SDLRuby/sdl/include/SDL_hints.h.rb +199 -199
  35. data/lib/SDLRuby/sdl/include/SDL_joystick.h.rb +131 -131
  36. data/lib/SDLRuby/sdl/include/SDL_keyboard.h.rb +35 -35
  37. data/lib/SDLRuby/sdl/include/SDL_keycode.h.rb +292 -292
  38. data/lib/SDLRuby/sdl/include/SDL_locale.h.rb +13 -13
  39. data/lib/SDLRuby/sdl/include/SDL_main.h.rb +3 -3
  40. data/lib/SDLRuby/sdl/include/SDL_messagebox.h.rb +58 -58
  41. data/lib/SDLRuby/sdl/include/SDL_misc.h.rb +5 -5
  42. data/lib/SDLRuby/sdl/include/SDL_mouse.h.rb +57 -57
  43. data/lib/SDLRuby/sdl/include/SDL_pixels.h.rb +285 -285
  44. data/lib/SDLRuby/sdl/include/SDL_platform.h.rb +3 -3
  45. data/lib/SDLRuby/sdl/include/SDL_power.h.rb +6 -6
  46. data/lib/SDLRuby/sdl/include/SDL_rect.h.rb +46 -46
  47. data/lib/SDLRuby/sdl/include/SDL_render.h.rb +131 -131
  48. data/lib/SDLRuby/sdl/include/SDL_revision.h.rb +2 -2
  49. data/lib/SDLRuby/sdl/include/SDL_rwops.h.rb +78 -78
  50. data/lib/SDLRuby/sdl/include/SDL_scancode.h.rb +252 -252
  51. data/lib/SDLRuby/sdl/include/SDL_sensor.h.rb +25 -25
  52. data/lib/SDLRuby/sdl/include/SDL_shape.h.rb +40 -40
  53. data/lib/SDLRuby/sdl/include/SDL_stdinc.h.rb +62 -62
  54. data/lib/SDLRuby/sdl/include/SDL_surface.h.rb +100 -100
  55. data/lib/SDLRuby/sdl/include/SDL_system.h.rb +6 -6
  56. data/lib/SDLRuby/sdl/include/SDL_syswm.h.rb +10 -10
  57. data/lib/SDLRuby/sdl/include/SDL_timer.h.rb +21 -21
  58. data/lib/SDLRuby/sdl/include/SDL_touch.h.rb +15 -15
  59. data/lib/SDLRuby/sdl/include/SDL_types.h.rb +3 -3
  60. data/lib/SDLRuby/sdl/include/SDL_version.h.rb +14 -14
  61. data/lib/SDLRuby/sdl/include/SDL_video.h.rb +264 -264
  62. data/lib/SDLRuby/sdl.rb +6 -6
  63. data/lib/SDLRuby/ttf/include/SDL_ttf.h.rb +54 -54
  64. data/lib/SDLRuby/version.rb +5 -5
  65. data/lib/SDLRuby/window/surfacer.rb +37 -37
  66. data/lib/SDLRuby.rb +32 -16
  67. data/sig/SDLRuby.rbs +4 -4
  68. data/sig/lib/SDLRuby/event/accessor.rbs +157 -157
  69. data/sig/lib/SDLRuby/event/type.rbs +67 -67
  70. data/sig/lib/SDLRuby/event.rbs +47 -47
  71. data/sig/lib/SDLRuby/keyboard.rbs +25 -25
  72. data/sig/lib/SDLRuby/mouse.rbs +35 -35
  73. data/sig/lib/SDLRuby/sdl.rbs +655 -655
  74. data/sig/lib/SDLRuby/timer.rbs +7 -7
  75. metadata +12 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 808c30b69ff9a14dd61fae1fa5c6812a1be91e6313affb2a46ff136cbffcfeac
4
- data.tar.gz: 42794a0310f8329168a8237897d62dddf14cb14922d1db1d631570308708c8da
3
+ metadata.gz: 1410421c2582356d255e9f404030ef549289c7f317e4ea0f8dd2f5c3d55f98a2
4
+ data.tar.gz: 0cba1cb7eaafe022c66a853f5fad9a5a11a2f62d653ca16434107e99a45c23ca
5
5
  SHA512:
6
- metadata.gz: c840b525923d6e083094d5783ad70057f758dbd4be86f1660d16f7873eeb9e12bf5bdfdfb739c0664287eda2bde514926bc8e0fffd25f1822001482b024b3820
7
- data.tar.gz: 1bec511a45a3786d35c407d51c66b3e75fb0b339835b2d00e492cce65d73c98873a9433043b8faa43f3ac6117988746c4178c14b7468d68a8873fd99a0d45785
6
+ metadata.gz: 4e8f629bd1e20e47acca1fd336d0dcea4128049be1393182e2ad52693daccfa6aed98379ee3f0bd4a3a63d5bbd53c6d467463b1f25b33860cde2f45b7f905d88
7
+ data.tar.gz: 9eddb90e1e1c6af15991c4807e7bf4bed6fab5613e37f01c5bf19bb765e5149b70b6d3e0c0b0781fe4f15a10fcf35afd9df91027c6f12c578a95220d417f9466
data/CHANGELOG.md CHANGED
@@ -1,19 +1,29 @@
1
- ## [Unreleased]
2
-
3
- ## [0.3.0] - 2023-09-19
4
- - Implemented Mouse Module.
5
- - Implementation of the Timer Module.
6
- - Implemented Keyboard Module.
7
- - Specification and implementation of SDL.init, SDL.init?, and SDL.quit.
8
-
9
- ## [0.2.1] - 2023-09-13
10
-
11
- - Memory leak fix on event retrieval failure.
12
-
13
- ## [0.2.0] - 2023-09-13
14
-
15
- - Implementation of the Event Object. SDL event queue is now available.
16
-
17
- ## [0.1.0] - 2023-08-30
18
-
19
- - Initial release
1
+ ## [Unreleased]
2
+
3
+ ## [0.4.0] - 2024-09-13
4
+
5
+ - Added fiddle to Gemfile to support Ruby 3.5.
6
+ - Changed loading of SDL library and SDL extension libraries to be handled by SDLRuby class methods load_sdl and load_sdl_*.
7
+ - Added sample code to the examples directory.
8
+ - Made several minor modifications.
9
+
10
+ ## [0.3.1] - 2023-09-28
11
+ - Refactored RWOps class.
12
+
13
+ ## [0.3.0] - 2023-09-19
14
+ - Implemented Mouse Module.
15
+ - Implementation of the Timer Module.
16
+ - Implemented Keyboard Module.
17
+ - Specification and implementation of SDL.init, SDL.init?, and SDL.quit.
18
+
19
+ ## [0.2.1] - 2023-09-13
20
+
21
+ - Memory leak fix on event retrieval failure.
22
+
23
+ ## [0.2.0] - 2023-09-13
24
+
25
+ - Implementation of the Event Object. SDL event queue is now available.
26
+
27
+ ## [0.1.0] - 2023-08-30
28
+
29
+ - Initial release
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2023 shinokaro
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 shinokaro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,31 +1,31 @@
1
- # SDLRuby
2
-
3
- SDLRuby is a GEM that allows calling the SDL library from Ruby, enabling window creation, image display, audio playback, and more. It easily manages C pointers as Ruby objects, all written in 100% Ruby. Achieve multimedia programming simplicity.
4
-
5
- ## Installation
6
-
7
- Install the gem and add to the application's Gemfile by executing:
8
-
9
- $ bundle add SDLRuby
10
-
11
- If bundler is not being used to manage dependencies, install the gem by executing:
12
-
13
- $ gem install SDLRuby
14
-
15
- ## Usage
16
-
17
- **⚠️UNDER CONSTRUCTION⚠️**
18
-
19
- ## Development
20
-
21
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
22
-
23
- To install this gem onto your local machine, run `bundle exec rake install`.
24
-
25
- ## Contributing
26
-
27
- Bug reports and pull requests are welcome on GitHub at https://github.com/shinokaro/SDLRuby.
28
-
29
- ## License
30
-
31
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1
+ # SDLRuby
2
+
3
+ SDLRuby is a GEM that allows calling the SDL library from Ruby, enabling window creation, image display, audio playback, and more. It easily manages C pointers as Ruby objects, all written in 100% Ruby. Achieve multimedia programming simplicity.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add SDLRuby
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install SDLRuby
14
+
15
+ ## Usage
16
+
17
+ **⚠️UNDER CONSTRUCTION⚠️**
18
+
19
+ ## Development
20
+
21
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
22
+
23
+ To install this gem onto your local machine, run `bundle exec rake install`.
24
+
25
+ ## Contributing
26
+
27
+ Bug reports and pull requests are welcome on GitHub at https://github.com/shinokaro/SDLRuby.
28
+
29
+ ## License
30
+
31
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
10
- end
11
-
12
- task default: :test
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
data/SDLRuby.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/SDLRuby/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "SDLRuby"
7
+ spec.version = SDLRuby::VERSION
8
+ spec.authors = ["shinokaro"]
9
+ spec.email = ["shinokaro@hotmail.co.jp"]
10
+
11
+ spec.summary = "Using the SDL library from Ruby."
12
+ spec.description = "SDLRuby is a GEM that allows calling the SDL library from Ruby, enabling window creation, image display, audio playback, and more. It easily manages C pointers as Ruby objects, all written in 100% Ruby. Achieve multimedia programming simplicity."
13
+ spec.homepage = "https://github.com/shinokaro/SDLRuby"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.2.2"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/shinokaro/SDLRuby"
19
+ spec.metadata["changelog_uri"] = "https://github.com/shinokaro/SDLRuby/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+
36
+ # For more information and examples about making a new gem, check out our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
data/examples/alert.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'SDLRuby'
2
+
3
+ SDLRuby.load_sdl
4
+ include SDLRuby
5
+ SDL.alert("ALERT", __FILE__)
6
+ SDL.error_alert("ERROR ALERT")
7
+ SDL.warn_alert("WARNING ALERT")
8
+ SDL.info_alert("INFO ALERT")
@@ -0,0 +1,7 @@
1
+ require 'SDLRuby'
2
+
3
+ SDLRuby.load_sdl
4
+ include SDLRuby
5
+ SDL.init
6
+ w = Window.create(__FILE__)
7
+ sleep 10
@@ -65,14 +65,14 @@ module SDLRuby
65
65
  # ※これはKernel#yメソッドにオブジェクトが応答してしまうため、
66
66
  # 事前にattr_readerでオーバーライドする。
67
67
  #
68
- attr_reader *%w[
68
+ attr_reader(*%w[
69
69
  axis ball button clicks code dDist dTheta data data1 data2 direction
70
70
  display dx dy error event file finger fingerId gestureId hat iscapture
71
71
  keysym length level mouseX mouseY msg numFingers
72
72
  padding padding1 padding2 padding3 padding4
73
73
  preciseX preciseY pressure repeat sensor start state text timestamp
74
74
  timestamp_us touchId touchpad type value which windowID x xrel y yrel
75
- ]
75
+ ])
76
76
 
77
77
  # Ruby like accessor
78
78
  #
data/lib/SDLRuby/event.rb CHANGED
@@ -1,101 +1,101 @@
1
- require_relative 'event/accessor'
2
- require_relative 'event/type'
3
-
4
- module SDLRuby
5
- class Event
6
- include Accessor, Fiddle, SDL
7
-
8
- class << self
9
- include Fiddle, SDL
10
-
11
- private def __malloc__ = Pointer.malloc(SDL_Event.size, RUBY_FREE)
12
-
13
- def clear = SDL.SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT)
14
-
15
- # The deq method can be called from any thread.
16
- #
17
- def deq(non_block = false)
18
- if non_block && empty?
19
- raise SDLError, "event queue empty"
20
- end
21
-
22
- e = __malloc__
23
-
24
- case SDL.SDL_PeepEvents(e, 1, SDL_GETEVENT, 0, -1)
25
- when 1
26
- return new(e)
27
- when 0
28
- sleep(0.001)
29
- else # -1 "The event system has been shut down"
30
- return
31
- end while true
32
- end
33
-
34
- def disable(type) = SDL.SDL_EventState(type, 0)
35
-
36
- def empty? = SDL.SDL_PeepEvents(nil, 1, SDL_PEEKEVENT, 0, -1) != 1
37
-
38
- def enable(type) = SDL.SDL_EventState(type, 1)
39
-
40
- def get
41
- unless Thread.current == Thread.main
42
- raise SDLError, "called from a non-main thread"
43
- end
44
-
45
- e = __malloc__
46
- if SDL.SDL_WaitEvent(e) == 1
47
- new(e)
48
- else
49
- raise SDLError
50
- end
51
- end
52
-
53
- def length = SDL.SDL_PeepEvents(nil, 0, SDL_PEEKEVENT, 0, -1)
54
- alias size length
55
-
56
- def quit? = (update or SDL.SDL_HasEvent(SDL_QUIT) == 1)
57
-
58
- def reserve(num)
59
- base = SDL.SDL_RegisterEvents(num)
60
-
61
- if base == 0xFFFF_FFFF
62
- raise SDLError, "cannot register any more user events"
63
- end
64
-
65
- base
66
- end
67
-
68
- def update
69
- unless Thread.current == Thread.main
70
- raise SDLError, "called from a non-main thread"
71
- end
72
-
73
- SDL.SDL_PumpEvents
74
- end
75
-
76
- def wait(timeout = nil)
77
- return self unless empty?
78
-
79
- return nil unless Thread.current == Thread.main
80
-
81
- if timeout
82
- SDL.SDL_WaitEventTimeout(nil, timeout * 1000)
83
- else
84
- SDL.SDL_WaitEvent(nil)
85
- end == 1 ? self : nil
86
- end
87
- end
88
-
89
- def initialize(ptr)
90
- @ptr = ptr
91
- st = SDL_Event.new(ptr)
92
- sym = Type[st.type]
93
- @entity = st.__send__(sym)
94
- extend(Accessor[sym])
95
- end
96
-
97
- private attr_reader :entity
98
-
99
- def to_ptr = @ptr
100
- end
101
- end
1
+ require_relative 'event/accessor'
2
+ require_relative 'event/type'
3
+
4
+ module SDLRuby
5
+ class Event
6
+ include Accessor, Fiddle, SDL
7
+
8
+ class << self
9
+ include Fiddle, SDL
10
+
11
+ private def __malloc__ = Pointer.malloc(SDL_Event.size, RUBY_FREE)
12
+
13
+ def clear = SDL.SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT)
14
+
15
+ # The deq method can be called from any thread.
16
+ #
17
+ def deq(non_block = false)
18
+ if non_block && empty?
19
+ raise SDLError, "event queue empty"
20
+ end
21
+
22
+ e = __malloc__
23
+
24
+ case SDL.SDL_PeepEvents(e, 1, SDL_GETEVENT, 0, -1)
25
+ when 1
26
+ return new(e)
27
+ when 0
28
+ sleep(0.001)
29
+ else # -1 "The event system has been shut down"
30
+ return
31
+ end while true
32
+ end
33
+
34
+ def disable(type) = SDL.SDL_EventState(type, 0)
35
+
36
+ def empty? = SDL.SDL_PeepEvents(nil, 1, SDL_PEEKEVENT, 0, -1) != 1
37
+
38
+ def enable(type) = SDL.SDL_EventState(type, 1)
39
+
40
+ def get
41
+ unless Thread.current == Thread.main
42
+ raise SDLError, "called from a non-main thread"
43
+ end
44
+
45
+ e = __malloc__
46
+ if SDL.SDL_WaitEvent(e) == 1
47
+ new(e)
48
+ else
49
+ raise SDLError
50
+ end
51
+ end
52
+
53
+ def length = SDL.SDL_PeepEvents(nil, 0, SDL_PEEKEVENT, 0, -1)
54
+ alias size length
55
+
56
+ def quit? = (update or SDL.SDL_HasEvent(SDL_QUIT) == 1)
57
+
58
+ def reserve(num)
59
+ base = SDL.SDL_RegisterEvents(num)
60
+
61
+ if base == 0xFFFF_FFFF
62
+ raise SDLError, "cannot register any more user events"
63
+ end
64
+
65
+ base
66
+ end
67
+
68
+ def update
69
+ unless Thread.current == Thread.main
70
+ raise SDLError, "called from a non-main thread"
71
+ end
72
+
73
+ SDL.SDL_PumpEvents
74
+ end
75
+
76
+ def wait(timeout = nil)
77
+ return self unless empty?
78
+
79
+ return nil unless Thread.current == Thread.main
80
+
81
+ if timeout
82
+ SDL.SDL_WaitEventTimeout(nil, timeout * 1000)
83
+ else
84
+ SDL.SDL_WaitEvent(nil)
85
+ end == 1 ? self : nil
86
+ end
87
+ end
88
+
89
+ def initialize(ptr)
90
+ @ptr = ptr
91
+ st = SDL_Event.new(ptr)
92
+ sym = Type[st.type]
93
+ @entity = st.__send__(sym)
94
+ extend(Accessor[sym])
95
+ end
96
+
97
+ private attr_reader :entity
98
+
99
+ def to_ptr = @ptr
100
+ end
101
+ end
@@ -1,61 +1,61 @@
1
- module SDLRuby::Image
2
- typealias "IMG_InitFlags", "int"
3
- extern "const SDL_version * IMG_Linked_Version(void)"
4
- extern "int IMG_Init(int flags)"
5
- extern "void IMG_Quit(void)"
6
- extern "SDL_Surface * IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type)"
7
- extern "SDL_Surface * IMG_Load(const char *file)"
8
- extern "SDL_Surface * IMG_Load_RW(SDL_RWops *src, int freesrc)"
9
- extern "SDL_Texture * IMG_LoadTexture(SDL_Renderer *renderer, const char *file)"
10
- extern "SDL_Texture * IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc)"
11
- extern "SDL_Texture * IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type)"
12
- extern "int IMG_isAVIF(SDL_RWops *src)"
13
- extern "int IMG_isICO(SDL_RWops *src)"
14
- extern "int IMG_isCUR(SDL_RWops *src)"
15
- extern "int IMG_isBMP(SDL_RWops *src)"
16
- extern "int IMG_isGIF(SDL_RWops *src)"
17
- extern "int IMG_isJPG(SDL_RWops *src)"
18
- extern "int IMG_isJXL(SDL_RWops *src)"
19
- extern "int IMG_isLBM(SDL_RWops *src)"
20
- extern "int IMG_isPCX(SDL_RWops *src)"
21
- extern "int IMG_isPNG(SDL_RWops *src)"
22
- extern "int IMG_isPNM(SDL_RWops *src)"
23
- extern "int IMG_isSVG(SDL_RWops *src)"
24
- extern "int IMG_isQOI(SDL_RWops *src)"
25
- extern "int IMG_isTIF(SDL_RWops *src)"
26
- extern "int IMG_isXCF(SDL_RWops *src)"
27
- extern "int IMG_isXPM(SDL_RWops *src)"
28
- extern "int IMG_isXV(SDL_RWops *src)"
29
- extern "int IMG_isWEBP(SDL_RWops *src)"
30
- extern "SDL_Surface * IMG_LoadAVIF_RW(SDL_RWops *src)"
31
- extern "SDL_Surface * IMG_LoadICO_RW(SDL_RWops *src)"
32
- extern "SDL_Surface * IMG_LoadCUR_RW(SDL_RWops *src)"
33
- extern "SDL_Surface * IMG_LoadBMP_RW(SDL_RWops *src)"
34
- extern "SDL_Surface * IMG_LoadGIF_RW(SDL_RWops *src)"
35
- extern "SDL_Surface * IMG_LoadJPG_RW(SDL_RWops *src)"
36
- extern "SDL_Surface * IMG_LoadJXL_RW(SDL_RWops *src)"
37
- extern "SDL_Surface * IMG_LoadLBM_RW(SDL_RWops *src)"
38
- extern "SDL_Surface * IMG_LoadPCX_RW(SDL_RWops *src)"
39
- extern "SDL_Surface * IMG_LoadPNG_RW(SDL_RWops *src)"
40
- extern "SDL_Surface * IMG_LoadPNM_RW(SDL_RWops *src)"
41
- extern "SDL_Surface * IMG_LoadSVG_RW(SDL_RWops *src)"
42
- extern "SDL_Surface * IMG_LoadQOI_RW(SDL_RWops *src)"
43
- extern "SDL_Surface * IMG_LoadTGA_RW(SDL_RWops *src)"
44
- extern "SDL_Surface * IMG_LoadTIF_RW(SDL_RWops *src)"
45
- extern "SDL_Surface * IMG_LoadXCF_RW(SDL_RWops *src)"
46
- extern "SDL_Surface * IMG_LoadXPM_RW(SDL_RWops *src)"
47
- extern "SDL_Surface * IMG_LoadXV_RW(SDL_RWops *src)"
48
- extern "SDL_Surface * IMG_LoadWEBP_RW(SDL_RWops *src)"
49
- extern "SDL_Surface * IMG_LoadSizedSVG_RW(SDL_RWops *src, int width, int height)"
50
- extern "SDL_Surface * IMG_ReadXPMFromArray(char **xpm)"
51
- extern "SDL_Surface * IMG_ReadXPMFromArrayToRGB888(char **xpm)"
52
- extern "int IMG_SavePNG(SDL_Surface *surface, const char *file)"
53
- extern "int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)"
54
- extern "int IMG_SaveJPG(SDL_Surface *surface, const char *file, int quality)"
55
- extern "int IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality)"
56
- extern "IMG_Animation * IMG_LoadAnimation(const char *file)"
57
- extern "IMG_Animation * IMG_LoadAnimation_RW(SDL_RWops *src, int freesrc)"
58
- extern "IMG_Animation * IMG_LoadAnimationTyped_RW(SDL_RWops *src, int freesrc, const char *type)"
59
- extern "void IMG_FreeAnimation(IMG_Animation *anim)"
60
- extern "IMG_Animation * IMG_LoadGIFAnimation_RW(SDL_RWops *src)"
61
- end
1
+ module SDLRuby::Image
2
+ typealias "IMG_InitFlags", "int"
3
+ extern "const SDL_version * IMG_Linked_Version(void)"
4
+ extern "int IMG_Init(int flags)"
5
+ extern "void IMG_Quit(void)"
6
+ extern "SDL_Surface * IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type)"
7
+ extern "SDL_Surface * IMG_Load(const char *file)"
8
+ extern "SDL_Surface * IMG_Load_RW(SDL_RWops *src, int freesrc)"
9
+ extern "SDL_Texture * IMG_LoadTexture(SDL_Renderer *renderer, const char *file)"
10
+ extern "SDL_Texture * IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc)"
11
+ extern "SDL_Texture * IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type)"
12
+ extern "int IMG_isAVIF(SDL_RWops *src)"
13
+ extern "int IMG_isICO(SDL_RWops *src)"
14
+ extern "int IMG_isCUR(SDL_RWops *src)"
15
+ extern "int IMG_isBMP(SDL_RWops *src)"
16
+ extern "int IMG_isGIF(SDL_RWops *src)"
17
+ extern "int IMG_isJPG(SDL_RWops *src)"
18
+ extern "int IMG_isJXL(SDL_RWops *src)"
19
+ extern "int IMG_isLBM(SDL_RWops *src)"
20
+ extern "int IMG_isPCX(SDL_RWops *src)"
21
+ extern "int IMG_isPNG(SDL_RWops *src)"
22
+ extern "int IMG_isPNM(SDL_RWops *src)"
23
+ extern "int IMG_isSVG(SDL_RWops *src)"
24
+ extern "int IMG_isQOI(SDL_RWops *src)"
25
+ extern "int IMG_isTIF(SDL_RWops *src)"
26
+ extern "int IMG_isXCF(SDL_RWops *src)"
27
+ extern "int IMG_isXPM(SDL_RWops *src)"
28
+ extern "int IMG_isXV(SDL_RWops *src)"
29
+ extern "int IMG_isWEBP(SDL_RWops *src)"
30
+ extern "SDL_Surface * IMG_LoadAVIF_RW(SDL_RWops *src)"
31
+ extern "SDL_Surface * IMG_LoadICO_RW(SDL_RWops *src)"
32
+ extern "SDL_Surface * IMG_LoadCUR_RW(SDL_RWops *src)"
33
+ extern "SDL_Surface * IMG_LoadBMP_RW(SDL_RWops *src)"
34
+ extern "SDL_Surface * IMG_LoadGIF_RW(SDL_RWops *src)"
35
+ extern "SDL_Surface * IMG_LoadJPG_RW(SDL_RWops *src)"
36
+ extern "SDL_Surface * IMG_LoadJXL_RW(SDL_RWops *src)"
37
+ extern "SDL_Surface * IMG_LoadLBM_RW(SDL_RWops *src)"
38
+ extern "SDL_Surface * IMG_LoadPCX_RW(SDL_RWops *src)"
39
+ extern "SDL_Surface * IMG_LoadPNG_RW(SDL_RWops *src)"
40
+ extern "SDL_Surface * IMG_LoadPNM_RW(SDL_RWops *src)"
41
+ extern "SDL_Surface * IMG_LoadSVG_RW(SDL_RWops *src)"
42
+ extern "SDL_Surface * IMG_LoadQOI_RW(SDL_RWops *src)"
43
+ extern "SDL_Surface * IMG_LoadTGA_RW(SDL_RWops *src)"
44
+ extern "SDL_Surface * IMG_LoadTIF_RW(SDL_RWops *src)"
45
+ extern "SDL_Surface * IMG_LoadXCF_RW(SDL_RWops *src)"
46
+ extern "SDL_Surface * IMG_LoadXPM_RW(SDL_RWops *src)"
47
+ extern "SDL_Surface * IMG_LoadXV_RW(SDL_RWops *src)"
48
+ extern "SDL_Surface * IMG_LoadWEBP_RW(SDL_RWops *src)"
49
+ extern "SDL_Surface * IMG_LoadSizedSVG_RW(SDL_RWops *src, int width, int height)"
50
+ extern "SDL_Surface * IMG_ReadXPMFromArray(char **xpm)"
51
+ extern "SDL_Surface * IMG_ReadXPMFromArrayToRGB888(char **xpm)"
52
+ extern "int IMG_SavePNG(SDL_Surface *surface, const char *file)"
53
+ extern "int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)"
54
+ extern "int IMG_SaveJPG(SDL_Surface *surface, const char *file, int quality)"
55
+ extern "int IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality)"
56
+ extern "IMG_Animation * IMG_LoadAnimation(const char *file)"
57
+ extern "IMG_Animation * IMG_LoadAnimation_RW(SDL_RWops *src, int freesrc)"
58
+ extern "IMG_Animation * IMG_LoadAnimationTyped_RW(SDL_RWops *src, int freesrc, const char *type)"
59
+ extern "void IMG_FreeAnimation(IMG_Animation *anim)"
60
+ extern "IMG_Animation * IMG_LoadGIFAnimation_RW(SDL_RWops *src)"
61
+ end