raylib-bindings 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/raymath.rb ADDED
@@ -0,0 +1,342 @@
1
+ # Yet another raylib wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/raylib-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module Raylib
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+
14
+ # Enum
15
+
16
+
17
+ # Typedef
18
+
19
+
20
+ # Struct
21
+
22
+ class Float3 < FFI::Struct
23
+ layout(
24
+ :v, [:float, 3],
25
+ )
26
+ end
27
+
28
+ class Float16 < FFI::Struct
29
+ layout(
30
+ :v, [:float, 16],
31
+ )
32
+ end
33
+
34
+
35
+ # Function
36
+
37
+ def self.setup_raymath_symbols()
38
+ symbols = [
39
+ :Clamp,
40
+ :Lerp,
41
+ :Normalize,
42
+ :Remap,
43
+ :Vector2Zero,
44
+ :Vector2One,
45
+ :Vector2Add,
46
+ :Vector2AddValue,
47
+ :Vector2Subtract,
48
+ :Vector2SubtractValue,
49
+ :Vector2Length,
50
+ :Vector2LengthSqr,
51
+ :Vector2DotProduct,
52
+ :Vector2Distance,
53
+ :Vector2Angle,
54
+ :Vector2Scale,
55
+ :Vector2Multiply,
56
+ :Vector2Negate,
57
+ :Vector2Divide,
58
+ :Vector2Normalize,
59
+ :Vector2Lerp,
60
+ :Vector2Reflect,
61
+ :Vector2Rotate,
62
+ :Vector2MoveTowards,
63
+ :Vector3Zero,
64
+ :Vector3One,
65
+ :Vector3Add,
66
+ :Vector3AddValue,
67
+ :Vector3Subtract,
68
+ :Vector3SubtractValue,
69
+ :Vector3Scale,
70
+ :Vector3Multiply,
71
+ :Vector3CrossProduct,
72
+ :Vector3Perpendicular,
73
+ :Vector3Length,
74
+ :Vector3LengthSqr,
75
+ :Vector3DotProduct,
76
+ :Vector3Distance,
77
+ :Vector3Angle,
78
+ :Vector3Negate,
79
+ :Vector3Divide,
80
+ :Vector3Normalize,
81
+ :Vector3OrthoNormalize,
82
+ :Vector3Transform,
83
+ :Vector3RotateByQuaternion,
84
+ :Vector3Lerp,
85
+ :Vector3Reflect,
86
+ :Vector3Min,
87
+ :Vector3Max,
88
+ :Vector3Barycenter,
89
+ :Vector3Unproject,
90
+ :Vector3ToFloatV,
91
+ :MatrixDeterminant,
92
+ :MatrixTrace,
93
+ :MatrixTranspose,
94
+ :MatrixInvert,
95
+ :MatrixNormalize,
96
+ :MatrixIdentity,
97
+ :MatrixAdd,
98
+ :MatrixSubtract,
99
+ :MatrixMultiply,
100
+ :MatrixTranslate,
101
+ :MatrixRotate,
102
+ :MatrixRotateX,
103
+ :MatrixRotateY,
104
+ :MatrixRotateZ,
105
+ :MatrixRotateXYZ,
106
+ :MatrixRotateZYX,
107
+ :MatrixScale,
108
+ :MatrixFrustum,
109
+ :MatrixPerspective,
110
+ :MatrixOrtho,
111
+ :MatrixLookAt,
112
+ :MatrixToFloatV,
113
+ :QuaternionAdd,
114
+ :QuaternionAddValue,
115
+ :QuaternionSubtract,
116
+ :QuaternionSubtractValue,
117
+ :QuaternionIdentity,
118
+ :QuaternionLength,
119
+ :QuaternionNormalize,
120
+ :QuaternionInvert,
121
+ :QuaternionMultiply,
122
+ :QuaternionScale,
123
+ :QuaternionDivide,
124
+ :QuaternionLerp,
125
+ :QuaternionNlerp,
126
+ :QuaternionSlerp,
127
+ :QuaternionFromVector3ToVector3,
128
+ :QuaternionFromMatrix,
129
+ :QuaternionToMatrix,
130
+ :QuaternionFromAxisAngle,
131
+ :QuaternionToAxisAngle,
132
+ :QuaternionFromEuler,
133
+ :QuaternionToEuler,
134
+ :QuaternionTransform,
135
+ ]
136
+ args = {
137
+ :Clamp => [:float, :float, :float],
138
+ :Lerp => [:float, :float, :float],
139
+ :Normalize => [:float, :float, :float],
140
+ :Remap => [:float, :float, :float, :float, :float],
141
+ :Vector2Zero => [],
142
+ :Vector2One => [],
143
+ :Vector2Add => [Vector2.by_value, Vector2.by_value],
144
+ :Vector2AddValue => [Vector2.by_value, :float],
145
+ :Vector2Subtract => [Vector2.by_value, Vector2.by_value],
146
+ :Vector2SubtractValue => [Vector2.by_value, :float],
147
+ :Vector2Length => [Vector2.by_value],
148
+ :Vector2LengthSqr => [Vector2.by_value],
149
+ :Vector2DotProduct => [Vector2.by_value, Vector2.by_value],
150
+ :Vector2Distance => [Vector2.by_value, Vector2.by_value],
151
+ :Vector2Angle => [Vector2.by_value, Vector2.by_value],
152
+ :Vector2Scale => [Vector2.by_value, :float],
153
+ :Vector2Multiply => [Vector2.by_value, Vector2.by_value],
154
+ :Vector2Negate => [Vector2.by_value],
155
+ :Vector2Divide => [Vector2.by_value, Vector2.by_value],
156
+ :Vector2Normalize => [Vector2.by_value],
157
+ :Vector2Lerp => [Vector2.by_value, Vector2.by_value, :float],
158
+ :Vector2Reflect => [Vector2.by_value, Vector2.by_value],
159
+ :Vector2Rotate => [Vector2.by_value, :float],
160
+ :Vector2MoveTowards => [Vector2.by_value, Vector2.by_value, :float],
161
+ :Vector3Zero => [],
162
+ :Vector3One => [],
163
+ :Vector3Add => [Vector3.by_value, Vector3.by_value],
164
+ :Vector3AddValue => [Vector3.by_value, :float],
165
+ :Vector3Subtract => [Vector3.by_value, Vector3.by_value],
166
+ :Vector3SubtractValue => [Vector3.by_value, :float],
167
+ :Vector3Scale => [Vector3.by_value, :float],
168
+ :Vector3Multiply => [Vector3.by_value, Vector3.by_value],
169
+ :Vector3CrossProduct => [Vector3.by_value, Vector3.by_value],
170
+ :Vector3Perpendicular => [Vector3.by_value],
171
+ :Vector3Length => [Vector3.by_value],
172
+ :Vector3LengthSqr => [Vector3.by_value],
173
+ :Vector3DotProduct => [Vector3.by_value, Vector3.by_value],
174
+ :Vector3Distance => [Vector3.by_value, Vector3.by_value],
175
+ :Vector3Angle => [Vector3.by_value, Vector3.by_value],
176
+ :Vector3Negate => [Vector3.by_value],
177
+ :Vector3Divide => [Vector3.by_value, Vector3.by_value],
178
+ :Vector3Normalize => [Vector3.by_value],
179
+ :Vector3OrthoNormalize => [:pointer, :pointer],
180
+ :Vector3Transform => [Vector3.by_value, Matrix.by_value],
181
+ :Vector3RotateByQuaternion => [Vector3.by_value, Quaternion.by_value],
182
+ :Vector3Lerp => [Vector3.by_value, Vector3.by_value, :float],
183
+ :Vector3Reflect => [Vector3.by_value, Vector3.by_value],
184
+ :Vector3Min => [Vector3.by_value, Vector3.by_value],
185
+ :Vector3Max => [Vector3.by_value, Vector3.by_value],
186
+ :Vector3Barycenter => [Vector3.by_value, Vector3.by_value, Vector3.by_value, Vector3.by_value],
187
+ :Vector3Unproject => [Vector3.by_value, Matrix.by_value, Matrix.by_value],
188
+ :Vector3ToFloatV => [Vector3.by_value],
189
+ :MatrixDeterminant => [Matrix.by_value],
190
+ :MatrixTrace => [Matrix.by_value],
191
+ :MatrixTranspose => [Matrix.by_value],
192
+ :MatrixInvert => [Matrix.by_value],
193
+ :MatrixNormalize => [Matrix.by_value],
194
+ :MatrixIdentity => [],
195
+ :MatrixAdd => [Matrix.by_value, Matrix.by_value],
196
+ :MatrixSubtract => [Matrix.by_value, Matrix.by_value],
197
+ :MatrixMultiply => [Matrix.by_value, Matrix.by_value],
198
+ :MatrixTranslate => [:float, :float, :float],
199
+ :MatrixRotate => [Vector3.by_value, :float],
200
+ :MatrixRotateX => [:float],
201
+ :MatrixRotateY => [:float],
202
+ :MatrixRotateZ => [:float],
203
+ :MatrixRotateXYZ => [Vector3.by_value],
204
+ :MatrixRotateZYX => [Vector3.by_value],
205
+ :MatrixScale => [:float, :float, :float],
206
+ :MatrixFrustum => [:double, :double, :double, :double, :double, :double],
207
+ :MatrixPerspective => [:double, :double, :double, :double],
208
+ :MatrixOrtho => [:double, :double, :double, :double, :double, :double],
209
+ :MatrixLookAt => [Vector3.by_value, Vector3.by_value, Vector3.by_value],
210
+ :MatrixToFloatV => [Matrix.by_value],
211
+ :QuaternionAdd => [Quaternion.by_value, Quaternion.by_value],
212
+ :QuaternionAddValue => [Quaternion.by_value, :float],
213
+ :QuaternionSubtract => [Quaternion.by_value, Quaternion.by_value],
214
+ :QuaternionSubtractValue => [Quaternion.by_value, :float],
215
+ :QuaternionIdentity => [],
216
+ :QuaternionLength => [Quaternion.by_value],
217
+ :QuaternionNormalize => [Quaternion.by_value],
218
+ :QuaternionInvert => [Quaternion.by_value],
219
+ :QuaternionMultiply => [Quaternion.by_value, Quaternion.by_value],
220
+ :QuaternionScale => [Quaternion.by_value, :float],
221
+ :QuaternionDivide => [Quaternion.by_value, Quaternion.by_value],
222
+ :QuaternionLerp => [Quaternion.by_value, Quaternion.by_value, :float],
223
+ :QuaternionNlerp => [Quaternion.by_value, Quaternion.by_value, :float],
224
+ :QuaternionSlerp => [Quaternion.by_value, Quaternion.by_value, :float],
225
+ :QuaternionFromVector3ToVector3 => [Vector3.by_value, Vector3.by_value],
226
+ :QuaternionFromMatrix => [Matrix.by_value],
227
+ :QuaternionToMatrix => [Quaternion.by_value],
228
+ :QuaternionFromAxisAngle => [Vector3.by_value, :float],
229
+ :QuaternionToAxisAngle => [Quaternion.by_value, :pointer, :pointer],
230
+ :QuaternionFromEuler => [:float, :float, :float],
231
+ :QuaternionToEuler => [Quaternion.by_value],
232
+ :QuaternionTransform => [Quaternion.by_value, Matrix.by_value],
233
+ }
234
+ retvals = {
235
+ :Clamp => :float,
236
+ :Lerp => :float,
237
+ :Normalize => :float,
238
+ :Remap => :float,
239
+ :Vector2Zero => Vector2.by_value,
240
+ :Vector2One => Vector2.by_value,
241
+ :Vector2Add => Vector2.by_value,
242
+ :Vector2AddValue => Vector2.by_value,
243
+ :Vector2Subtract => Vector2.by_value,
244
+ :Vector2SubtractValue => Vector2.by_value,
245
+ :Vector2Length => :float,
246
+ :Vector2LengthSqr => :float,
247
+ :Vector2DotProduct => :float,
248
+ :Vector2Distance => :float,
249
+ :Vector2Angle => :float,
250
+ :Vector2Scale => Vector2.by_value,
251
+ :Vector2Multiply => Vector2.by_value,
252
+ :Vector2Negate => Vector2.by_value,
253
+ :Vector2Divide => Vector2.by_value,
254
+ :Vector2Normalize => Vector2.by_value,
255
+ :Vector2Lerp => Vector2.by_value,
256
+ :Vector2Reflect => Vector2.by_value,
257
+ :Vector2Rotate => Vector2.by_value,
258
+ :Vector2MoveTowards => Vector2.by_value,
259
+ :Vector3Zero => Vector3.by_value,
260
+ :Vector3One => Vector3.by_value,
261
+ :Vector3Add => Vector3.by_value,
262
+ :Vector3AddValue => Vector3.by_value,
263
+ :Vector3Subtract => Vector3.by_value,
264
+ :Vector3SubtractValue => Vector3.by_value,
265
+ :Vector3Scale => Vector3.by_value,
266
+ :Vector3Multiply => Vector3.by_value,
267
+ :Vector3CrossProduct => Vector3.by_value,
268
+ :Vector3Perpendicular => Vector3.by_value,
269
+ :Vector3Length => :float,
270
+ :Vector3LengthSqr => :float,
271
+ :Vector3DotProduct => :float,
272
+ :Vector3Distance => :float,
273
+ :Vector3Angle => :float,
274
+ :Vector3Negate => Vector3.by_value,
275
+ :Vector3Divide => Vector3.by_value,
276
+ :Vector3Normalize => Vector3.by_value,
277
+ :Vector3OrthoNormalize => :void,
278
+ :Vector3Transform => Vector3.by_value,
279
+ :Vector3RotateByQuaternion => Vector3.by_value,
280
+ :Vector3Lerp => Vector3.by_value,
281
+ :Vector3Reflect => Vector3.by_value,
282
+ :Vector3Min => Vector3.by_value,
283
+ :Vector3Max => Vector3.by_value,
284
+ :Vector3Barycenter => Vector3.by_value,
285
+ :Vector3Unproject => Vector3.by_value,
286
+ :Vector3ToFloatV => Float3.by_value,
287
+ :MatrixDeterminant => :float,
288
+ :MatrixTrace => :float,
289
+ :MatrixTranspose => Matrix.by_value,
290
+ :MatrixInvert => Matrix.by_value,
291
+ :MatrixNormalize => Matrix.by_value,
292
+ :MatrixIdentity => Matrix.by_value,
293
+ :MatrixAdd => Matrix.by_value,
294
+ :MatrixSubtract => Matrix.by_value,
295
+ :MatrixMultiply => Matrix.by_value,
296
+ :MatrixTranslate => Matrix.by_value,
297
+ :MatrixRotate => Matrix.by_value,
298
+ :MatrixRotateX => Matrix.by_value,
299
+ :MatrixRotateY => Matrix.by_value,
300
+ :MatrixRotateZ => Matrix.by_value,
301
+ :MatrixRotateXYZ => Matrix.by_value,
302
+ :MatrixRotateZYX => Matrix.by_value,
303
+ :MatrixScale => Matrix.by_value,
304
+ :MatrixFrustum => Matrix.by_value,
305
+ :MatrixPerspective => Matrix.by_value,
306
+ :MatrixOrtho => Matrix.by_value,
307
+ :MatrixLookAt => Matrix.by_value,
308
+ :MatrixToFloatV => Float16.by_value,
309
+ :QuaternionAdd => Quaternion.by_value,
310
+ :QuaternionAddValue => Quaternion.by_value,
311
+ :QuaternionSubtract => Quaternion.by_value,
312
+ :QuaternionSubtractValue => Quaternion.by_value,
313
+ :QuaternionIdentity => Quaternion.by_value,
314
+ :QuaternionLength => :float,
315
+ :QuaternionNormalize => Quaternion.by_value,
316
+ :QuaternionInvert => Quaternion.by_value,
317
+ :QuaternionMultiply => Quaternion.by_value,
318
+ :QuaternionScale => Quaternion.by_value,
319
+ :QuaternionDivide => Quaternion.by_value,
320
+ :QuaternionLerp => Quaternion.by_value,
321
+ :QuaternionNlerp => Quaternion.by_value,
322
+ :QuaternionSlerp => Quaternion.by_value,
323
+ :QuaternionFromVector3ToVector3 => Quaternion.by_value,
324
+ :QuaternionFromMatrix => Quaternion.by_value,
325
+ :QuaternionToMatrix => Matrix.by_value,
326
+ :QuaternionFromAxisAngle => Quaternion.by_value,
327
+ :QuaternionToAxisAngle => :void,
328
+ :QuaternionFromEuler => Quaternion.by_value,
329
+ :QuaternionToEuler => Vector3.by_value,
330
+ :QuaternionTransform => Quaternion.by_value,
331
+ }
332
+ symbols.each do |sym|
333
+ begin
334
+ attach_function sym, args[sym], retvals[sym]
335
+ rescue FFI::NotFoundError => error
336
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
337
+ end
338
+ end
339
+ end
340
+
341
+ end
342
+