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.
@@ -0,0 +1,427 @@
1
+ # frozen_string_literal: true
2
+
3
+ # raylib_handles.rb — the gem-shaped handle API on top of the native view
4
+ # classes (declared in raylib_handles_ffi.rb).
5
+ #
6
+ # Fields are native accessors; this file adds the sub-struct views (model
7
+ # material/mesh/transform, material shader), the gem's `size`/pointer helpers,
8
+ # and fresh definitions for the raw shims that used to return interior
9
+ # pointers (renamed to *_ptr in C so these names are new definitions, not
10
+ # redefinitions).
11
+ module Raylib
12
+ # Interior arrays (events; font.recs/glyphs live next to their class in
13
+ # raylib_handles_ffi.rb) travel as Raylib::Ptr: the gem indexes them with
14
+ # `ptr + index * Rectangle.size`, and Spinel boxes :ptr arithmetic, so the
15
+ # address itself is what Ptr#+ shifts. (This used to be a second,
16
+ # near-identical wrapper class; one address-over-a-long class is what the C
17
+ # side can unbox -- see rl_p_unbox in raylib_adapter.c.)
18
+ class AutomationEvent
19
+ end
20
+
21
+ class AutomationEventList
22
+ # the gem indexes the events array with AutomationEvent.size
23
+ def events = Ptr.new(Raylib.rl_AutomationEventList_events_addr(self))
24
+ end
25
+
26
+ class Model
27
+
28
+ # gem helper name (raylib_helper.rb)
29
+ def material_count = materialCount
30
+
31
+ def mesh_count = meshCount
32
+
33
+ def transform
34
+ m = Matrix.new
35
+ Raylib.rl_Model_transform(self, m)
36
+ m
37
+ end
38
+ end
39
+
40
+ class Material
41
+ def shader = Shader.new(Raylib.rl_Material_shader_ptr(self), self)
42
+ end
43
+
44
+ # MaterialMap: texture and color are stored by value, value is a float.
45
+ class MaterialMap
46
+ def pointer = self
47
+ def texture = Texture2D.new(Raylib.rl_MaterialMap_texture_ptr(self), self)
48
+ def color
49
+ c = Color.new
50
+ Raylib.rl_MaterialMap_color(self, c)
51
+ c
52
+ end
53
+ end
54
+
55
+ # Material's remaining fields: the two pointers, with writer shims.
56
+ class Material
57
+ def maps = Ptr.new(Raylib.rl_m_Material_maps(self))
58
+ def params = Ptr.new(Raylib.rl_m_Material_params(self))
59
+
60
+ def maps=(v)
61
+ Raylib.rl_Material_set_maps_ptr(self, Raylib.ptr_addr(v))
62
+ end
63
+
64
+ def params=(v)
65
+ Raylib.rl_Material_set_params_ptr(self, Raylib.ptr_addr(v))
66
+ end
67
+ end
68
+
69
+ class Model
70
+ def bone_info(index = 0) = BoneInfo.new(Raylib.rl_Model_bone_ptr(self, index), self)
71
+
72
+ # gem helper names (raylib_helper.rb)
73
+ def bone_count = boneCount
74
+
75
+ def bind_pose_transform(index = 0) =
76
+ Transform.new(Raylib.rl_Model_bind_pose_ptr(self, index), self)
77
+
78
+ # Pointer fields, gem names. Readers hand back a pointer object; the writers
79
+ # go through the *_ptr shims so a wrapper can delegate to them.
80
+ def meshes = Ptr.new(Raylib.rl_m_Model_meshes(self))
81
+ def materials = Ptr.new(Raylib.rl_m_Model_materials(self))
82
+ def meshMaterial = Ptr.new(Raylib.rl_m_Model_meshMaterial(self))
83
+ def currentPose = Ptr.new(Raylib.rl_m_Model_currentPose(self))
84
+ def boneMatrices = Ptr.new(Raylib.rl_m_Model_boneMatrices(self))
85
+
86
+ def meshes=(v)
87
+ Raylib.rl_Model_set_meshes_ptr(self, Raylib.ptr_addr(v))
88
+ end
89
+
90
+ def materials=(v)
91
+ Raylib.rl_Model_set_materials_ptr(self, Raylib.ptr_addr(v))
92
+ end
93
+
94
+ def meshMaterial=(v)
95
+ Raylib.rl_Model_set_meshMaterial_ptr(self, Raylib.ptr_addr(v))
96
+ end
97
+
98
+ def currentPose=(v)
99
+ Raylib.rl_Model_set_currentPose_ptr(self, Raylib.ptr_addr(v))
100
+ end
101
+
102
+ def boneMatrices=(v)
103
+ Raylib.rl_Model_set_boneMatrices_ptr(self, Raylib.ptr_addr(v))
104
+ end
105
+
106
+ # transform is stored by value: read above, write copies the Matrix view
107
+ def transform=(matrix)
108
+ Raylib.rl_Model_set_transform(self, matrix)
109
+ end
110
+
111
+ # skeleton is stored by value too: the reader wraps the embedded struct, the
112
+ # writer copies a ModelSkeleton view back over it
113
+ def skeleton = ModelSkeleton.new(Raylib.rl_Model_skeleton_ptr(self), self)
114
+
115
+ def skeleton=(s)
116
+ Raylib.rl_Model_set_skeleton(self, s)
117
+ end
118
+ end
119
+
120
+ # ModelSkeleton: bones and bindPose are pointers into raylib-owned arrays.
121
+ class ModelSkeleton
122
+ def bone_count = boneCount
123
+ def bones = Ptr.new(Raylib.rl_m_ModelSkeleton_bones(self))
124
+ def bindPose = Ptr.new(Raylib.rl_m_ModelSkeleton_bindPose(self))
125
+ def pointer = self
126
+
127
+ def bones=(v)
128
+ Raylib.rl_ModelSkeleton_set_bones_ptr(self, Raylib.ptr_addr(v))
129
+ end
130
+
131
+ def bindPose=(v)
132
+ Raylib.rl_ModelSkeleton_set_bindPose_ptr(self, Raylib.ptr_addr(v))
133
+ end
134
+ end
135
+
136
+ # The gem's ModelAnimations helper (raylib_helper.rb) over the raw
137
+ # LoadModelAnimations pointer + per-animation views.
138
+ class ModelAnimations
139
+ def initialize
140
+ @anims = nil
141
+ @anims_ptr = nil
142
+ end
143
+
144
+ def anim(index) = @anims[index]
145
+ def anims_count = @anims.length
146
+ def frame_count(index) = @anims[index].keyframeCount
147
+
148
+ def bone_transform_of_frame_pose(anim_index, frame, bone_index)
149
+ a = anim(anim_index)
150
+ Transform.new(Raylib.rl_ModelAnimation_frame_pose_bone_ptr(a, frame, bone_index), a)
151
+ end
152
+
153
+ def setup(file_name)
154
+ buffer = Raylib.rl_IntAlloc
155
+ ptr = Raylib.LoadModelAnimations(file_name, buffer)
156
+ count = Raylib.rl_IntGet(buffer)
157
+ Raylib.rl_IntFree(buffer)
158
+ @anims_ptr = ptr
159
+ @anims = []
160
+ count.times do |i|
161
+ @anims << ModelAnimation.new(Raylib.rl_ModelAnimationAt_ptr(ptr, i), nil)
162
+ end
163
+ self
164
+ end
165
+
166
+ def cleanup
167
+ Raylib.UnloadModelAnimations(@anims_ptr, @anims.length)
168
+ end
169
+ end
170
+
171
+ # gem helper names (raylib_helper.rb)
172
+ def self.LoadAndAllocateModelAnimations(file_name)
173
+ buffer = Raylib.rl_IntAlloc
174
+ ptr = Raylib.LoadModelAnimations(file_name, buffer)
175
+ count = Raylib.rl_IntGet(buffer)
176
+ Raylib.rl_IntFree(buffer)
177
+ anims = []
178
+ count.times do |i|
179
+ anims << ModelAnimation.new(Raylib.rl_ModelAnimationAt_ptr(ptr, i), nil)
180
+ end
181
+ [anims, ptr]
182
+ end
183
+
184
+ def self.UnloadAndFreeModelAnimations(anims, anim_ptrs)
185
+ Raylib.UnloadModelAnimations(anim_ptrs, anims.length)
186
+ end
187
+
188
+ class ModelAnimation
189
+ # the gem's ModelAnimations helper reads keyframeCount as frame_count
190
+ def frame_count = keyframeCount
191
+
192
+ def name = Raylib.rl_ModelAnimation_name(self)
193
+ def keyframePoses = Ptr.new(Raylib.rl_m_ModelAnimation_keyframePoses(self))
194
+
195
+ def name=(s)
196
+ Raylib.rl_ModelAnimation_set_name(self, s)
197
+ end
198
+ end
199
+
200
+ # The gem's FFI::Struct#pointer (hand the struct to a C function) is the
201
+ # single most common struct idiom, e.g. UpdateCamera(camera.pointer, mode),
202
+ # SetAutomationEventList(list.pointer), ImageFlipVertical(image.pointer).
203
+ # Our views are native-class instances: a :ptr slot hands C their struct
204
+ # address, so `pointer` is the view itself. (A native_method returning :ptr
205
+ # would hand the box instead, which raylib then reads as the struct.)
206
+ class Vector2
207
+ def pointer = self
208
+ end
209
+ class Vector3
210
+ def pointer = self
211
+ end
212
+ class Vector4
213
+ def pointer = self
214
+ end
215
+ class Color
216
+ def pointer = self
217
+ end
218
+ class Rectangle
219
+ def pointer = self
220
+ end
221
+ class Camera
222
+ def pointer = self
223
+ end
224
+ class Camera2D
225
+ def pointer = self
226
+ end
227
+ class BoundingBox
228
+ def pointer = self
229
+ end
230
+ class Shader
231
+ # locs lives in raylib_handles_ffi.rb (IntArrayPtr: byte-offset pointer
232
+ # arithmetic + write_int32, matching the gem's FFI::Pointer).
233
+ end
234
+ class NPatchInfo
235
+ def source
236
+ r = Rectangle(0.0, 0.0, 0.0, 0.0)
237
+ Raylib.rl_NPatchInfo_source(self, r)
238
+ r
239
+ end
240
+ end
241
+ class FilePathList
242
+ def paths = Ptr.new(Raylib.rl_m_FilePathList_paths(self))
243
+ # gem-shaped per-entry path string (mirror of the MRI helper in
244
+ # raylib_ruby.rb). The C shim returns "" for a null handle/index.
245
+ def path(index) = Raylib.rl_FilePathList_path(self, index)
246
+ end
247
+ class VrDeviceInfo
248
+ # The gem's inline arrays read as value arrays (element-indexed, see
249
+ # Raylib::FloatArrayPtr); the writers take a boxed source pointer.
250
+ def lensDistortionValues = FloatArrayPtr.new(Raylib.rl_m_VrDeviceInfo_lensDistortionValues(self))
251
+ def chromaAbCorrection = FloatArrayPtr.new(Raylib.rl_m_VrDeviceInfo_chromaAbCorrection(self))
252
+ end
253
+
254
+ class VrStereoConfig
255
+ def projection = Ptr.new(Raylib.rl_m_VrStereoConfig_projection(self))
256
+ def viewOffset = Ptr.new(Raylib.rl_m_VrStereoConfig_viewOffset(self))
257
+ def leftLensCenter = FloatArrayPtr.new(Raylib.rl_m_VrStereoConfig_leftLensCenter(self))
258
+ def rightLensCenter = FloatArrayPtr.new(Raylib.rl_m_VrStereoConfig_rightLensCenter(self))
259
+ def leftScreenCenter = FloatArrayPtr.new(Raylib.rl_m_VrStereoConfig_leftScreenCenter(self))
260
+ def rightScreenCenter = FloatArrayPtr.new(Raylib.rl_m_VrStereoConfig_rightScreenCenter(self))
261
+ def scale = FloatArrayPtr.new(Raylib.rl_m_VrStereoConfig_scale(self))
262
+ def scaleIn = FloatArrayPtr.new(Raylib.rl_m_VrStereoConfig_scaleIn(self))
263
+ end
264
+
265
+ class AutomationEvent
266
+ def params = Ptr.new(Raylib.rl_m_AutomationEvent_params(self))
267
+ end
268
+
269
+ class Ray
270
+ def pointer = self
271
+ def position
272
+ v = Vector3.new(0.0, 0.0, 0.0)
273
+ Raylib.rl_Ray_position(self, v)
274
+ v
275
+ end
276
+
277
+ def direction
278
+ v = Vector3.new(0.0, 0.0, 0.0)
279
+ Raylib.rl_Ray_direction(self, v)
280
+ v
281
+ end
282
+ end
283
+ class RayCollision
284
+ def pointer = self
285
+ def point
286
+ v = Vector3.new(0.0, 0.0, 0.0)
287
+ Raylib.rl_RayCollision_point(self, v)
288
+ v
289
+ end
290
+
291
+ def normal
292
+ v = Vector3.new(0.0, 0.0, 0.0)
293
+ Raylib.rl_RayCollision_normal(self, v)
294
+ v
295
+ end
296
+ end
297
+ class Matrix
298
+ def pointer = self
299
+ end
300
+ class NPatchInfo
301
+ def pointer = self
302
+ end
303
+ class VrDeviceInfo
304
+ def pointer = self
305
+ end
306
+ class VrStereoConfig
307
+ def pointer = self
308
+ end
309
+ class FilePathList
310
+ def pointer = self
311
+ end
312
+ class Transform
313
+ def pointer = self
314
+ end
315
+ class AutomationEvent
316
+ def pointer = self
317
+ end
318
+ class AutomationEventList
319
+ def pointer = self
320
+ end
321
+ class Image
322
+ def pointer = self
323
+ end
324
+ class Texture2D
325
+ def pointer = self
326
+ end
327
+ class Font
328
+ def pointer = self
329
+ end
330
+ class GlyphInfo
331
+ def pointer = self
332
+ end
333
+ class RenderTexture
334
+ def pointer = self
335
+ end
336
+ class Model
337
+ def pointer = self
338
+ end
339
+ class Material
340
+ def pointer = self
341
+ end
342
+ class Mesh
343
+ def pointer = self
344
+ end
345
+ class Shader
346
+ def pointer = self
347
+ end
348
+ class ModelAnimation
349
+ def pointer = self
350
+ end
351
+ class BoneInfo
352
+ def pointer = self
353
+ def name = Raylib.rl_BoneInfo_name(self)
354
+
355
+ def name=(s)
356
+ Raylib.rl_BoneInfo_set_name(self, s)
357
+ end
358
+ end
359
+
360
+ # FFI::MemoryPointer/FFI::Pointer (the gem idiom) has no C address the AOT
361
+ # compiler can hand to a :ptr slot; the Integer #address it holds is accepted
362
+ # (src/codegen_call_class.c: an Integer, a String, an IO::Buffer or a native
363
+ # class instance may fill a pointer argument). Values without an address —
364
+ # Integer addresses, boxed pointers returned by :ptr functions, nil — pass
365
+ # through untouched.
366
+ def self.ptr_addr(x) = x.respond_to?(:address) ? x.address : x
367
+
368
+ # Integer address for a :ptr slot. ptr_addr's untyped union poisons the AOT's
369
+ # :ptr acceptance program-wide when its result reaches a :ptr parameter (the
370
+ # compiler then refuses view instances elsewhere), so wrappers that take
371
+ # pointer-shaped arguments pin the type here.
372
+ def self.ptr_int(x) = x.respond_to?(:address) ? x.address.to_i : x.to_i
373
+
374
+ # View -> payload address for raygui's struct-pointer parameters (the gem
375
+ # hands an FFI::Struct's address; ours sits behind the view). Integer
376
+ # addresses and address-like objects pass through ptr_addr.
377
+ def self.vector2_addr(v) = v.is_a?(Vector2) ? Raylib.rl_Vector2_payload(v) : Raylib.ptr_addr(v)
378
+ def self.vector3_addr(v) = v.is_a?(Vector3) ? Raylib.rl_Vector3_payload(v) : Raylib.ptr_addr(v)
379
+ def self.color_addr(v) = v.is_a?(Color) ? Raylib.rl_Color_payload(v) : Raylib.ptr_addr(v)
380
+ def self.rectangle_addr(v) = v.is_a?(Rectangle) ? Raylib.rl_Rectangle_payload(v) : Raylib.ptr_addr(v)
381
+
382
+ # Scene-facing names for the renamed raw shims: the *_ptr symbols return raw
383
+ # interior/heap pointers, these return views. They build the view straight
384
+ # from the pointer shim instead of sending the Ruby accessor: when the AOT
385
+ # compiler cannot pin the receiver's type (an array element, a struct field),
386
+ # a `font.texture` send becomes a polymorphic call that misses the native
387
+ # class arm ("undefined method 'texture' for an instance of Raylib::Font"),
388
+ # while an ffi_func argument unboxes the same value.
389
+ def self.rl_FontTexture(font) =
390
+ Texture2D.new(Raylib.rl_Font_texture_ptr(font), font)
391
+ def self.rl_RenderTexture_texture(target) =
392
+ Texture2D.new(Raylib.rl_RenderTexture_texture_ptr(target), target)
393
+ def self.rl_RenderTexture_depth(target) =
394
+ Texture2D.new(Raylib.rl_RenderTexture_depth_ptr(target), target)
395
+ def self.rl_Model_material(model, index) =
396
+ Material.new(Raylib.rl_Model_material_ptr(model, index), model)
397
+ def self.rl_Model_mesh(model, index) =
398
+ Mesh.new(Raylib.rl_Model_mesh_ptr(model, index), model)
399
+
400
+ def self.rl_ModelAnimationAt(anims, index)
401
+ # `anims` is the raw heap pointer from LoadModelAnimations. Passing it as
402
+ # the owner marks the view borrowed: UnloadModelAnimation must not free a
403
+ # pointer into the animations array.
404
+ ModelAnimation.new(Raylib.rl_ModelAnimationAt_ptr(anims, index), anims)
405
+ end
406
+
407
+ def self.rl_LoadShaderFS(fsFileName)
408
+ Shader.new(Raylib.rl_LoadShaderFS_ptr(fsFileName), nil)
409
+ end
410
+
411
+
412
+ # Gem-shaped name for the atlas builder (mirrored on CRuby in
413
+ # raylib_ruby.rb via LoadFontData + GenImageFontAtlas).
414
+ def self.LoadFontAtlas(path, fontSize, loadGlyphCount, atlasGlyphCount,
415
+ padding, packMethod, fontType)
416
+ Font.new(Raylib.rl_LoadFontAtlas_ptr(path, fontSize, loadGlyphCount,
417
+ atlasGlyphCount, padding, packMethod,
418
+ fontType), nil)
419
+ end
420
+
421
+ # kept for the older spelling used elsewhere
422
+ def self.rl_LoadFontAtlas(path, fontSize, loadGlyphCount, atlasGlyphCount,
423
+ padding, packMethod, fontType)
424
+ LoadFontAtlas(path, fontSize, loadGlyphCount, atlasGlyphCount, padding,
425
+ packMethod, fontType)
426
+ end
427
+ end
@@ -0,0 +1,255 @@
1
+ # frozen_string_literal: true
2
+
3
+ # raylib_handles_ffi.rb — the handle classes (Image/Texture2D/Font/...) as
4
+ # native view objects, plus the field shims.
5
+ #
6
+ # The C side lives in lib/rl_handle_views.h (layout + RL_<X> macros) and the
7
+ # implementation section of raylib_adapter.c (ctors, scans, rl_m_* accessors);
8
+ # lib/raylib_handles.rb adds the gem-shaped Ruby methods.
9
+ #
10
+ # View ctors take the pointer boxed ([:any]): Spinel boxes ffi_func :ptr
11
+ # returns, and rl_h_unbox accepts a boxed foreign pointer, an object or an
12
+ # Integer address.
13
+ module Raylib
14
+ ffi_lib "raylib"
15
+
16
+ # pointer <-> address (the gem's `ptr + index * Struct.size` idiom; Spinel
17
+ # boxes poly arithmetic, so the address travels as an Integer)
18
+ ffi_func :rl_ptr_addr, [:ptr], :long
19
+ ffi_func :rl_PtrWriteFloat, [:long, :long, :float], :void
20
+ ffi_func :rl_PtrReadFloat, [:long, :long], :float
21
+ ffi_func :rl_PtrWriteInt16, [:long, :long, :int], :void
22
+ ffi_func :rl_PtrWriteInt32, [:long, :long, :int], :void
23
+ ffi_func :rl_PtrReadInt32, [:long, :long], :int
24
+
25
+ # Interior pointers into the payload of a handle (for sub-struct views).
26
+ # ffi_funcs (not native_methods): only ffi :ptr returns feed an [:any] ctor.
27
+ ffi_func :rl_Font_texture_ptr, [:ptr], :ptr
28
+ ffi_func :rl_Vector2_payload, [:ptr], :long
29
+ ffi_func :rl_Vector3_payload, [:ptr], :long
30
+ ffi_func :rl_Color_payload, [:ptr], :long
31
+ ffi_func :rl_Rectangle_payload, [:ptr], :long
32
+ ffi_func :rl_Font_recs_addr, [:ptr], :long
33
+ ffi_func :rl_Font_glyphs_addr, [:ptr], :long
34
+ ffi_func :rl_GlyphInfo_image_ptr, [:ptr], :ptr
35
+ ffi_func :rl_RenderTexture_texture_ptr, [:ptr], :ptr
36
+ ffi_func :rl_RenderTexture_depth_ptr, [:ptr], :ptr
37
+ ffi_func :rl_FontTexture_ptr, [:ptr], :ptr
38
+
39
+ # ------------------------------------------------------------------ Image
40
+ native_struct "Image", "rl_Image"
41
+ native_new [], "rl_Image_new"
42
+ native_new [:any, :any], "rl_Image_view"
43
+ native_method :width, [], :int, "rl_m_Image_width"
44
+ native_method :width=, [:int], :int, "rl_m_Image_set_width"
45
+ native_method :height, [], :int, "rl_m_Image_height"
46
+ native_method :height=, [:int], :int, "rl_m_Image_set_height"
47
+ native_method :mipmaps, [], :int, "rl_m_Image_mipmaps"
48
+ native_method :mipmaps=, [:int], :int, "rl_m_Image_set_mipmaps"
49
+ native_method :format, [], :int, "rl_m_Image_format"
50
+ native_method :format=, [:int], :int, "rl_m_Image_set_format"
51
+ ffi_func :rl_m_Image_data, [:ptr], :long
52
+ native_method :data=, [:any], :void, "rl_m_Image_set_data"
53
+
54
+ # -------------------------------------------------------------- Texture2D
55
+ native_struct "Texture2D", "rl_Texture2D"
56
+ native_new [], "rl_Texture2D_new"
57
+ native_new [:any, :any], "rl_Texture2D_view"
58
+ native_method :id, [], :int, "rl_m_Texture2D_id"
59
+ native_method :id=, [:int], :int, "rl_m_Texture2D_set_id"
60
+ native_method :width, [], :int, "rl_m_Texture2D_width"
61
+ native_method :width=, [:int], :int, "rl_m_Texture2D_set_width"
62
+ native_method :height, [], :int, "rl_m_Texture2D_height"
63
+ native_method :height=, [:int], :int, "rl_m_Texture2D_set_height"
64
+ native_method :mipmaps, [], :int, "rl_m_Texture2D_mipmaps"
65
+ native_method :mipmaps=, [:int], :int, "rl_m_Texture2D_set_mipmaps"
66
+ native_method :format, [], :int, "rl_m_Texture2D_format"
67
+ native_method :format=, [:int], :int, "rl_m_Texture2D_set_format"
68
+
69
+ # ------------------------------------------------------------------- Font
70
+ native_struct "Font", "rl_Font"
71
+ native_new [], "rl_Font_new"
72
+ native_new [:any, :any], "rl_Font_view"
73
+ native_method :baseSize, [], :int, "rl_m_Font_baseSize"
74
+ native_method :baseSize=, [:int], :int, "rl_m_Font_set_baseSize"
75
+ native_method :glyphCount, [], :int, "rl_m_Font_glyphCount"
76
+ native_method :glyphCount=, [:int], :int, "rl_m_Font_set_glyphCount"
77
+ native_method :glyphPadding, [], :int, "rl_m_Font_glyphPadding"
78
+ native_method :glyphPadding=, [:int], :int, "rl_m_Font_set_glyphPadding"
79
+ native_method :glyphs=, [:any], :void, "rl_m_Font_set_glyphs"
80
+ native_method :recs=, [:any], :void, "rl_m_Font_set_recs"
81
+ native_method :texture=, [:any], :void, "rl_m_Font_set_texture"
82
+ native_method :texture_ptr, [], :ptr, "rl_Font_texture_ptr"
83
+ # View accessors next to the class declaration: a polymorphic send (a Struct
84
+ # field or an Array element) only finds the native-class arm when the
85
+ # definition sits here rather than in raylib_handles.rb. The ffi_funcs they
86
+ # read through are declared at the top of this file.
87
+ class Font
88
+ def texture = Texture2D.new(Raylib.rl_Font_texture_ptr(self), self)
89
+ def recs = Ptr.new(Raylib.rl_Font_recs_addr(self))
90
+ def glyphs = Ptr.new(Raylib.rl_Font_glyphs_addr(self))
91
+ end
92
+
93
+ # -------------------------------------------------------------- GlyphInfo
94
+ native_struct "GlyphInfo", "rl_GlyphInfo"
95
+ native_new [], "rl_GlyphInfo_new"
96
+ native_new [:any, :any], "rl_GlyphInfo_view"
97
+ native_new [:any], "rl_GlyphInfo_view_addr"
98
+ native_method :value, [], :int, "rl_m_GlyphInfo_value"
99
+ native_method :value=, [:int], :int, "rl_m_GlyphInfo_set_value"
100
+ native_method :offsetX, [], :int, "rl_m_GlyphInfo_offsetX"
101
+ native_method :offsetX=, [:int], :int, "rl_m_GlyphInfo_set_offsetX"
102
+ native_method :offsetY, [], :int, "rl_m_GlyphInfo_offsetY"
103
+ native_method :offsetY=, [:int], :int, "rl_m_GlyphInfo_set_offsetY"
104
+ native_method :advanceX, [], :int, "rl_m_GlyphInfo_advanceX"
105
+ native_method :advanceX=, [:int], :int, "rl_m_GlyphInfo_set_advanceX"
106
+ class GlyphInfo
107
+ def image = Image.new(Raylib.rl_GlyphInfo_image_ptr(self), self)
108
+ end
109
+
110
+ # --------------------------------------------------------- RenderTexture
111
+ native_struct "RenderTexture", "rl_RenderTexture"
112
+ native_new [], "rl_RenderTexture_new"
113
+ native_new [:any, :any], "rl_RenderTexture_view"
114
+ native_method :texture_ptr, [], :ptr, "rl_RenderTexture_texture_ptr"
115
+ native_method :depth_ptr, [], :ptr, "rl_RenderTexture_depth_ptr"
116
+ class RenderTexture
117
+ def texture = Texture2D.new(Raylib.rl_RenderTexture_texture_ptr(self), self)
118
+ def depth = Texture2D.new(Raylib.rl_RenderTexture_depth_ptr(self), self)
119
+ end
120
+ end
121
+
122
+ # ------------------------------------------------------------------ batch 2
123
+ module Raylib
124
+ # interior/helper shims for the batch-2 classes (the renamed scene-facing
125
+ # shims -- rl_Model_material_ptr, rl_Model_mesh_ptr, rl_ModelAnimationAt_ptr,
126
+ # rl_LoadShaderFS_ptr -- stay declared next to their peers in raylib_ffi.rb)
127
+ ffi_func :rl_Material_shader_ptr, [:ptr], :ptr
128
+
129
+ native_struct "Model", "rl_Model"
130
+ native_new [], "rl_Model_new"
131
+ native_new [:any, :any], "rl_Model_view"
132
+ native_new [:any], "rl_Model_view_addr"
133
+ native_method :meshCount, [], :int, "rl_m_Model_meshCount"
134
+ native_method :meshCount=, [:int], :int, "rl_m_Model_set_meshCount"
135
+ native_method :materialCount, [], :int, "rl_m_Model_materialCount"
136
+ # payload accessors the AOT must see next to the class declaration, so a
137
+ # polymorphic send (an Array element) finds the native-class arm
138
+ class Model
139
+ def material(index = 0) = Material.new(Raylib.rl_Model_material_ptr(self, index), self)
140
+ def mesh(index = 0) = Mesh.new(Raylib.rl_Model_mesh_ptr(self, index), self)
141
+ end
142
+ native_method :materialCount=, [:int], :int, "rl_m_Model_set_materialCount"
143
+ native_method :boneCount, [], :int, "rl_m_Model_boneCount"
144
+ native_method :boneCount=, [:int], :int, "rl_m_Model_set_boneCount"
145
+ ffi_func :rl_m_Model_meshes, [:ptr], :long
146
+ ffi_func :rl_Model_set_meshes_ptr, [:ptr, :ptr], :void
147
+ ffi_func :rl_m_Model_materials, [:ptr], :long
148
+ ffi_func :rl_Model_set_materials_ptr, [:ptr, :ptr], :void
149
+ ffi_func :rl_m_Model_meshMaterial, [:ptr], :long
150
+ ffi_func :rl_Model_set_meshMaterial_ptr, [:ptr, :ptr], :void
151
+ ffi_func :rl_m_Model_currentPose, [:ptr], :long
152
+ ffi_func :rl_Model_set_currentPose_ptr, [:ptr, :ptr], :void
153
+ ffi_func :rl_m_Model_boneMatrices, [:ptr], :long
154
+ ffi_func :rl_Model_set_boneMatrices_ptr, [:ptr, :ptr], :void
155
+ ffi_func :rl_Model_set_transform, [:ptr, :ptr], :void
156
+ ffi_func :rl_Model_skeleton_ptr, [:ptr], :ptr
157
+ ffi_func :rl_Model_set_skeleton, [:ptr, :ptr], :void
158
+
159
+ native_struct "ModelSkeleton", "rl_ModelSkeleton"
160
+ native_new [], "rl_ModelSkeleton_new"
161
+ native_new [:any, :any], "rl_ModelSkeleton_view_any"
162
+ native_method :boneCount, [], :int, "rl_m_ModelSkeleton_boneCount"
163
+ native_method :boneCount=, [:int], :int, "rl_m_ModelSkeleton_set_boneCount"
164
+ ffi_func :rl_m_ModelSkeleton_bones, [:ptr], :long
165
+ ffi_func :rl_ModelSkeleton_set_bones_ptr, [:ptr, :ptr], :void
166
+ ffi_func :rl_m_ModelSkeleton_bindPose, [:ptr], :long
167
+ ffi_func :rl_ModelSkeleton_set_bindPose_ptr, [:ptr, :ptr], :void
168
+ native_struct "MaterialMap", "rl_MaterialMap"
169
+ native_new [], "rl_MaterialMap_new"
170
+ native_new [:any, :any], "rl_MaterialMap_view_any"
171
+ ffi_func :rl_MaterialMap_texture_ptr, [:ptr], :ptr
172
+ native_method :texture=, [:any], :void, "rl_MaterialMap_set_texture"
173
+ ffi_func :rl_MaterialMap_color, [:ptr, :ptr], :void
174
+ native_method :color=, [:any], :void, "rl_MaterialMap_set_color"
175
+ native_method :value, [], :float, "rl_m_MaterialMap_value"
176
+ native_method :value=, [:float], :float, "rl_m_MaterialMap_set_value"
177
+ ffi_func :rl_m_Material_maps, [:ptr], :long
178
+ ffi_func :rl_Material_set_maps_ptr, [:ptr, :ptr], :void
179
+ ffi_func :rl_m_Material_params, [:ptr], :long
180
+ ffi_func :rl_Material_set_params_ptr, [:ptr, :ptr], :void
181
+ ffi_func :rl_m_Model_meshCount_v, [:ptr], :int
182
+ ffi_func :rl_m_Model_materialCount_v, [:ptr], :int
183
+ ffi_func :rl_m_Model_boneCount_v, [:ptr], :int
184
+
185
+ native_struct "Material", "rl_Material"
186
+ native_method :shader=, [:any], :void, "rl_Material_set_shader_any"
187
+ native_new [], "rl_Material_new"
188
+ native_new [:any, :any], "rl_Material_view"
189
+ native_new [:any], "rl_Material_view_addr"
190
+
191
+ native_struct "Mesh", "rl_Mesh"
192
+ native_new [], "rl_Mesh_new"
193
+ native_new [:any, :any], "rl_Mesh_view"
194
+ native_new [:any], "rl_Mesh_view_addr"
195
+ native_method :vertexCount, [], :int, "rl_m_Mesh_vertexCount"
196
+ native_method :vertexCount=, [:int], :int, "rl_m_Mesh_set_vertexCount"
197
+ native_method :triangleCount, [], :int, "rl_m_Mesh_triangleCount"
198
+ ffi_func :rl_m_Mesh_vertices, [:ptr], :long
199
+ native_method :vertices=, [:any], :void, "rl_m_Mesh_set_vertices"
200
+ ffi_func :rl_m_Mesh_texcoords, [:ptr], :long
201
+ native_method :texcoords=, [:any], :void, "rl_m_Mesh_set_texcoords"
202
+ ffi_func :rl_m_Mesh_texcoords2, [:ptr], :long
203
+ native_method :texcoords2=, [:any], :void, "rl_m_Mesh_set_texcoords2"
204
+ ffi_func :rl_m_Mesh_normals, [:ptr], :long
205
+ native_method :normals=, [:any], :void, "rl_m_Mesh_set_normals"
206
+ ffi_func :rl_m_Mesh_tangents, [:ptr], :long
207
+ native_method :tangents=, [:any], :void, "rl_m_Mesh_set_tangents"
208
+ ffi_func :rl_m_Mesh_colors, [:ptr], :long
209
+ native_method :colors=, [:any], :void, "rl_m_Mesh_set_colors"
210
+ ffi_func :rl_m_Mesh_indices, [:ptr], :long
211
+ native_method :indices=, [:any], :void, "rl_m_Mesh_set_indices"
212
+ native_method :triangleCount=, [:int], :int, "rl_m_Mesh_set_triangleCount"
213
+
214
+ native_struct "Shader", "rl_Shader"
215
+ native_new [], "rl_Shader_new"
216
+ native_new [:any, :any], "rl_Shader_view"
217
+ native_new [:any], "rl_Shader_view_addr"
218
+ native_method :id, [], :int, "rl_m_Shader_id"
219
+ native_method :id=, [:int], :int, "rl_m_Shader_set_id"
220
+ # Gem-shaped locs (raylib's inline int[32]): shader.locs is an address view,
221
+ # so (shader.locs + 4 * index).write_int32(loc) works like the gem's
222
+ # FFI::Pointer arithmetic.
223
+ ffi_func :rl_m_Shader_locs, [:ptr], :long
224
+ class Shader
225
+ def locs = IntArrayPtr.new(Raylib.rl_m_Shader_locs(self))
226
+ end
227
+
228
+ ffi_func :rl_Model_bone_ptr, [:ptr, :int], :ptr
229
+ ffi_func :rl_Model_bind_pose_ptr, [:ptr, :int], :ptr
230
+ ffi_func :rl_ModelAnimation_frame_pose_bone_ptr, [:ptr, :int, :int], :ptr
231
+
232
+ native_struct "BoneInfo", "rl_BoneInfo"
233
+ native_new [], "rl_BoneInfo_new"
234
+ native_new [:any, :any], "rl_BoneInfo_view"
235
+ native_new [:any], "rl_BoneInfo_view_addr"
236
+ native_method :parent_bone_index, [], :int, "rl_m_BoneInfo_parent_bone_index"
237
+ native_method :parent_bone_index=, [:int], :int, "rl_m_BoneInfo_set_parent_bone_index"
238
+
239
+ native_struct "Transform", "rl_Transform"
240
+ native_new [], "rl_Transform_new"
241
+ native_new [:any, :any], "rl_Transform_view_any"
242
+ native_new [:any], "rl_Transform_view_addr"
243
+ native_method :translation=, [:any], :void, "rl_Transform_set_translation"
244
+ native_method :rotation=, [:any], :void, "rl_Transform_set_rotation"
245
+ native_method :scale=, [:any], :void, "rl_Transform_set_scale"
246
+
247
+ native_struct "ModelAnimation", "rl_ModelAnimation"
248
+ native_new [], "rl_ModelAnimation_new"
249
+ native_new [:any, :any], "rl_ModelAnimation_view"
250
+ native_new [:any], "rl_ModelAnimation_view_addr"
251
+ native_method :keyframeCount, [], :int, "rl_m_ModelAnimation_keyframeCount"
252
+ native_method :keyframeCount=, [:int], :int, "rl_m_ModelAnimation_set_keyframeCount"
253
+ native_method :boneCount, [], :int, "rl_m_ModelAnimation_boneCount"
254
+ native_method :boneCount=, [:int], :int, "rl_m_ModelAnimation_set_boneCount"
255
+ end