1use 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::{
91 ConfigFlag, GamepadAxis, GamepadButton, Gesture, KeyboardKey, MouseButton, MouseCursor,
92 TextureFilter, TextureWrap,
93 },
94 math::Rectangle,
95 math::Vector2,
96 texture::{Image, RenderTexture, RenderTexture2D, Texture},
97};
98
99extern "C" {
101 #[link_name = "InitWindow"]
103 pub fn init_window(width: c_int, height: c_int, title: *const c_char);
104 #[link_name = "CloseWindow"]
106 pub fn close_window();
107 #[link_name = "WindowShouldClose"]
109 pub fn window_should_close() -> bool;
110 #[link_name = "IsWindowReady"]
112 pub fn is_window_ready() -> bool;
113 #[link_name = "IsWindowFullscreen"]
115 pub fn is_window_fullscreen() -> bool;
116 #[link_name = "IsWindowHidden"]
118 pub fn is_window_hidden() -> bool;
119 #[link_name = "IsWindowMinimized"]
121 pub fn is_window_minimized() -> bool;
122 #[link_name = "IsWindowMaximized"]
124 pub fn is_window_maximized() -> bool;
125 #[link_name = "IsWindowFocused"]
127 pub fn is_window_focused() -> bool;
128 #[link_name = "IsWindowResized"]
130 pub fn is_window_resized() -> bool;
131 #[link_name = "IsWindowState"]
144 pub fn is_window_state(flags: ConfigFlag) -> bool;
145 #[link_name = "SetWindowState"]
158 pub fn set_window_state(flags: ConfigFlag);
159 #[link_name = "ClearWindowState"]
172 pub fn clear_window_state(flags: ConfigFlag);
173 #[link_name = "ToggleFullscreen"]
175 pub fn toggle_fullscreen();
176 #[link_name = "ToggleBorderlessWindowed"]
178 pub fn toggle_borderless_windowed();
179 #[link_name = "MaximizeWindow"]
181 pub fn maximize_window();
182 #[link_name = "MinimizeWindow"]
184 pub fn minimize_window();
185 #[link_name = "RestoreWindow"]
187 pub fn restore_window();
188 #[link_name = "SetWindowIcon"]
190 pub fn set_window_icon(image: Image);
191 #[link_name = "SetWindowIcons"]
193 pub fn set_window_icons(images: *const Image);
194 #[link_name = "SetWindowTitle"]
196 pub fn set_window_title(images: *const c_char);
197 #[link_name = "SetWindowPosition"]
199 pub fn set_window_position(x: c_int, y: c_int);
200 #[link_name = "SetWindowMonitor"]
202 pub fn set_window_monitor(monitor: c_int);
203 #[link_name = "SetWindowMinSize"]
205 pub fn set_window_min_size(width: c_int, height: c_int);
206 #[link_name = "SetWindowMaxSize"]
208 pub fn set_window_max_size(width: c_int, height: c_int);
209 #[link_name = "SetWindowSize"]
211 pub fn set_window_size(width: c_int, height: c_int);
212 #[link_name = "SetWindowOpacity"]
214 pub fn set_window_opacity(opacity: c_float);
215 #[link_name = "SetWindowFocused"]
217 pub fn set_window_focused();
218 #[link_name = "GetScreenWidth"]
220 pub fn get_screen_width() -> c_int;
221 #[link_name = "GetScreenHeight"]
223 pub fn get_screen_height() -> c_int;
224 #[link_name = "GetRenderWidth"]
226 pub fn get_render_width() -> c_int;
227 #[link_name = "GetRenderHeight"]
229 pub fn get_render_height() -> c_int;
230 #[link_name = "GetMonitorCount"]
232 pub fn get_monitor_count() -> c_int;
233 #[link_name = "GetCurrentMonitor"]
235 pub fn get_current_monitor() -> c_int;
236 #[link_name = "GetMonitorPosition"]
238 pub fn get_monitor_position(monitor: c_int) -> Vector2;
239 #[link_name = "GetMonitorWidth"]
241 pub fn get_monitor_width(monitor: c_int) -> c_int;
242 #[link_name = "GetMonitorHeight"]
244 pub fn get_monitor_height(monitor: c_int) -> c_int;
245 #[link_name = "GetMonitorPhysicalWidth"]
247 pub fn get_monitor_physical_width(monitor: c_int) -> c_int;
248 #[link_name = "GetMonitorPhysicalHeight"]
250 pub fn get_monitor_physical_height(monitor: c_int) -> c_int;
251 #[link_name = "GetMonitorRefreshRate"]
253 pub fn get_monitor_refresh_rate(monitor: c_int) -> c_int;
254 #[link_name = "GetWindowPosition"]
256 pub fn get_window_position() -> Vector2;
257 #[link_name = "GetWindowScaleDPI"]
259 pub fn get_window_scale_dpi() -> Vector2;
260 #[link_name = "GetMonitorName"]
262 pub fn get_monitor_name(monitor: c_int) -> *const c_char;
263 #[link_name = "SetClipboardText"]
265 pub fn set_clipboard_text(text: *const c_char);
266 #[link_name = "GetClipboardText"]
268 pub fn get_clipboard_text() -> *const c_char;
269 #[link_name = "GetClipboardImage"]
271 pub fn get_clipboard_image() -> Image;
272 #[link_name = "EnableEventWaiting"]
274 pub fn enable_event_waiting();
275 #[link_name = "DisableEventWaiting"]
277 pub fn disable_event_waiting();
278}
279
280extern "C" {
282 #[link_name = "ShowCursor"]
284 pub fn show_cursor();
285 #[link_name = "HideCursor"]
287 pub fn hide_cursor();
288 #[link_name = "IsCursorHidden"]
290 pub fn is_cursor_hidden();
291 #[link_name = "EnableCursor"]
293 pub fn enable_cursor();
294 #[link_name = "DisableCursor"]
296 pub fn disable_cursor();
297 #[link_name = "IsCursorOnScreen"]
299 pub fn is_cursor_on_screen();
300}
301
302extern "C" {
304 #[link_name = "ClearBackground"]
306 pub fn clear_background(color: Color);
307 #[link_name = "BeginDrawing"]
309 pub fn begin_drawing();
310 #[link_name = "EndDrawing"]
312 pub fn end_drawing();
313 #[link_name = "BeginTextureMode"]
315 pub fn begin_texture_mode(render_texture: RenderTexture2D);
316 #[link_name = "EndTextureMode"]
318 pub fn end_texture_mode();
319}
320
321extern "C" {
324 #[link_name = "LoadTexture"]
326 pub fn load_texture(path: *const c_char) -> Texture;
327 #[link_name = "LoadTextureFromImage"]
329 pub fn load_texture_from_image(image: Image) -> Texture;
330 #[link_name = "LoadRenderTexture"]
332 pub fn load_render_texture(width: c_int, height: c_int) -> RenderTexture;
333 #[link_name = "IsTextureValid"]
335 pub fn is_texture_valid(texture: Texture) -> bool;
336 #[link_name = "UnloadTexture"]
338 pub fn unload_texture(texture: Texture);
339 #[link_name = "IsRenderTextureValid"]
341 pub fn is_render_texture_valid(target: RenderTexture) -> bool;
342 #[link_name = "UnloadRenderTexture"]
344 pub fn unload_render_texture(render_texture: RenderTexture);
345 #[link_name = "UpdateTexture"]
347 pub fn update_texture(texture: Texture, pixels: *const c_void);
348 #[link_name = "UpdateTextureRec"]
350 pub fn update_texture_rec(texture: Texture, rec: Rectangle, pixels: *const c_void);
351}
352
353extern "C" {
355 #[link_name = "GenTextureMipmaps"]
357 pub fn gen_texture_mipmaps(texture: *mut Texture);
358 #[link_name = "SetTextureFilter"]
360 pub fn set_texture_filter(texture: Texture, filter: TextureFilter);
361 #[link_name = "SetTextureWrap"]
363 pub fn set_texture_wrap(texture: Texture, wrap: TextureWrap);
364}
365
366extern "C" {
368 #[link_name = "DrawTexture"]
370 pub fn draw_texture(texture: Texture, pos_x: c_int, pos_y: c_int, tint: Color);
371 #[link_name = "DrawTextureV"]
373 pub fn draw_texture_v(texture: Texture, pos: Vector2, tint: Color);
374 #[link_name = "DrawTextureEx"]
376 pub fn draw_texture_ex(
377 texture: Texture,
378 pos: Vector2,
379 rotation: c_float,
380 scale: c_float,
381 tint: Color,
382 );
383 #[link_name = "DrawTextureRec"]
385 pub fn draw_texture_rec(texture: Texture, source: Rectangle, position: Vector2, tint: Color);
386 #[link_name = "DrawTexturePro"]
388 pub fn draw_texture_pro(
389 texture: Texture,
390 source: Rectangle,
391 dest: Rectangle,
392 origin: Vector2,
393 rotation: c_float,
394 tint: Color,
395 );
396 }
398
399extern "C" {
401 #[link_name = "DrawFPS"]
403 pub fn draw_fps(pos_x: c_int, pos_y: c_int);
404 #[link_name = "DrawText"]
406 pub fn draw_text(
407 text: *const c_char,
408 pos_x: c_int,
409 pos_y: c_int,
410 font_size: c_int,
411 color: Color,
412 );
413}
414
415extern "C" {
417 #[link_name = "MeasureText"]
419 pub fn measure_text(text: *const c_char, font_size: c_int);
420}
421
422extern "C" {
424 #[link_name = "DrawCircleV"]
426 pub fn draw_circle_v(center: Vector2, radius: c_float, color: Color);
427 #[link_name = "DrawRectangleRec"]
429 pub fn draw_rectangle_rec(rec: Rectangle, color: Color);
430 #[link_name = "DrawRectangleLines"]
432 pub fn draw_rectangle_lines(
433 pos_x: c_int,
434 pos_y: c_int,
435 width: c_int,
436 height: c_int,
437 color: Color,
438 );
439}
440
441extern "C" {
443 #[link_name = "IsKeyPressed"]
445 pub fn is_key_pressed(key: KeyboardKey) -> bool;
446 #[link_name = "IsKeyPressedRepeat"]
448 pub fn is_key_pressed_repeat(key: KeyboardKey) -> bool;
449 #[link_name = "IsKeyDown"]
451 pub fn is_key_down(key: KeyboardKey) -> bool;
452 #[link_name = "IsKeyReleased"]
454 pub fn is_key_released(key: KeyboardKey) -> bool;
455 #[link_name = "IsKeyUp"]
457 pub fn is_key_up(key: KeyboardKey) -> bool;
458 #[link_name = "GetKeyPressed"]
460 pub fn get_key_pressed() -> c_int;
461 #[link_name = "GetCharPressed"]
463 pub fn get_char_pressed() -> c_int;
464 #[link_name = "SetExitKey"]
466 pub fn set_exit_key(key: c_int);
467}
468
469extern "C" {
471 #[link_name = "IsGamepadAvailable"]
473 pub fn is_gamepad_available(gamepad: c_int) -> bool;
474 #[link_name = "GetGamepadName"]
476 pub fn get_gamepad_name(gamepad: c_int) -> *const c_char;
477 #[link_name = "IsGamepadButtonPressed"]
479 pub fn is_gamepad_button_pressed(gamepad: c_int, button: GamepadButton) -> bool;
480 #[link_name = "IsGamepadButtonDown"]
482 pub fn is_gamepad_button_down(gamepad: c_int, button: GamepadButton) -> bool;
483 #[link_name = "IsGamepadButtonReleased"]
485 pub fn is_gamepad_button_released(gamepad: c_int, button: GamepadButton) -> bool;
486 #[link_name = "IsGamepadButtonUp"]
488 pub fn is_gamepad_button_up(gamepad: c_int, button: GamepadButton) -> bool;
489 #[link_name = "GetGamepadButtonPressed"]
491 pub fn get_gamepad_button_pressed(gamepad: c_int) -> GamepadButton;
492 #[link_name = "GetGamepadAxisCount"]
494 pub fn get_gamepad_axis_count(gamepad: c_int) -> c_int;
495 #[link_name = "GetGamepadAxisMovement"]
497 pub fn get_gamepad_axis_movement(gamepad: c_int, axis: GamepadAxis) -> c_float;
498 #[link_name = "SetGamepadVibration"]
500 pub fn set_gamepad_vibration(
501 gamepad: c_int,
502 left_motor: c_float,
503 right_motor: c_float,
504 duration: c_float,
505 );
506}
507
508extern "C" {
510 #[link_name = "IsMouseButtonPressed"]
512 pub fn is_mouse_button_pressed(button: MouseButton) -> bool;
513 #[link_name = "IsMouseButtonDown"]
515 pub fn is_mouse_button_down(button: MouseButton) -> bool;
516 #[link_name = "IsMouseButtonReleased"]
518 pub fn is_mouse_button_released(button: MouseButton) -> bool;
519 #[link_name = "IsMouseButtonUp"]
521 pub fn is_mouse_button_up(button: MouseButton) -> bool;
522 #[link_name = "GetMouseX"]
524 pub fn get_mouse_x() -> c_int;
525 #[link_name = "GetMouseY"]
527 pub fn get_mouse_y() -> c_int;
528 #[link_name = "GetMousePosition"]
530 pub fn get_mouse_position() -> Vector2;
531 #[link_name = "GetMouseDelta"]
533 pub fn get_mouse_delta() -> Vector2;
534 #[link_name = "SetMousePosition"]
536 pub fn set_mouse_position(x: c_int, y: c_int);
537 #[link_name = "SetMouseOffset"]
539 pub fn set_mouse_offset(offset_x: c_int, offset_y: c_int);
540 #[link_name = "SetMouseScale"]
542 pub fn set_mouse_scale(scale_x: c_int, scale_y: c_int);
543 #[link_name = "GetMouseWheelMove"]
545 pub fn get_mouse_wheel_move() -> c_float;
546 #[link_name = "GetMouseWheelMoveV"]
548 pub fn get_mouse_wheel_move_v() -> Vector2;
549 #[link_name = "SetMouseCursor"]
551 pub fn set_mouse_cursor(cursor: MouseCursor);
552}
553
554extern "C" {
556 #[link_name = "GetTouchX"]
558 pub fn get_touch_x() -> c_int;
559 #[link_name = "GetTouchY"]
561 pub fn get_touch_y() -> c_int;
562 #[link_name = "GetTouchPosition"]
564 pub fn get_touch_position(index: c_int) -> Vector2;
565 #[link_name = "GetTouchPointId"]
567 pub fn get_touch_point_id(index: c_int) -> c_int;
568 #[link_name = "GetTouchPointCount"]
570 pub fn get_touch_point_count() -> c_int;
571}
572extern "C" {
574 #[link_name = "SetGesturesEnabled"]
576 pub fn set_gestures_enabled(flags: Gesture);
577 #[link_name = "IsGestureDetected"]
579 pub fn is_gesture_detected(gesture: Gesture);
580 #[link_name = "GetGestureDetected"]
582 pub fn get_gesture_detected() -> Gesture;
583 #[link_name = "GetGestureHoldDuration"]
585 pub fn get_gesture_hold_duration() -> c_int;
586 #[link_name = "GetGestureDragVector"]
588 pub fn get_gesture_drag_vector() -> Vector2;
589 #[link_name = "GetGestureDragAngle"]
591 pub fn get_gesture_drag_angle() -> c_float;
592 #[link_name = "GetGesturePinchVector"]
594 pub fn get_gesture_pinch_vector() -> Vector2;
595 #[link_name = "GetGesturePinchAngle"]
597 pub fn get_gesture_pinch_angle() -> c_float;
598}
599
600extern "C" {
602 #[link_name = "SetTargetFPS"]
604 pub fn set_target_fps(fps: c_int);
605 #[link_name = "GetFrameTime"]
607 pub fn get_frame_time() -> c_float;
608 #[link_name = "GetTime"]
610 pub fn get_time() -> c_double;
611 #[link_name = "GetFPS"]
613 pub fn get_fps() -> c_int;
614}
615
616extern "C" {
618 #[link_name = "SetConfigFlags"]
631 pub fn set_config_flags(flags: ConfigFlag);
632}
633
634extern "C" {
636 #[link_name = "InitAudioDevice"]
638 pub fn init_audio_device();
639 #[link_name = "CloseAudioDevice"]
641 pub fn close_audio_device();
642 #[link_name = "IsAudioDeviceReady"]
644 pub fn is_audio_device_ready() -> bool;
645 #[link_name = "SetMasterVolume"]
647 pub fn set_master_volume(volume: c_float);
648 #[link_name = "GetMasterVolume"]
650 pub fn get_master_volume() -> c_float;
651}
652
653extern "C" {
655 #[link_name = "LoadWave"]
657 pub fn load_wave(file_name: *const c_char) -> Wave;
658 #[link_name = "LoadWaveFromMemory"]
660 pub fn load_wave_from_memory(
661 file_type: *const c_char,
662 file_data: *const c_uchar,
663 data_size: c_int,
664 ) -> Wave;
665 #[link_name = "IsWaveValid"]
667 pub fn is_wave_valid(wave: Wave) -> bool;
668 #[link_name = "LoadSound"]
670 pub fn load_sound(file_name: *const c_char) -> Sound;
671 #[link_name = "LoadSoundFromWave"]
673 pub fn load_sound_from_wave(wave: Wave) -> Sound;
674 #[link_name = "LoadSoundAlias"]
676 pub fn load_sound_alias(source: Sound) -> Sound;
677 #[link_name = "IsSoundValid"]
679 pub fn is_sound_valid(sound: Sound) -> bool;
680 #[link_name = "UpdateSound"]
682 pub fn update_sound(sound: Sound, data: *const c_void, sample_count: c_int);
683 #[link_name = "UnloadWave"]
685 pub fn unload_wave(wave: Wave);
686 #[link_name = "UnloadSound"]
688 pub fn unload_sound(sound: Sound);
689 #[link_name = "UnloadSoundAlias"]
691 pub fn unload_sound_alias(alias: Sound);
692 #[link_name = "ExportWave"]
694 pub fn export_wave(wave: Wave, file_name: *const c_char) -> bool;
695 #[link_name = "ExportWaveAsCode"]
697 pub fn export_wave_as_code(wave: Wave, file_name: *const c_char) -> bool;
698}
699
700extern "C" {
702 #[link_name = "PlaySound"]
704 pub fn play_sound(sound: Sound);
705 #[link_name = "StopSound"]
707 pub fn stop_sound(sound: Sound);
708 #[link_name = "PauseSound"]
710 pub fn pause_sound(sound: Sound);
711 #[link_name = "ResumeSound"]
713 pub fn resume_sound(sound: Sound);
714 #[link_name = "IsSoundPlaying"]
716 pub fn is_sound_playing(sound: Sound) -> bool;
717 #[link_name = "SetSoundVolume"]
719 pub fn set_sound_volume(sound: Sound, volume: c_float);
720 #[link_name = "SetSoundPitch"]
722 pub fn set_sound_pitch(sound: Sound, pitch: c_float);
723 #[link_name = "SetSoundPan"]
725 pub fn set_sound_pan(sound: Sound, pan: c_float);
726 #[link_name = "WaveCopy"]
728 pub fn wave_copy(wave: Wave);
729 #[link_name = "WaveCrop"]
731 pub fn wave_crop(wave: *mut Wave, init_frame: c_int, final_frame: c_int);
732 #[link_name = "WaveFormat"]
734 pub fn wave_format(wave: *mut Wave, sample_rate: c_int, sample_size: c_int, channels: c_int);
735 #[link_name = "LoadWaveSamples"]
737 pub fn load_wave_samples(wave: Wave) -> *const c_float;
738 #[link_name = "UnloadWaveSamples"]
740 pub fn unload_wave_samples(samples: *const c_float);
741}
742
743extern "C" {
744 #[link_name = "LoadMusicStream"]
746 pub fn load_music_stream(file_name: *const c_char) -> Music;
747 #[link_name = "LoadMusicStreamFromMemory"]
749 pub fn load_music_stream_from_memory(
750 file_type: *const c_char,
751 data: *const c_uchar,
752 data_size: c_int,
753 ) -> Music;
754 #[link_name = "IsMusicValid"]
756 pub fn is_music_valid(music: Music) -> bool;
757 #[link_name = "UnloadMusicStream"]
759 pub fn unload_music_stream(music: Music);
760 #[link_name = "PlayMusicStream"]
762 pub fn play_music_stream(music: Music);
763 #[link_name = "IsMusicStreamPlaying"]
765 pub fn is_music_stream_playing(music: Music) -> bool;
766 #[link_name = "UpdateMusicStream"]
768 pub fn update_music_stream(music: Music);
769 #[link_name = "StopMusicStream"]
771 pub fn stop_music_stream(music: Music);
772 #[link_name = "PauseMusicStream"]
774 pub fn pause_music_stream(music: Music);
775 #[link_name = "ResumeMusicStream"]
777 pub fn resume_music_stream(music: Music);
778 #[link_name = "SeekMusicStream"]
780 pub fn seek_music_stream(music: Music, position: c_float);
781 #[link_name = "SetMusicVolume"]
783 pub fn set_music_volume(music: Music, volume: c_float);
784 #[link_name = "SetMusicPitch"]
786 pub fn set_music_pitch(music: Music, pitch: c_float);
787 #[link_name = "SetMusicPan"]
789 pub fn set_music_pan(music: Music, pan: c_float);
790 #[link_name = "GetMusicTimeLength"]
792 pub fn get_music_time_length(music: Music) -> c_float;
793 #[link_name = "GetMusicTimePlayed"]
795 pub fn get_music_time_played(music: Music) -> c_float;
796}
797
798extern "C" {
800 #[link_name = "LoadAudioStream"]
802 pub fn load_audio_stream(
803 sample_rate: c_uint,
804 sample_size: c_uint,
805 channels: c_uint,
806 ) -> AudioStream;
807 #[link_name = "IsAudioStreamValid"]
809 pub fn is_audio_stream_valid(stream: AudioStream) -> bool;
810 #[link_name = "UnloadStreamValid"]
812 pub fn unload_stream_valid(stream: AudioStream);
813 #[link_name = "UpdateStreamValid"]
815 pub fn update_stream_valid(stream: AudioStream, data: *const c_void, frame_count: c_int);
816 #[link_name = "IsAudioStreamProcessed"]
818 pub fn is_audio_stream_processed(stream: AudioStream) -> bool;
819 #[link_name = "PlayAudioStream"]
821 pub fn play_audio_stream(stream: AudioStream);
822 #[link_name = "PauseAudioStream"]
824 pub fn pause_audio_stream(stream: AudioStream);
825 #[link_name = "ResumeAudioStream"]
827 pub fn resume_audio_stream(stream: AudioStream);
828 #[link_name = "IsAudioStreamPlaying"]
830 pub fn is_audio_stream_playing(stream: AudioStream) -> bool;
831 #[link_name = "StopAudioStream"]
833 pub fn stop_audio_stream(stream: AudioStream);
834 #[link_name = "SetAudioStreamVolume"]
836 pub fn set_audio_stream_volume(stream: AudioStream, volume: c_float);
837 #[link_name = "SetAudioStreamPitch"]
839 pub fn set_audio_stream_pitch(stream: AudioStream, pitch: c_float);
840 #[link_name = "SetAudioStreamPan"]
842 pub fn set_audio_stream_pan(stream: AudioStream, pan: c_float);
843 #[link_name = "SetAudioStreamBufferSizeDefault"]
845 pub fn set_audio_stream_buffer_size_default(size: c_int);
846 #[link_name = "SetAudioStreamCallback"]
848 pub fn set_audio_stream_callback(stream: AudioStream, callback: AudioCallback);
849
850 #[link_name = "AttachAudioStreamProcessor"]
852 pub fn attach_audio_stream_processor(stream: AudioStream, processor: AudioCallback);
853 #[link_name = "DetachAudioStreamProcessor"]
855 pub fn detach_audio_stream_processor(stream: AudioStream, processor: AudioCallback);
856 #[link_name = "AttachAudioMixedProcessor"]
858 pub fn attach_audio_mixed_processor(processor: AudioCallback);
859 #[link_name = "DetachAudioMixedProcessor"]
861 pub fn detach_audio_mixed_processor(processor: AudioCallback);
862}