raylib-spinel 0.1.0
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.
- checksums.yaml +7 -0
- data/LICENSE.md +16 -0
- data/README.md +135 -0
- data/lib/physac.h +1987 -0
- data/lib/physac_compat.rb +43 -0
- data/lib/physac_ffi.rb +128 -0
- data/lib/raygui.h +6479 -0
- data/lib/raygui_compat.rb +116 -0
- data/lib/raygui_ffi.rb +714 -0
- data/lib/raylib_audio_fields.rb +115 -0
- data/lib/raylib_camera_fields.rb +16 -0
- data/lib/raylib_compat.rb +72 -0
- data/lib/raylib_ffi.rb +4093 -0
- data/lib/raylib_field_index.rb +593 -0
- data/lib/raylib_handles.rb +427 -0
- data/lib/raylib_handles_ffi.rb +255 -0
- data/lib/raylib_include.rb +2414 -0
- data/lib/raylib_model_ref.rb +99 -0
- data/lib/raylib_pointer_fields.rb +153 -0
- data/lib/raylib_ruby.rb +614 -0
- data/lib/raylib_sizes.rb +128 -0
- data/lib/raylib_struct_fields.rb +102 -0
- data/lib/raylib_structs.rb +174 -0
- data/lib/raymath_ffi.rb +1014 -0
- data/lib/rcamera_ffi.rb +113 -0
- data/lib/rl_handle_views.h +83 -0
- data/lib/rlgl_constants.rb +382 -0
- data/lib/rlgl_ffi.rb +1016 -0
- data/raylib-spinel/physac.rb +13 -0
- data/raylib-spinel/raygui.rb +14 -0
- data/raylib-spinel/raymath.rb +15 -0
- data/raylib-spinel/rcamera.rb +15 -0
- data/raylib-spinel/rlgl.rb +13 -0
- data/raylib-spinel.rb +56 -0
- data/raylib.rb +37 -0
- data/spin.toml +21 -0
- metadata +97 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The audio structs (Wave, AudioStream, Sound, Music) as view classes, plus the
|
|
4
|
+
# shims for the audio functions raylib takes/returns by value. Hand-written:
|
|
5
|
+
# regenerating raylib_ffi.rb cannot drop it, and tools/wrap_audio.rb reshapes the
|
|
6
|
+
# generated wrappers onto these shims.
|
|
7
|
+
module Raylib
|
|
8
|
+
native_struct "Wave", "rl_Wave"
|
|
9
|
+
native_new [], "rl_Wave_new"
|
|
10
|
+
native_new [:any, :any], "rl_Wave_view"
|
|
11
|
+
native_method :frameCount, [], :int, "rl_m_Wave_frameCount"
|
|
12
|
+
native_method :frameCount=, [:int], :int, "rl_m_Wave_set_frameCount"
|
|
13
|
+
native_method :sampleRate, [], :int, "rl_m_Wave_sampleRate"
|
|
14
|
+
native_method :sampleRate=, [:int], :int, "rl_m_Wave_set_sampleRate"
|
|
15
|
+
native_method :sampleSize, [], :int, "rl_m_Wave_sampleSize"
|
|
16
|
+
native_method :sampleSize=, [:int], :int, "rl_m_Wave_set_sampleSize"
|
|
17
|
+
native_method :channels, [], :int, "rl_m_Wave_channels"
|
|
18
|
+
native_method :channels=, [:int], :int, "rl_m_Wave_set_channels"
|
|
19
|
+
ffi_func :rl_m_Wave_data, [:ptr], :long
|
|
20
|
+
native_method :data=, [:any], :void, "rl_Wave_set_data"
|
|
21
|
+
|
|
22
|
+
native_struct "AudioStream", "rl_AudioStream"
|
|
23
|
+
native_new [], "rl_AudioStream_new"
|
|
24
|
+
native_new [:any, :any], "rl_AudioStream_view"
|
|
25
|
+
ffi_func :rl_m_AudioStream_buffer, [:ptr], :long
|
|
26
|
+
native_method :buffer=, [:any], :void, "rl_AudioStream_set_buffer"
|
|
27
|
+
ffi_func :rl_m_AudioStream_processor, [:ptr], :long
|
|
28
|
+
native_method :processor=, [:any], :void, "rl_AudioStream_set_processor"
|
|
29
|
+
native_method :sampleRate, [], :int, "rl_m_AudioStream_sampleRate"
|
|
30
|
+
native_method :sampleRate=, [:int], :int, "rl_m_AudioStream_set_sampleRate"
|
|
31
|
+
native_method :sampleSize, [], :int, "rl_m_AudioStream_sampleSize"
|
|
32
|
+
native_method :sampleSize=, [:int], :int, "rl_m_AudioStream_set_sampleSize"
|
|
33
|
+
native_method :channels, [], :int, "rl_m_AudioStream_channels"
|
|
34
|
+
native_method :channels=, [:int], :int, "rl_m_AudioStream_set_channels"
|
|
35
|
+
|
|
36
|
+
native_struct "Sound", "rl_Sound"
|
|
37
|
+
native_new [], "rl_Sound_new"
|
|
38
|
+
native_new [:any, :any], "rl_Sound_view"
|
|
39
|
+
native_method :frameCount, [], :int, "rl_m_Sound_frameCount"
|
|
40
|
+
native_method :frameCount=, [:int], :int, "rl_m_Sound_set_frameCount"
|
|
41
|
+
ffi_func :rl_Sound_stream, [:ptr, :ptr], :void
|
|
42
|
+
native_method :stream=, [:any], :void, "rl_Sound_set_stream"
|
|
43
|
+
|
|
44
|
+
native_struct "Music", "rl_Music"
|
|
45
|
+
native_new [], "rl_Music_new"
|
|
46
|
+
native_new [:any, :any], "rl_Music_view"
|
|
47
|
+
native_method :frameCount, [], :int, "rl_m_Music_frameCount"
|
|
48
|
+
native_method :frameCount=, [:int], :int, "rl_m_Music_set_frameCount"
|
|
49
|
+
native_method :looping, [], :bool, "rl_m_Music_looping"
|
|
50
|
+
native_method :looping=, [:bool], :bool, "rl_m_Music_set_looping"
|
|
51
|
+
native_method :ctxType, [], :int, "rl_m_Music_ctxType"
|
|
52
|
+
native_method :ctxType=, [:int], :int, "rl_m_Music_set_ctxType"
|
|
53
|
+
ffi_func :rl_m_Music_ctxData, [:ptr], :long
|
|
54
|
+
native_method :ctxData=, [:any], :void, "rl_Music_set_ctxData"
|
|
55
|
+
ffi_func :rl_Music_stream, [:ptr, :ptr], :void
|
|
56
|
+
native_method :stream=, [:any], :void, "rl_Music_set_stream"
|
|
57
|
+
|
|
58
|
+
# function shims (raylib takes/returns these structs by value)
|
|
59
|
+
ffi_func :rl_audio_LoadWaveFromMemory, [:str, :str, :int], :ptr
|
|
60
|
+
ffi_func :rl_audio_IsWaveValid, [:ptr], :int
|
|
61
|
+
ffi_func :rl_audio_UnloadWave, [:ptr], :void
|
|
62
|
+
ffi_func :rl_audio_LoadSoundFromWave, [:ptr], :ptr
|
|
63
|
+
ffi_func :rl_audio_LoadSound, [:str], :ptr
|
|
64
|
+
ffi_func :rl_audio_IsSoundValid, [:ptr], :int
|
|
65
|
+
ffi_func :rl_audio_PlaySound, [:ptr], :void
|
|
66
|
+
ffi_func :rl_audio_StopSound, [:ptr], :void
|
|
67
|
+
ffi_func :rl_audio_IsSoundPlaying, [:ptr], :int
|
|
68
|
+
ffi_func :rl_audio_SetSoundVolume, [:ptr, :float], :void
|
|
69
|
+
ffi_func :rl_audio_SetSoundPitch, [:ptr, :float], :void
|
|
70
|
+
ffi_func :rl_audio_UnloadSound, [:ptr], :void
|
|
71
|
+
ffi_func :rl_audio_LoadAudioStream, [:uint32, :uint32, :uint32], :ptr
|
|
72
|
+
ffi_func :rl_audio_IsAudioStreamValid, [:ptr], :int
|
|
73
|
+
ffi_func :rl_audio_IsAudioStreamPlaying, [:ptr], :int
|
|
74
|
+
ffi_func :rl_audio_PlayAudioStream, [:ptr], :void
|
|
75
|
+
ffi_func :rl_audio_StopAudioStream, [:ptr], :void
|
|
76
|
+
ffi_func :rl_audio_UpdateAudioStream, [:ptr, :long, :int], :void
|
|
77
|
+
ffi_func :rl_audio_UnloadAudioStream, [:ptr], :void
|
|
78
|
+
ffi_func :rl_audio_IsMusicValid, [:ptr], :int
|
|
79
|
+
ffi_func :rl_MemAllocAddr, [:int], :long
|
|
80
|
+
ffi_func :rl_MemFreeAddr, [:long], :void
|
|
81
|
+
|
|
82
|
+
# field readers that hand over an address, and the embedded-stream views
|
|
83
|
+
class Wave
|
|
84
|
+
def pointer = self
|
|
85
|
+
def data = Ptr.new(Raylib.rl_m_Wave_data(self))
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class AudioStream
|
|
89
|
+
def pointer = self
|
|
90
|
+
def buffer = Ptr.new(Raylib.rl_m_AudioStream_buffer(self))
|
|
91
|
+
def processor = Ptr.new(Raylib.rl_m_AudioStream_processor(self))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class Sound
|
|
95
|
+
def pointer = self
|
|
96
|
+
|
|
97
|
+
def stream
|
|
98
|
+
a = AudioStream.new
|
|
99
|
+
Raylib.rl_Sound_stream(self, a)
|
|
100
|
+
a
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
class Music
|
|
105
|
+
def pointer = self
|
|
106
|
+
|
|
107
|
+
def stream
|
|
108
|
+
a = AudioStream.new
|
|
109
|
+
Raylib.rl_Music_stream(self, a)
|
|
110
|
+
a
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def ctxData = Ptr.new(Raylib.rl_m_Music_ctxData(self))
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Camera field writers for the struct-typed fields: the generator emits
|
|
4
|
+
# writers for scalar fields only, so position/target/up (Camera3D, Vector3)
|
|
5
|
+
# and offset/target (Camera2D, Vector2) are declared here. Hand-written, not
|
|
6
|
+
# generated, so regenerating raylib_ffi.rb cannot drop them.
|
|
7
|
+
module Raylib
|
|
8
|
+
native_struct "Camera", "rl_Camera"
|
|
9
|
+
native_method :position=, [:any], :void, "rl_Camera_set_position"
|
|
10
|
+
native_method :target=, [:any], :void, "rl_Camera_set_target"
|
|
11
|
+
native_method :up=, [:any], :void, "rl_Camera_set_up"
|
|
12
|
+
|
|
13
|
+
native_struct "Camera2D", "rl_Camera2D"
|
|
14
|
+
native_method :offset=, [:any], :void, "rl_Camera2D_set_offset"
|
|
15
|
+
native_method :target=, [:any], :void, "rl_Camera2D_set_target"
|
|
16
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# raylib_compat.rb — Spinel-side no-ops for the gem's runtime entry idioms.
|
|
4
|
+
#
|
|
5
|
+
# Unmodified raylib-bindings projects sometimes call Raylib.load_lib /
|
|
6
|
+
# Raylib.setup_symbols to point the gem at a shared library before use. Under
|
|
7
|
+
# Spinel the adapters are linked into the binary, so these are accepted and
|
|
8
|
+
# ignored; the signatures mirror the gem's (raylib-bindings lib/raylib.rb).
|
|
9
|
+
# Loaded by raylib.rb on the Spinel path only.
|
|
10
|
+
module Raylib
|
|
11
|
+
def self.load_lib(libpath, raygui_libpath: nil, physac_libpath: nil,
|
|
12
|
+
method_naming: :original)
|
|
13
|
+
nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.setup_symbols(method_naming: :original)
|
|
17
|
+
nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# TextFormat — the gem's printf-style helper. The gem passes FFI varargs as
|
|
21
|
+
# (type, value) pairs; Spinel cannot call C varargs, so the pairs are
|
|
22
|
+
# stripped here and Kernel#format does the work.
|
|
23
|
+
def self.TextFormat(fmt, *args)
|
|
24
|
+
vals = []
|
|
25
|
+
i = 0
|
|
26
|
+
while i < args.size
|
|
27
|
+
vals << args[i + 1]
|
|
28
|
+
i += 2
|
|
29
|
+
end
|
|
30
|
+
format(fmt, *vals)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# UnloadFileText — LoadFileText returns a Ruby String copy under Spinel
|
|
34
|
+
# (see raylib_ffi.rb), so there is no C buffer to free. The raw-pointer pair
|
|
35
|
+
# rl_LoadFileTextPtr/rl_UnloadFileTextPtr keeps the free for pointer users.
|
|
36
|
+
def self.UnloadFileText(text)
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class String
|
|
42
|
+
# The gem's TextFormat/LoadFileText return FFI pointers that callers read
|
|
43
|
+
# with read_string; ours are already Ruby Strings, so the call is identity.
|
|
44
|
+
def read_string = self
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Gem::Specification — the preamble of every raylib-bindings example
|
|
48
|
+
# (examples/template.rb) locates the gem's bundled library before use:
|
|
49
|
+
#
|
|
50
|
+
# shared_lib_path = Gem::Specification.find_by_name('raylib-bindings').full_gem_path + '/lib/'
|
|
51
|
+
# Raylib.load_lib(shared_lib_path + "libraylib.so", raygui_libpath: ..., physac_libpath: ...)
|
|
52
|
+
#
|
|
53
|
+
# Under Spinel there is no RubyGems runtime to answer that: `Gem` exists as a
|
|
54
|
+
# module, `Gem::Specification` does not, and --require-gate refuses
|
|
55
|
+
# `require "rubygems"` (see tools/repro/upstream/issue-f-require-gate-builtin.md).
|
|
56
|
+
# The path it computes is only ever passed to Raylib.load_lib, which is a no-op
|
|
57
|
+
# here, so an answer that locates nothing keeps unmodified example code
|
|
58
|
+
# running. A stub rather than a shim: every name answers, where MRI raises
|
|
59
|
+
# Gem::LoadError for a gem that is not installed. Safe because this package
|
|
60
|
+
# reads the path back to nothing; a program that asks RubyGems something real
|
|
61
|
+
# (specs, activation) is asking for MRI, where this file is not loaded.
|
|
62
|
+
module Gem
|
|
63
|
+
class Specification
|
|
64
|
+
def self.find_by_name(name)
|
|
65
|
+
new
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def full_gem_path = ""
|
|
69
|
+
|
|
70
|
+
def full_require_paths = [""]
|
|
71
|
+
end
|
|
72
|
+
end
|