Skip to main content

rustyray_sys/
consts.rs

1use bitmask_enum::bitmask;
2
3/// Mouse buttons
4#[repr(i32)]
5#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
6pub enum MouseButton {
7    /// Mouse button left
8    Left,
9    /// Mouse button right
10    Right,
11    /// Mouse button middle (pressed wheel)
12    Middle,
13    /// Mouse button side (advanced mouse device)
14    Side,
15    /// Mouse button extra (advanced mouse device)
16    Extra,
17    /// Mouse button forward (advanced mouse device)
18    Forward,
19    /// Mouse button back (advanced mouse device)
20    Back,
21}
22
23/// Mouse cursor
24#[repr(i32)]
25#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
26pub enum MouseCursor {
27    /// Default pointer shape
28    Default,
29    /// Arrow shape
30    Arrow,
31    /// Text writing cursor shape
32    Ibeam,
33    /// Cross shape
34    Crosshair,
35    /// Pointing hand cursor
36    PointingHand,
37    /// Horizontal resize/move arrow shape
38    ResizeEW,
39    /// Vertical resize/move arrow shape
40    ResizeNS,
41    /// Top-left to bottom-right diagonal resize/move arrow shape
42    ResizeNWSE,
43    /// Top-right to bottom-left diagonal resize/move arrow shape
44    ResizeNESW,
45    /// The omnidirectional resize/move cursor shape
46    ResizeAll,
47    /// The operation-not-allowed shape
48    NotAllowed,
49}
50
51/// Gamepad buttons
52#[repr(i32)]
53#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
54pub enum GamepadButton {
55    /// Unknown button, just for error checking
56    UNKNOWN = 0,
57    /// Gamepad left DPAD up button
58    LeftFaceUp,
59    /// Gamepad left DPAD right button
60    LeftFaceRight,
61    /// Gamepad left DPAD down button
62    LeftFaceDown,
63    /// Gamepad left DPAD left button
64    LeftFaceLeft,
65    /// Gamepad right button up (i.e. PS3: Triangle, Xbox: Y)
66    RightFaceUp,
67    /// Gamepad right button right (i.e. PS3: Circle, Xbox: B)
68    RightFaceRight,
69    /// Gamepad right button down (i.e. PS3: Cross, Xbox: A)
70    RightFaceDown,
71    /// Gamepad right button left (i.e. PS3: Square, Xbox: X)
72    RightFaceLeft,
73    /// Gamepad top/back trigger left (first), it could be a trailing button
74    LeftTrigger1,
75    /// Gamepad top/back trigger left (second), it could be a trailing button
76    LeftTrigger2,
77    /// Gamepad top/back trigger right (first), it could be a trailing button
78    RightTrigger1,
79    /// Gamepad top/back trigger right (second), it could be a trailing button
80    RightTrigger2,
81    /// Gamepad center buttons, left one (i.e. PS3: Select)
82    MiddleLeft,
83    /// Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX)
84    Middle,
85    /// Gamepad center buttons, right one (i.e. PS3: Start)
86    MiddleRight,
87    /// Gamepad joystick pressed button left
88    LeftThumb,
89    /// Gamepad joystick pressed button right
90    RightThumb,
91}
92
93impl From<i32> for GamepadButton {
94    fn from(value: i32) -> Self {
95        // SAFETY: `GamepadButton` is `#[repr(i32)]` with values matching raylib's `GamepadButton`.
96        unsafe { std::mem::transmute(value) }
97    }
98}
99
100/// Gamepad axis
101#[repr(i32)]
102#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
103pub enum GamepadAxis {
104    /// Gamepad left stick X axis
105    LeftX,
106    /// Gamepad left stick Y axis
107    LeftY,
108    /// Gamepad right stick X axis
109    RightX,
110    /// Gamepad right stick Y axis
111    RightY,
112    /// Gamepad back trigger left, pressure level: [1..-1]
113    TriggerLeft,
114    /// Gamepad back trigger right, pressure level: [1..-1]
115    TriggerRight,
116}
117
118/// Material map index
119#[repr(i32)]
120#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
121pub enum MaterialMap {
122    /// Albedo material (same as: [MATERIAL_MAP_DIFFUSE])
123    Albedo,
124    /// Metalness material (same as: [MATERIAL_MAP_SPECULAR])
125    Metalness,
126    /// Normal material
127    Normal,
128    /// Roughness material
129    Roughness,
130    /// Ambient occlusion material
131    Occlusion,
132    /// Emission material
133    Emission,
134    /// Heightmap material
135    Height,
136    /// Cubemap material (**NOTE**: Uses GL_TEXTURE_CUBE_MAP)
137    Cubemap,
138    /// Irradiance material (**NOTE**: Uses GL_TEXTURE_CUBE_MAP)
139    Irradiance,
140    /// Prefilter material (**NOTE**: Uses GL_TEXTURE_CUBE_MAP)
141    Prefilter,
142    /// BRDF material
143    BRDF,
144}
145
146pub const MATERIAL_MAP_DIFFUSE: MaterialMap = MaterialMap::Albedo;
147pub const MATERIAL_MAP_SPECULAR: MaterialMap = MaterialMap::Metalness;
148
149/// [crate::texture::Texture] parameters: filter mode
150/// - **NOTE 1**: Filtering considers mipmaps if available in the texture
151/// - **NOTE 2**: Filter is accordingly set for minification and magnification
152#[repr(i32)]
153#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
154pub enum TextureFilter {
155    /// No filter, just pixel approximation
156    Point,
157    /// Linear filtering
158    Bilinear,
159    /// Trilinear filtering (linear with mipmaps)
160    Trilinear,
161    /// Anisotropic filtering 4x
162    Anisotropic4X,
163    /// Anisotropic filtering 8x
164    Anisotropic8X,
165    /// Anisotropic filtering 16x
166    Anisotropic16X,
167}
168
169/// [crate::texture::Texture] parameters: wrap mode
170#[repr(i32)]
171#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
172pub enum TextureWrap {
173    /// Repeats [crate::texture::Texture] in tiled mode
174    Repeat,
175    /// Clamps [crate::texture::Texture] to edge pixel in tiled mode
176    Clamp,
177    /// Mirrors and repeats the [crate::texture::Texture] in tiled mode
178    MirrorRepeat,
179    /// Mirrors and clamps to border the [crate::texture::Texture] in tiled mode
180    MirrorClamp,
181}
182
183/// Font type, defines generation method
184#[repr(i32)]
185#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
186pub enum FontType {
187    /// Default font generation, anti-alised
188    Default,
189    /// Bitmap font generation, no anti-aliasing
190    Bitmap,
191    /// SDF font generation, requires external shader
192    SDF,
193}
194
195/// Color blending modes (pre-defined)
196#[repr(i32)]
197#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
198pub enum BlendMode {
199    /// Blend textures considering alpha (default)
200    Alpha,
201    /// Blend textures adding colors
202    Additive,
203    /// Blend textures multiplying colors
204    Multiplied,
205    /// Blend textures adding colors (alternative)
206    AddColors,
207    /// Blend textures subtracting colors (alternative)
208    SubtractColors,
209    /// Blend premultiplied textures considering alpha
210    AlphaPremultiply,
211    /// Blend textures using custom src/dst factors (use rlSetBlendFactors())
212    Custom,
213    /// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())
214    CustomSeparate,
215}
216
217/// Gesture
218#[bitmask(u32)]
219pub enum Gesture {
220    /// No gesture
221    None,
222    /// Tap gesture
223    Tap,
224    /// Double tap gesture
225    DoubleTap,
226    /// Hold gesture
227    Hold,
228    /// Drag gesture
229    Drag,
230    /// Swipe right gesture
231    SwipeRight,
232    /// Swipe left gesture
233    SwipeLeft,
234    /// Swipe up gesture
235    SwipeUp,
236    /// Swipe down gesture
237    SwipeDown,
238    /// Pinch in gesture
239    PinchIn,
240    /// Pinch out gesture
241    PinchOut,
242}
243
244/// Camera system modes
245#[repr(i32)]
246#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
247pub enum CameraMode {
248    /// Camera custom, controlled by user ([crate::ffi::update_camera] does nothing)
249    Custom,
250    /// Camera free mode
251    Free,
252    /// Camera orbital, around target, zoom supported
253    Orbital,
254    /// Camera first person
255    FirstPerson,
256    /// Camera third person
257    ThridPerson,
258}
259
260/// Camera projection
261#[repr(i32)]
262#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
263pub enum CameraProjection {
264    /// Perspective projection
265    Perspective,
266    /// Orthographic projection
267    Orthographic,
268}
269
270/// N-patch layout
271#[repr(i32)]
272#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
273pub enum NPatchLayout {
274    /// Npatch layout: 3x3 tiles
275    NinePatch,
276    /// Npatch layout: 1x3 tiles
277    ThreePatchVertical,
278    /// Npatch layout: 3x1 tiles
279    ThreePatchHorizontal,
280}
281
282/// Trace log level
283///
284/// **NOTE**: Organized by priority level
285#[repr(i32)]
286#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
287pub enum TraceLogLevel {
288    /// Display all logs
289    All,
290    /// Trace logging, intended for interal use only
291    Trace,
292    /// Debug logging, used for internal debugging, it should be disabled on release builds
293    Debug,
294    /// Info logging, used for program execution info
295    Info,
296    /// Warning logging, used for recoverable failures
297    Warning,
298    /// Error logging, used for unrecoverable failures
299    Error,
300    /// Fatal logging, used to abort program: exit(EXIT_FAILURE)
301    Fatal,
302    /// Disable logging
303    None,
304}
305
306/// Keyboard keys (US keyboard layout)
307///
308/// **NOTE**: Use [crate::ffi::get_key_pressed] to allow redefining
309/// required keys for alternative layouts
310#[repr(i32)]
311#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
312pub enum KeyboardKey {
313    /// Key: NULL, used for no key pressed
314    Null = 0,
315    // Alphanumeric keys
316    /// Key: `'`
317    Apostrophe = 39,
318    /// Key: `,`
319    Comma = 44,
320    /// Key: `-`
321    Minus = 45,
322    /// Key: `.`
323    Period = 46,
324    /// Key: `/`
325    Slash = 47,
326    /// Key: `0`
327    Zero = 48,
328    /// Key: `1`
329    One = 49,
330    /// Key: `2`
331    Two = 50,
332    /// Key: `3`
333    Three = 51,
334    /// Key: `4`
335    Four = 52,
336    /// Key: `5`
337    Five = 53,
338    /// Key: `6`
339    Six = 54,
340    /// Key: `7`
341    Seven = 55,
342    /// Key: `8`
343    Eight = 56,
344    /// Key: `9`
345    Nine = 57,
346    /// Key: `;`
347    Semicolon = 59,
348    /// Key: `=`
349    Equal = 61,
350    /// Key: `A` | `a`
351    A = 65,
352    /// Key: `B` | `b`
353    B = 66,
354    /// Key: `C` | `c`
355    C = 67,
356    /// Key: `D` | `d`
357    D = 68,
358    /// Key: `E` | `e`
359    E = 69,
360    /// Key: `F` | `f`
361    F = 70,
362    /// Key: `G` | `g`
363    G = 71,
364    /// Key: `H` | `h`
365    H = 72,
366    /// Key: `I` | `i`
367    I = 73,
368    /// Key: `J` | `j`
369    J = 74,
370    /// Key: `K` | `k`
371    K = 75,
372    /// Key: `L` | `l`
373    L = 76,
374    /// Key: `M` | `m`
375    M = 77,
376    /// Key: `N` | `n`
377    N = 78,
378    /// Key: `O` | `o`
379    O = 79,
380    /// Key: `P` | `p`
381    P = 80,
382    /// Key: `Q` | `q`
383    Q = 81,
384    /// Key: `R` | `r`
385    R = 82,
386    /// Key: `S` | `s`
387    S = 83,
388    /// Key: `T` | `t`
389    T = 84,
390    /// Key: `U` | `u`
391    U = 85,
392    /// Key: `V` | `v`
393    V = 86,
394    /// Key: `W` | `w`
395    W = 87,
396    /// Key: `X` | `x`
397    X = 88,
398    /// Key: `Y` | `y`
399    Y = 89,
400    /// Key: `Z` | `z`
401    Z = 90,
402    /// Key: `[`
403    LeftBracket = 91,
404    /// Key: `\`
405    Backslash = 92,
406    /// Key: `]`
407    RightBracket = 93,
408    /// Key  `\``
409    Grave = 96,
410    // Function keys
411    /// Key: `Space`
412    Space = 32,
413    /// Key: `Esc`
414    Escape = 256,
415    /// Key: `Enter`
416    Enter = 257,
417    /// Key: `Tab`
418    Tab = 258,
419    /// Key: `Backspace`
420    Backspace = 259,
421    /// Key: `Ins`
422    Insert = 260,
423    /// Key: `Del`
424    Delete = 261,
425    /// Key: `Cursor right`
426    Right = 262,
427    /// Key: `Cursor left`
428    Left = 263,
429    /// Key: `Cursor down`
430    Down = 264,
431    /// Key: `Cursor up`
432    Up = 265,
433    /// Key: `Page up`
434    PageUp = 266,
435    /// Key: `Page down`
436    PageDown = 267,
437    /// Key: `Home`
438    Home = 268,
439    /// Key: `End`
440    End = 269,
441    /// Key: `Caps lock`
442    CapsLock = 280,
443    /// Key: `Scroll lock`
444    ScrollLock = 281,
445    /// Key: `Num lock`
446    NumLock = 282,
447    /// Key: `Print screen`
448    PrintScreen = 283,
449    /// Key: `Pause`
450    Pause = 284,
451    /// Key: `F1`
452    F1 = 290,
453    /// Key: `F2`
454    F2 = 291,
455    /// Key: `F3`
456    F3 = 292,
457    /// Key: `F4`
458    F4 = 293,
459    /// Key: `F5`
460    F5 = 294,
461    /// Key: `F6`
462    F6 = 295,
463    /// Key: `F7`
464    F7 = 296,
465    /// Key: `F8`
466    F8 = 297,
467    /// Key: `F9`
468    F9 = 298,
469    /// Key: `F10`
470    F10 = 299,
471    /// Key: `F11`
472    F11 = 300,
473    /// Key: `F12`
474    F12 = 301,
475    /// Key: `Shift left`
476    LeftShift = 340,
477    /// Key: `Control left`
478    LeftControl = 341,
479    /// Key: `Alt left`
480    LeftAlt = 342,
481    /// Key: `Super left`
482    LeftSuper = 343,
483    /// Key: `Shift right`
484    RightShift = 344,
485    /// Key: `Control right`
486    RightControl = 345,
487    /// Key: `Alt right`
488    RightAlt = 346,
489    /// Key: `Super right`
490    RightSuper = 347,
491    /// Key: `KB menu`
492    KBMenu = 348,
493    // Keypad keys
494    /// Key: `Keypad 0`
495    KP0 = 320,
496    /// Key: `Keypad 1`
497    KP1 = 321,
498    /// Key: `Keypad 2`
499    KP2 = 322,
500    /// Key: `Keypad 3`
501    KP3 = 323,
502    /// Key: `Keypad 4`
503    KP4 = 324,
504    /// Key: `Keypad 5`
505    KP5 = 325,
506    /// Key: `Keypad 6`
507    KP6 = 326,
508    /// Key: `Keypad 7`
509    KP7 = 327,
510    /// Key: `Keypad 8`
511    KP8 = 328,
512    /// Key: `Keypad 9`
513    KP9 = 329,
514    /// Key: `Keypad .`
515    KPDecimal = 330,
516    /// Key: `Keypad /`
517    KPDivide = 331,
518    /// Key: `Keypad *`
519    KPMultiply = 332,
520    /// Key: `Keypad -`
521    KPSubtract = 333,
522    /// Key: `Keypad +`
523    KPAdd = 334,
524    /// Key: `Keypad Enter`
525    KPEnter = 335,
526    /// Key: `Keypad =`
527    KPEqual = 336,
528    // Android key button
529    /// Key: `Android back button`
530    Back = 4,
531    /// Key: `Android menu button`
532    Menu = 5,
533    /// Key: `Android volume up button`
534    VolumeUp = 24,
535    /// Key: `Android volume down button`
536    VolumeDown = 25,
537}
538
539/// System/Window config flags
540///
541/// **NOTE**: Every bit registers one state (use it with bit masks)
542///
543/// By default all flags are set to `0`
544#[bitmask(u32)]
545pub enum ConfigFlag {
546    /// Set to try enabling V-Sync on GPU
547    VsyncHint = 0x00000040,
548    /// Set to run program in fullscreen
549    FullscreenMode = 0x00000002,
550    /// Set to allow resizable window
551    WindowResizable = 0x00000004,
552    /// Set to disable window decoration (frame and buttons)
553    WindowUndecorated = 0x00000008,
554    /// Set to hide window
555    WindowHidden = 0x00000080,
556    /// Set to minimize window (iconify)
557    WindowMinimized = 0x00000200,
558    /// Set to maximize window (expanded to monitor)
559    WindowMaximized = 0x00000400,
560    /// Set to window non focused
561    WindowUnfocused = 0x00000800,
562    /// Set to window always on top
563    WindowTopmost = 0x00001000,
564    /// Set to allow windows running while
565    WindowAlwaysRun = 0x00000100,
566    /// Set to allow transparent framebuffer
567    WindowTransparent = 0x00000010,
568    /// Set to support HighDPI
569    WindowHighdpi = 0x00002000,
570    /// Set to support mouse passthrough, only supported when [ConfigFlag::WindowUndecorated]
571    WindowMousePassthrough = 0x00004000,
572    /// Set to run program in borderless windowed mode
573    BorderlessWindowedMode = 0x00008000,
574    /// Set to try enabling MSAA 4X
575    Msaa4xHint = 0x00000020,
576    /// Set to try enabling interlaced video format (for V3D)
577    InterlacedHint = 0x00010000,
578}