rustyray_sys/ffi.rs
1/**********************************************************************************************
2*
3* raylib v5.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
4*
5* FEATURES:
6* - NO external dependencies, all required libraries included with raylib
7* - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly,
8* MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5.
9* - Written in plain C code (C99) in PascalCase/camelCase notation
10* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3, ES2, ES3 - choose at compile)
11* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]
12* - Multiple Fonts formats supported (TTF, OTF, FNT, BDF, Sprite fonts)
13* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
14* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!
15* - Flexible Materials system, supporting classic maps and PBR maps
16* - Animated 3D models supported (skeletal bones animation) (IQM, M3D, GLTF)
17* - Shaders support, including Model shaders and Postprocessing shaders
18* - Powerful math module for Vector, Matrix and Quaternion operations: [raymath]
19* - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, QOA, XM, MOD)
20* - VR stereo rendering with configurable HMD device parameters
21* - Bindings to multiple programming languages available!
22*
23* NOTES:
24* - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text]
25* - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2)
26* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2)
27* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)
28*
29* DEPENDENCIES (included):
30* [rcore][GLFW] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input
31* [rcore][RGFW] rgfw (ColleagueRiley - github.com/ColleagueRiley/RGFW) for window/context management and input
32* [rlgl] glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading
33* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management
34*
35* OPTIONAL DEPENDENCIES (included):
36* [rcore] msf_gif (Miles Fogle) for GIF recording
37* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm
38* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm
39* [rcore] rprand (Ramon Snatamaria) for pseudo-random numbers generation
40* [rtextures] qoi (Dominic Szablewski - https://phoboslab.org) for QOI image manage
41* [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...)
42* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)
43* [rtextures] stb_image_resize2 (Sean Barret) for image resizing algorithms
44* [rtextures] stb_perlin (Sean Barret) for Perlin Noise image generation
45* [rtext] stb_truetype (Sean Barret) for ttf fonts loading
46* [rtext] stb_rect_pack (Sean Barret) for rectangles packing
47* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation
48* [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL)
49* [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF)
50* [rmodels] m3d (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d)
51* [rmodels] vox_loader (Johann Nadalutti) for models loading (VOX)
52* [raudio] dr_wav (David Reid) for WAV audio file loading
53* [raudio] dr_flac (David Reid) for FLAC audio file loading
54* [raudio] dr_mp3 (David Reid) for MP3 audio file loading
55* [raudio] stb_vorbis (Sean Barret) for OGG audio loading
56* [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading
57* [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading
58* [raudio] qoa (Dominic Szablewski - https://phoboslab.org) for QOA audio manage
59*
60*
61* LICENSE: zlib/libpng
62*
63* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
64* BSD-like license that allows static linking with closed source software:
65*
66* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
67*
68* This software is provided "as-is", without any express or implied warranty. In no event
69* will the authors be held liable for any damages arising from the use of this software.
70*
71* Permission is granted to anyone to use this software for any purpose, including commercial
72* applications, and to alter it and redistribute it freely, subject to the following restrictions:
73*
74* 1. The origin of this software must not be misrepresented; you must not claim that you
75* wrote the original software. If you use this software in a product, an acknowledgment
76* in the product documentation would be appreciated but is not required.
77*
78* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
79* as being the original software.
80*
81* 3. This notice may not be removed or altered from any source distribution.
82*
83**********************************************************************************************/
84
85use libc::{c_char, c_double, c_float, c_int, c_uchar, c_uint, c_void};
86
87use crate::{
88 audio::{AudioCallback, AudioStream, Music, Sound, Wave},
89 color::Color,
90 consts::{ConfigFlag, MouseButton},
91 rectangle::Rectangle,
92 texture::{Image, RenderTexture, RenderTexture2D, Texture},
93 vector::Vector2,
94};
95
96// Window-related functions
97unsafe extern "C" {
98 /// Initialize window and OpenGL context
99 #[link_name = "InitWindow"]
100 pub fn init_window(width: c_int, height: c_int, title: *const c_char);
101 /// Close window and unload OpenGL context
102 #[link_name = "CloseWindow"]
103 pub fn close_window();
104 /// Check if application should close (KEY_ESCAPE pressed or windows close icon clicked)
105 #[link_name = "WindowShouldClose"]
106 pub fn window_should_close() -> bool;
107 /// Check if window has been initialized successfully
108 #[link_name = "IsWindowReady"]
109 pub fn is_window_ready() -> bool;
110 /// Check if window is currently fullscreen
111 #[link_name = "IsWindowFullscreen"]
112 pub fn is_window_fullscreen() -> bool;
113 /// Check if window is currently hidden
114 #[link_name = "IsWindowHidden"]
115 pub fn is_window_hidden() -> bool;
116 /// Check if window is currently minimized
117 #[link_name = "IsWindowMinimized"]
118 pub fn is_window_minimized() -> bool;
119 /// Check if window is currently maximized
120 #[link_name = "IsWindowMaximized"]
121 pub fn is_window_maximized() -> bool;
122 /// Check if window is currently focused
123 #[link_name = "IsWindowFocused"]
124 pub fn is_window_focused() -> bool;
125 /// Check if window has been resized last frame
126 #[link_name = "IsWindowResized"]
127 pub fn is_window_resized() -> bool;
128 /// Check if one specific window flag is enabled
129 ///
130 /// Flags should be of values defined in [ConfigFlag].
131 ///
132 /// Use this value as a bitmask.
133 ///
134 /// # Examples
135 /// ```no_run
136 /// use rustyray_sys::{ffi::is_window_state, consts::ConfigFlag};
137 ///
138 /// unsafe { is_window_state(ConfigFlag::VsyncHint | ConfigFlag::FullscreenMode) };
139 /// ```
140 #[link_name = "IsWindowState"]
141 pub fn is_window_state(flags: ConfigFlag) -> bool;
142 /// Set window configuration state using flags
143 ///
144 /// Flags should be of values defined in [ConfigFlag].
145 ///
146 /// Use this value as a bitmask.
147 ///
148 /// # Examples
149 /// ```no_run
150 /// use rustyray_sys::{ffi::set_window_state, consts::ConfigFlag};
151 ///
152 /// unsafe { set_window_state(ConfigFlag::VsyncHint | ConfigFlag::FullscreenMode); }
153 /// ```
154 #[link_name = "SetWindowState"]
155 pub fn set_window_state(flags: ConfigFlag);
156 /// Clear window configuration state flags
157 ///
158 /// Flags should be of values defined in [ConfigFlag].
159 ///
160 /// Use this value as a bitmask.
161 ///
162 /// # Examples
163 /// ```no_run
164 /// use rustyray_sys::{ffi::clear_window_state, consts::ConfigFlag};
165 ///
166 /// unsafe { clear_window_state(ConfigFlag::VsyncHint | ConfigFlag::FullscreenMode); }
167 /// ```
168 #[link_name = "ClearWindowState"]
169 pub fn clear_window_state(flags: ConfigFlag);
170 /// Toggle window state: fullscreen/windowed, resizes monitor to match window resolution
171 #[link_name = "ToggleFullscreen"]
172 pub fn toggle_fullscreen();
173 /// Toggle window state: borderless windowed, resizes window to match monitor resolution
174 #[link_name = "ToggleBorderlessWindowed"]
175 pub fn toggle_borderless_windowed();
176 /// Set window state: maximized, if resizable
177 #[link_name = "MaximizeWindow"]
178 pub fn maximize_window();
179 /// Set window state: minimized, if resizable
180 #[link_name = "MinimizeWindow"]
181 pub fn minimize_window();
182 /// Set window state: not minimized/maximized
183 #[link_name = "RestoreWindow"]
184 pub fn restore_window();
185 /// Set icon for window (single image, RGBA 32bit)
186 #[link_name = "SetWindowIcon"]
187 pub fn set_window_icon(image: Image);
188 /// Set icon for window (multiple images, RGBA 32bit)
189 #[link_name = "SetWindowIcons"]
190 pub fn set_window_icons(images: *const Image);
191 /// Set title for window
192 #[link_name = "SetWindowTitle"]
193 pub fn set_window_title(images: *const c_char);
194 /// Set window position on screen
195 #[link_name = "SetWindowPosition"]
196 pub fn set_window_position(x: c_int, y: c_int);
197 /// Set monitor for the current window
198 #[link_name = "SetWindowMonitor"]
199 pub fn set_window_monitor(monitor: c_int);
200 /// Set window minimum dimensions (for [ConfigFlag::WindowResizable])
201 #[link_name = "SetWindowMinSize"]
202 pub fn set_window_min_size(width: c_int, height: c_int);
203 /// Set window maximum dimensions (for [ConfigFlag::WindowResizable])
204 #[link_name = "SetWindowMaxSize"]
205 pub fn set_window_max_size(width: c_int, height: c_int);
206 /// Set window dimension
207 #[link_name = "SetWindowSize"]
208 pub fn set_window_size(width: c_int, height: c_int);
209 /// Set window opacity [0.0..1.0]
210 #[link_name = "SetWindowOpacity"]
211 pub fn set_window_opacity(opacity: c_float);
212 /// Set window focused
213 #[link_name = "SetWindowFocused"]
214 pub fn set_window_focused();
215 /// Get current screen width
216 #[link_name = "GetScreenWidth"]
217 pub fn get_screen_width() -> c_int;
218 /// Get current screen height
219 #[link_name = "GetScreenHeight"]
220 pub fn get_screen_height() -> c_int;
221 /// Get current render width (it considers HiDPI)
222 #[link_name = "GetRenderWidth"]
223 pub fn get_render_width() -> c_int;
224 /// Get current render height (it considers HiDPI)
225 #[link_name = "GetRenderHeight"]
226 pub fn get_render_height() -> c_int;
227 /// Get number of connected monitors
228 #[link_name = "GetMonitorCount"]
229 pub fn get_monitor_count() -> c_int;
230 /// Get current monitor where window is placed
231 #[link_name = "GetCurrentMonitor"]
232 pub fn get_current_monitor() -> c_int;
233 /// Get specified monitor position
234 #[link_name = "GetMonitorPosition"]
235 pub fn get_monitor_position(monitor: c_int) -> Vector2;
236 /// Get specified monitor width (current video mode used by monitor)
237 #[link_name = "GetMonitorWidth"]
238 pub fn get_monitor_width(monitor: c_int) -> c_int;
239 /// Get specified monitor height (current video mode used by monitor)
240 #[link_name = "GetMonitorHeight"]
241 pub fn get_monitor_height(monitor: c_int) -> c_int;
242 /// Get specified monitor physical width in millimetres
243 #[link_name = "GetMonitorPhysicalWidth"]
244 pub fn get_monitor_physical_width(monitor: c_int) -> c_int;
245 /// Get specified monitor physical height in millimetres
246 #[link_name = "GetMonitorPhysicalHeight"]
247 pub fn get_monitor_physical_height(monitor: c_int) -> c_int;
248 /// Get specified monitor refresh rate
249 #[link_name = "GetMonitorRefreshRate"]
250 pub fn get_monitor_refresh_rate(monitor: c_int) -> c_int;
251 /// Get position XY on monitor
252 #[link_name = "GetWindowPosition"]
253 pub fn get_window_position() -> Vector2;
254 /// Get window scale DPI factor
255 #[link_name = "GetWindowScaleDPI"]
256 pub fn get_window_scale_dpi() -> Vector2;
257 /// Get the human-readable, UTF-8 encoded name of the specified monitor
258 #[link_name = "GetMonitorName"]
259 pub fn get_monitor_name(monitor: c_int) -> *const c_char;
260 /// Set clipboard text content
261 #[link_name = "SetClipboardText"]
262 pub fn set_clipboard_text(text: *const c_char);
263 /// Get clipboard text content
264 #[link_name = "GetClipboardText"]
265 pub fn get_clipboard_text() -> *const c_char;
266 /// Get clipboard image content
267 #[link_name = "GetClipboardImage"]
268 pub fn get_clipboard_image() -> Image;
269 /// Enable waiting for events on [end_drawing], no automatic event polling
270 #[link_name = "EnableEventWaiting"]
271 pub fn enable_event_waiting();
272 /// Disable waiting for events on [end_drawing], automatic event polling
273 #[link_name = "DisableEventWaiting"]
274 pub fn disable_event_waiting();
275}
276
277// Cursor-related functions
278unsafe extern "C" {
279 /// Shows cursor
280 #[link_name = "ShowCursor"]
281 pub fn show_cursor();
282 /// Hides cursor
283 #[link_name = "HideCursor"]
284 pub fn hide_cursor();
285 /// Check if cursor is not visible
286 #[link_name = "IsCursorHidden"]
287 pub fn is_cursor_hidden();
288 /// Enables cursor (unlock cursor)
289 #[link_name = "EnableCursor"]
290 pub fn enable_cursor();
291 /// Disabled cursor (lock cursor)
292 #[link_name = "DisableCursor"]
293 pub fn disable_cursor();
294 /// Check if cursor is on the screen
295 #[link_name = "IsCursorOnScreen"]
296 pub fn is_cursor_on_screen();
297}
298
299// Drawing related functions
300unsafe extern "C" {
301 /// Set background color (framebuffer clear color)
302 #[link_name = "ClearBackground"]
303 pub fn clear_background(color: Color);
304 /// Setup canvas (framebuffer) to start drawing
305 #[link_name = "BeginDrawing"]
306 pub fn begin_drawing();
307 /// End canvas drawing and swap buffers (double buffering)
308 #[link_name = "EndDrawing"]
309 pub fn end_drawing();
310 /// Begin drawing to render texture
311 #[link_name = "BeginTextureMode"]
312 pub fn begin_texture_mode(render_texture: RenderTexture2D);
313 /// Ends drawing to render texture
314 #[link_name = "EndTextureMode"]
315 pub fn end_texture_mode();
316}
317
318// Texture loading functions
319// Note: These function require GPU access
320unsafe extern "C" {
321 /// Load texture from file into GPU memory (VRAM)
322 #[link_name = "LoadTexture"]
323 pub fn load_texture(path: *const c_char) -> Texture;
324 /// Load texture from image data
325 #[link_name = "LoadTextureFromImage"]
326 pub fn load_texture_from_image(image: Image) -> Texture;
327 /// Load texture for rendering (framebuffer)
328 #[link_name = "LoadRenderTexture"]
329 pub fn load_render_texture(width: c_int, height: c_int) -> RenderTexture;
330 /// Check if a texture is valid (loaded in GPU)
331 #[link_name = "IsTextureValid"]
332 pub fn is_texture_valid(texture: Texture) -> bool;
333 /// Unload texture from GPU memory (VRAM)
334 #[link_name = "UnloadTexture"]
335 pub fn unload_texture(texture: Texture);
336 /// Check if a render texture is valid (loaded in GPU)
337 #[link_name = "IsRenderTextureValid"]
338 pub fn is_render_texture_valid(target: RenderTexture) -> bool;
339 /// Unload render texture from GPU memory (VRAM)
340 #[link_name = "UnloadRenderTexture"]
341 pub fn unload_render_texture(render_texture: RenderTexture);
342 /// Update GPU texture with new data
343 #[link_name = "UpdateTexture"]
344 pub fn update_texture(texture: Texture, pixels: *const c_void);
345 /// Update GPU texture rectangle with new data
346 #[link_name = "UpdateTextureRec"]
347 pub fn update_texture_rec(texture: Texture, rec: Rectangle, pixels: *const c_void);
348}
349
350// Texture configuration function
351unsafe extern "C" {
352 /// Generate GPU mipmaps for a texture
353 #[link_name = "GenTextureMipmaps"]
354 pub fn gen_texture_mipmaps(texture: *mut Texture);
355 /// Set texture scaling filter mode
356 #[link_name = "SetTextureFilter"]
357 pub fn set_texture_filter(texture: Texture, filter: c_int);
358 /// Set texture wrapping mode
359 #[link_name = "SetTextureWrap"]
360 pub fn set_texture_wrap(texture: Texture, wrap: c_int);
361}
362
363// Texture drawing functions
364unsafe extern "C" {
365 /// Draw a [Texture]
366 #[link_name = "DrawTexture"]
367 pub fn draw_texture(texture: Texture, pos_x: c_int, pos_y: c_int, tint: Color);
368 /// Draw a [Texture] with position defined as [Vector2]
369 #[link_name = "DrawTextureV"]
370 pub fn draw_texture_v(texture: Texture, pos: Vector2, tint: Color);
371 /// Draw a [Texture] with extended parameters
372 #[link_name = "DrawTextureEx"]
373 pub fn draw_texture_ex(
374 texture: Texture,
375 pos: Vector2,
376 rotation: c_float,
377 scale: c_float,
378 tint: Color,
379 );
380 /// Draw a part of a [Texture] defined by a [Rectangle]
381 #[link_name = "DrawTextureRec"]
382 pub fn draw_texture_rec(texture: Texture, source: Rectangle, position: Vector2, tint: Color);
383 /// Draw a part of a [Texture] defined by a [Rectangle] with 'pro' parameters
384 #[link_name = "DrawTexturePro"]
385 pub fn draw_texture_pro(
386 texture: Texture,
387 source: Rectangle,
388 dest: Rectangle,
389 origin: Vector2,
390 rotation: c_float,
391 tint: Color,
392 );
393 // TODO: Add draw_texture_npatch when NPatchInfo is implemented
394}
395
396// Text drawing functions
397unsafe extern "C" {
398 /// Draw current FPS
399 #[link_name = "DrawFPS"]
400 pub fn draw_fps(pos_x: c_int, pos_y: c_int);
401 /// Draw text (using default font)
402 #[link_name = "DrawText"]
403 pub fn draw_text(
404 text: *const c_char,
405 pos_x: c_int,
406 pos_y: c_int,
407 font_size: c_int,
408 color: Color,
409 );
410}
411
412// Text font info functions
413unsafe extern "C" {
414 /// Measure string width for default font
415 #[link_name = "MeasureText"]
416 pub fn measure_text(text: *const c_char, font_size: c_int);
417}
418
419// Basic shapes drawing functions
420unsafe extern "C" {
421 /// Draw a color-filled rectangle
422 #[link_name = "DrawRectangleRec"]
423 pub fn draw_rectangle_rec(rec: Rectangle, color: Color);
424}
425
426// Input-related functions: mouse
427unsafe extern "C" {
428 /// Check if a mouse button is beening pressed
429 #[link_name = "IsMouseButtonDown"]
430 pub fn is_mouse_button_down(button: MouseButton) -> bool;
431 /// Get mouse position X
432 #[link_name = "GetMouseX"]
433 pub fn get_mouse_x() -> c_int;
434 /// Get mouse position Y
435 #[link_name = "GetMouseY"]
436 pub fn get_mouse_y() -> c_int;
437 /// Get mouse position XY
438 #[link_name = "GetMousePosition"]
439 pub fn get_mouse_position() -> Vector2;
440}
441
442// Timing-related functions
443unsafe extern "C" {
444 /// Set target FPS (maximum)
445 #[link_name = "SetTargetFPS"]
446 pub fn set_target_fps(fps: c_int);
447 /// Get time in seconds for last frame drawn (delta time)
448 #[link_name = "GetFrameTime"]
449 pub fn get_frame_time() -> c_float;
450 /// Get elapsed time in seconds since InitWindow()
451 #[link_name = "GetTime"]
452 pub fn get_time() -> c_double;
453 /// Get current FPS
454 #[link_name = "GetFPS"]
455 pub fn get_fps() -> c_int;
456}
457
458// Misc functions
459unsafe extern "C" {
460 /// Setup init configuration flags
461 ///
462 /// Flags should be of values defined in [ConfigFlag].
463 ///
464 /// Use this value as a bitmask.
465 ///
466 /// # Examples
467 /// ```no_run
468 /// use rustyray_sys::{ffi::set_config_flags, consts::ConfigFlag};
469 ///
470 /// unsafe { set_config_flags(ConfigFlag::VsyncHint | ConfigFlag::FullscreenMode) }
471 /// ```
472 #[link_name = "SetConfigFlags"]
473 pub fn set_config_flags(flags: ConfigFlag);
474}
475
476// Audio device management functions
477unsafe extern "C" {
478 /// Initialize audio device and context
479 #[link_name = "InitAudioDevice"]
480 pub fn init_audio_device();
481 /// Close the audio device and context
482 #[link_name = "CloseAudioDevice"]
483 pub fn close_audio_device();
484 /// Check if audio device has been initialized successfully
485 #[link_name = "IsAudioDeviceReady"]
486 pub fn is_audio_device_ready() -> bool;
487 /// Set master volume (listener)
488 #[link_name = "SetMasterVolume"]
489 pub fn set_master_volume(volume: c_float);
490 /// Get master volume (listener)
491 #[link_name = "GetMasterVolume"]
492 pub fn get_master_volume() -> c_float;
493}
494
495// Wave/Sound loading/unloading functions
496unsafe extern "C" {
497 /// Load wave data from file
498 #[link_name = "LoadWave"]
499 pub fn load_wave(file_name: *const c_char) -> Wave;
500 /// Load wave from memory buffer, file_type refers to extension: i.e. `.wav`
501 #[link_name = "LoadWaveFromMemory"]
502 pub fn load_wave_from_memory(
503 file_type: *const c_char,
504 file_data: *const c_uchar,
505 data_size: c_int,
506 ) -> Wave;
507 /// Checks if wave data is valid (data loaded and parameters)
508 #[link_name = "IsWaveValid"]
509 pub fn is_wave_valid(wave: Wave) -> bool;
510 /// Load sound from file
511 #[link_name = "LoadSound"]
512 pub fn load_sound(file_name: *const c_char) -> Sound;
513 /// Load sound from wave data
514 #[link_name = "LoadSoundFromWave"]
515 pub fn load_sound_from_wave(wave: Wave) -> Sound;
516 /// Create a new sound that shares the same sample data as the source sound, does not own the sound data
517 #[link_name = "LoadSoundAlias"]
518 pub fn load_sound_alias(source: Sound) -> Sound;
519 /// Checks if sound is valid (data loaded and buffers initialized)
520 #[link_name = "IsSoundValid"]
521 pub fn is_sound_valid(sound: Sound) -> bool;
522 /// Update sound buffer with new data
523 #[link_name = "UpdateSound"]
524 pub fn update_sound(sound: Sound, data: *const c_void, sample_count: c_int);
525 /// Unload wave data
526 #[link_name = "UnloadWave"]
527 pub fn unload_wave(wave: Wave);
528 /// Unload sound
529 #[link_name = "UnloadSound"]
530 pub fn unload_sound(sound: Sound);
531 /// Unload a sound alias (does not deallocate sample data)
532 #[link_name = "UnloadSoundAlias"]
533 pub fn unload_sound_alias(alias: Sound);
534 /// Export wave data to file, returns true on success
535 #[link_name = "ExportWave"]
536 pub fn export_wave(wave: Wave, file_name: *const c_char) -> bool;
537 /// Export wave sample data to code (.h), returns true on success
538 #[link_name = "ExportWaveAsCode"]
539 pub fn export_wave_as_code(wave: Wave, file_name: *const c_char) -> bool;
540}
541
542// Wave/Sound management functions
543unsafe extern "C" {
544 /// Play a sound
545 #[link_name = "PlaySound"]
546 pub fn play_sound(sound: Sound);
547 /// Stop playing a sound
548 #[link_name = "StopSound"]
549 pub fn stop_sound(sound: Sound);
550 /// Pause a sound
551 #[link_name = "PauseSound"]
552 pub fn pause_sound(sound: Sound);
553 /// Resume a paused sound
554 #[link_name = "ResumeSound"]
555 pub fn resume_sound(sound: Sound);
556 /// Check if a sound is currently playing
557 #[link_name = "IsSoundPlaying"]
558 pub fn is_sound_playing(sound: Sound) -> bool;
559 /// Set volume for a sound (1.0 is max level)
560 #[link_name = "SetSoundVolume"]
561 pub fn set_sound_volume(sound: Sound, volume: c_float);
562 /// Set pitch for a sound (1.0 is base level)
563 #[link_name = "SetSoundPitch"]
564 pub fn set_sound_pitch(sound: Sound, pitch: c_float);
565 /// Set pan for a sound (0.5 is center)
566 #[link_name = "SetSoundPan"]
567 pub fn set_sound_pan(sound: Sound, pan: c_float);
568 /// Copy the wave to a new wave
569 #[link_name = "WaveCopy"]
570 pub fn wave_copy(wave: Wave);
571 /// Crop a wave to defined frames range
572 #[link_name = "WaveCrop"]
573 pub fn wave_crop(wave: *mut Wave, init_frame: c_int, final_frame: c_int);
574 /// Convert wave data to desired format
575 #[link_name = "WaveFormat"]
576 pub fn wave_format(wave: *mut Wave, sample_rate: c_int, sample_size: c_int, channels: c_int);
577 /// Load samples data from wave as a 32bit float data array
578 #[link_name = "LoadWaveSamples"]
579 pub fn load_wave_samples(wave: Wave) -> *const c_float;
580 /// Unload samples data loaded with LoadWaveSamples()
581 #[link_name = "UnloadWaveSamples"]
582 pub fn unload_wave_samples(samples: *const c_float);
583}
584
585unsafe extern "C" {
586 /// Load music stream from file
587 #[link_name = "LoadMusicStream"]
588 pub fn load_music_stream(file_name: *const c_char) -> Music;
589 /// Load music stream from file
590 #[link_name = "LoadMusicStreamFromMemory"]
591 pub fn load_music_stream_from_memory(
592 file_type: *const c_char,
593 data: *const c_uchar,
594 data_size: c_int,
595 ) -> Music;
596 /// Checks if a music stream is valid (context and buffers initialized)
597 #[link_name = "IsMusicValid"]
598 pub fn is_music_valid(music: Music) -> bool;
599 /// Unload music stream
600 #[link_name = "UnloadMusicStream"]
601 pub fn unload_music_stream(music: Music);
602 /// Start music playing
603 #[link_name = "PlayMusicStream"]
604 pub fn play_music_stream(music: Music);
605 /// Checks if music is playing
606 #[link_name = "IsMusicStreamPlaying"]
607 pub fn is_music_stream_playing(music: Music) -> bool;
608 /// Updates buffers for music streaming
609 #[link_name = "UpdateMusicStream"]
610 pub fn update_music_stream(music: Music);
611 /// Stop music playing
612 #[link_name = "StopMusicStream"]
613 pub fn stop_music_stream(music: Music);
614 /// Pause music playing
615 #[link_name = "PauseMusicStream"]
616 pub fn pause_music_stream(music: Music);
617 /// Resume playing paused music
618 #[link_name = "ResumeMusicStream"]
619 pub fn resume_music_stream(music: Music);
620 /// Seek music to a position (in seconds)
621 #[link_name = "SeekMusicStream"]
622 pub fn seek_music_stream(music: Music, position: c_float);
623 /// Set volume for music (1.0 is max level)
624 #[link_name = "SetMusicVolume"]
625 pub fn set_music_volume(music: Music, volume: c_float);
626 /// Set pitch for music (1.0 is base level)
627 #[link_name = "SetMusicPitch"]
628 pub fn set_music_pitch(music: Music, pitch: c_float);
629 /// Set pan for music (0.5 is center)
630 #[link_name = "SetMusicPan"]
631 pub fn set_music_pan(music: Music, pan: c_float);
632 /// Get music time length (in seconds)
633 #[link_name = "GetMusicTimeLength"]
634 pub fn get_music_time_length(music: Music) -> c_float;
635 /// Get current music time played (in seconds)
636 #[link_name = "GetMusicTimePlayed"]
637 pub fn get_music_time_played(music: Music) -> c_float;
638}
639
640// AudioStream management functions
641unsafe extern "C" {
642 /// Load audio stream (to stream raw audio pcm data)
643 #[link_name = "LoadAudioStream"]
644 pub fn load_audio_stream(
645 sample_rate: c_uint,
646 sample_size: c_uint,
647 channels: c_uint,
648 ) -> AudioStream;
649 /// Checks if an audio stream is valid (buffers initialized)
650 #[link_name = "IsAudioStreamValid"]
651 pub fn is_audio_stream_valid(stream: AudioStream) -> bool;
652 /// Unload audio stream and free memory
653 #[link_name = "UnloadStreamValid"]
654 pub fn unload_stream_valid(stream: AudioStream);
655 /// Update audio stream buffers with data
656 #[link_name = "UpdateStreamValid"]
657 pub fn update_stream_valid(stream: AudioStream, data: *const c_void, frame_count: c_int);
658 /// Check if any audio stream buffers requires refill
659 #[link_name = "IsAudioStreamProcessed"]
660 pub fn is_audio_stream_processed(stream: AudioStream) -> bool;
661 /// Play audio stream
662 #[link_name = "PlayAudioStream"]
663 pub fn play_audio_stream(stream: AudioStream);
664 /// Pause audio stream
665 #[link_name = "PauseAudioStream"]
666 pub fn pause_audio_stream(stream: AudioStream);
667 /// Resume audio stream
668 #[link_name = "ResumeAudioStream"]
669 pub fn resume_audio_stream(stream: AudioStream);
670 /// Check if audio stream is playing
671 #[link_name = "IsAudioStreamPlaying"]
672 pub fn is_audio_stream_playing(stream: AudioStream) -> bool;
673 /// Stop audio stream
674 #[link_name = "StopAudioStream"]
675 pub fn stop_audio_stream(stream: AudioStream);
676 /// Set volume for audio stream (1.0 is max level)
677 #[link_name = "SetAudioStreamVolume"]
678 pub fn set_audio_stream_volume(stream: AudioStream, volume: c_float);
679 /// Set pitch for audio stream (1.0 is base level)
680 #[link_name = "SetAudioStreamPitch"]
681 pub fn set_audio_stream_pitch(stream: AudioStream, pitch: c_float);
682 /// Set pan for audio stream (0.5 is centered)
683 #[link_name = "SetAudioStreamPan"]
684 pub fn set_audio_stream_pan(stream: AudioStream, pan: c_float);
685 /// Default size for new audio streams
686 #[link_name = "SetAudioStreamBufferSizeDefault"]
687 pub fn set_audio_stream_buffer_size_default(size: c_int);
688 /// Audio thread callback to request new data
689 #[link_name = "SetAudioStreamCallback"]
690 pub fn set_audio_stream_callback(stream: AudioStream, callback: AudioCallback);
691
692 /// Attach audio stream processor to stream, receives the samples as 'float'
693 #[link_name = "AttachAudioStreamProcessor"]
694 pub fn attach_audio_stream_processor(stream: AudioStream, processor: AudioCallback);
695 /// Detach audio stream processor from stream
696 #[link_name = "DetachAudioStreamProcessor"]
697 pub fn detach_audio_stream_processor(stream: AudioStream, processor: AudioCallback);
698 /// Attach audio stream processor to the entire audio pipeline, receives the samples as 'float'
699 #[link_name = "AttachAudioMixedProcessor"]
700 pub fn attach_audio_mixed_processor(processor: AudioCallback);
701 /// Detach audio stream processor from the entire audio pipeline
702 #[link_name = "DetachAudioMixedProcessor"]
703 pub fn detach_audio_mixed_processor(processor: AudioCallback);
704}