pub struct Raylib(/* private fields */);
Expand description
Main raylib handle
Implementations§
Source§impl Raylib
impl Raylib
Sourcepub fn init_window(width: u32, height: u32, title: &str) -> Option<Self>
pub fn init_window(width: u32, height: u32, title: &str) -> Option<Self>
Initialize window and OpenGL context
Sourcepub fn init_window_ex(
width: u32,
height: u32,
title: &str,
flags: ConfigFlags,
) -> Option<Self>
pub fn init_window_ex( width: u32, height: u32, title: &str, flags: ConfigFlags, ) -> Option<Self>
Initialize window and OpenGL context with config flags
Sourcepub fn window_should_close(&self) -> bool
pub fn window_should_close(&self) -> bool
Check if Escape key or Close icon is pressed
Sourcepub fn close_window(self)
pub fn close_window(self)
Close window and unload OpenGL context
Sourcepub fn is_window_fullscreen(&self) -> bool
pub fn is_window_fullscreen(&self) -> bool
Check if window is currently fullscreen
Check if window is currently hidden (only PLATFORM_DESKTOP)
Sourcepub fn is_window_minimized(&self) -> bool
pub fn is_window_minimized(&self) -> bool
Check if window is currently minimized (only PLATFORM_DESKTOP)
Sourcepub fn is_window_maximized(&self) -> bool
pub fn is_window_maximized(&self) -> bool
Check if window is currently maximized (only PLATFORM_DESKTOP)
Sourcepub fn is_window_focused(&self) -> bool
pub fn is_window_focused(&self) -> bool
Check if window is currently focused (only PLATFORM_DESKTOP)
Sourcepub fn is_window_resized(&self) -> bool
pub fn is_window_resized(&self) -> bool
Check if window has been resized last frame
Sourcepub fn is_window_state(&self, flag: ConfigFlags) -> bool
pub fn is_window_state(&self, flag: ConfigFlags) -> bool
Check if one specific window flag is enabled
Sourcepub fn set_window_state(&mut self, flags: ConfigFlags)
pub fn set_window_state(&mut self, flags: ConfigFlags)
Set window configuration state using flags (only PLATFORM_DESKTOP)
Sourcepub fn clear_window_state(&mut self, flags: ConfigFlags)
pub fn clear_window_state(&mut self, flags: ConfigFlags)
Clear window configuration state flags
Sourcepub fn toggle_fullscreen(&mut self)
pub fn toggle_fullscreen(&mut self)
Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
Sourcepub fn maximize_window(&mut self)
pub fn maximize_window(&mut self)
Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
Sourcepub fn minimize_window(&mut self)
pub fn minimize_window(&mut self)
Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
Sourcepub fn restore_window(&mut self)
pub fn restore_window(&mut self)
Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
Sourcepub fn set_window_icon(&mut self, image: &Image)
pub fn set_window_icon(&mut self, image: &Image)
Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
Sourcepub fn set_window_icons(&mut self, images: &[&Image])
pub fn set_window_icons(&mut self, images: &[&Image])
Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
Sourcepub fn set_window_title(&mut self, title: &str)
pub fn set_window_title(&mut self, title: &str)
Set title for window (only PLATFORM_DESKTOP)
Sourcepub fn set_window_position(&mut self, x: i32, y: i32)
pub fn set_window_position(&mut self, x: i32, y: i32)
Set window position on screen (only PLATFORM_DESKTOP)
Sourcepub fn set_window_monitor(&mut self, monitor: u32)
pub fn set_window_monitor(&mut self, monitor: u32)
Set monitor for the current window (fullscreen mode)
Sourcepub fn set_window_min_size(&mut self, width: u32, height: u32)
pub fn set_window_min_size(&mut self, width: u32, height: u32)
Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
Sourcepub fn set_window_size(&mut self, width: u32, height: u32)
pub fn set_window_size(&mut self, width: u32, height: u32)
Set window dimensions
Sourcepub fn set_window_opacity(&mut self, opacity: f32)
pub fn set_window_opacity(&mut self, opacity: f32)
Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
Sourcepub fn get_window_handle(&self) -> *mut c_void
pub fn get_window_handle(&self) -> *mut c_void
Get native window handle
Sourcepub fn get_screen_width(&self) -> u32
pub fn get_screen_width(&self) -> u32
Get current screen width
Sourcepub fn get_screen_height(&self) -> u32
pub fn get_screen_height(&self) -> u32
Get current screen height
Sourcepub fn get_render_width(&self) -> u32
pub fn get_render_width(&self) -> u32
Get current render width (it considers HiDPI)
Sourcepub fn get_render_height(&self) -> u32
pub fn get_render_height(&self) -> u32
Get current render height (it considers HiDPI)
Sourcepub fn get_monitor_count(&self) -> u32
pub fn get_monitor_count(&self) -> u32
Get number of connected monitors
Sourcepub fn get_current_monitor(&self) -> u32
pub fn get_current_monitor(&self) -> u32
Get current connected monitor
Sourcepub fn get_monitor_position(&self, monitor: u32) -> Vector2
pub fn get_monitor_position(&self, monitor: u32) -> Vector2
Get specified monitor position
Sourcepub fn get_monitor_width(&self, monitor: u32) -> u32
pub fn get_monitor_width(&self, monitor: u32) -> u32
Get specified monitor width (current video mode used by monitor)
Sourcepub fn get_monitor_height(&self, monitor: u32) -> u32
pub fn get_monitor_height(&self, monitor: u32) -> u32
Get specified monitor height (current video mode used by monitor)
Sourcepub fn get_monitor_physical_width(&self, monitor: u32) -> u32
pub fn get_monitor_physical_width(&self, monitor: u32) -> u32
Get specified monitor physical width in millimetres
Sourcepub fn get_monitor_physical_height(&self, monitor: u32) -> u32
pub fn get_monitor_physical_height(&self, monitor: u32) -> u32
Get specified monitor physical height in millimetres
Sourcepub fn get_monitor_refresh_rate(&self, monitor: u32) -> u32
pub fn get_monitor_refresh_rate(&self, monitor: u32) -> u32
Get specified monitor refresh rate
Sourcepub fn get_window_position(&self) -> Vector2
pub fn get_window_position(&self) -> Vector2
Get window position XY on monitor
Sourcepub fn get_window_scale_dpi(&self) -> Vector2
pub fn get_window_scale_dpi(&self) -> Vector2
Get window scale DPI factor
Sourcepub fn get_monitor_name(&self, monitor: u32) -> String
pub fn get_monitor_name(&self, monitor: u32) -> String
Get the human-readable, UTF-8 encoded name of the primary monitor
Sourcepub fn set_clipboard_text(&mut self, text: &str)
pub fn set_clipboard_text(&mut self, text: &str)
Set clipboard text content
Sourcepub fn get_clipboard_text(&self) -> String
pub fn get_clipboard_text(&self) -> String
Get clipboard text content
Sourcepub fn enable_event_waiting(&mut self)
pub fn enable_event_waiting(&mut self)
Enable waiting for events on EndDrawing(), no automatic event polling
Sourcepub fn disable_event_waiting(&mut self)
pub fn disable_event_waiting(&mut self)
Disable waiting for events on EndDrawing(), automatic events polling
Sourcepub fn swap_screen_buffer(&mut self)
pub fn swap_screen_buffer(&mut self)
Swap back buffer with front buffer (screen drawing) NOTE: Those functions are intended for advance users that want full control over the frame processing
Sourcepub fn poll_input_events(&mut self)
pub fn poll_input_events(&mut self)
Register all input events NOTE: Those functions are intended for advance users that want full control over the frame processing
Sourcepub fn wait_time(&mut self, duration: Duration)
pub fn wait_time(&mut self, duration: Duration)
Wait for some time (halt program execution) NOTE: Those functions are intended for advance users that want full control over the frame processing
Sourcepub fn show_cursor(&mut self)
pub fn show_cursor(&mut self)
Shows cursor
Sourcepub fn hide_cursor(&mut self)
pub fn hide_cursor(&mut self)
Hides cursor
Check if cursor is not visible
Sourcepub fn enable_cursor(&mut self)
pub fn enable_cursor(&mut self)
Enables cursor (unlock cursor)
Sourcepub fn disable_cursor(&mut self)
pub fn disable_cursor(&mut self)
Disables cursor (lock cursor)
Sourcepub fn is_cursor_on_screen(&self) -> bool
pub fn is_cursor_on_screen(&self) -> bool
Check if cursor is on the screen
Sourcepub fn set_target_fps(&mut self, fps: u32)
pub fn set_target_fps(&mut self, fps: u32)
Set target FPS (maximum)
Sourcepub fn get_frame_time(&self) -> Duration
pub fn get_frame_time(&self) -> Duration
Get time for last frame drawn (delta time)
Sourcepub fn get_random_value(&self, min: i32, max: i32) -> i32
pub fn get_random_value(&self, min: i32, max: i32) -> i32
Get a random value between min and max (both included)
Sourcepub fn set_random_seed(&mut self, seed: u32)
pub fn set_random_seed(&mut self, seed: u32)
Set the seed for the random number generator
Sourcepub fn take_screenshot(&mut self, file_name: &str)
pub fn take_screenshot(&mut self, file_name: &str)
Takes a screenshot of current screen (file_name extension defines format)
Sourcepub fn is_file_dropped(&self) -> bool
pub fn is_file_dropped(&self) -> bool
Check if a file has been dropped into window
Sourcepub fn get_dropped_files(&self) -> Vec<String>
pub fn get_dropped_files(&self) -> Vec<String>
Load dropped filepaths
Sourcepub fn is_key_pressed(&self, key: KeyboardKey) -> bool
pub fn is_key_pressed(&self, key: KeyboardKey) -> bool
Check if a key has been pressed once
Sourcepub fn is_key_down(&self, key: KeyboardKey) -> bool
pub fn is_key_down(&self, key: KeyboardKey) -> bool
Check if a key is being pressed
Sourcepub fn is_key_released(&self, key: KeyboardKey) -> bool
pub fn is_key_released(&self, key: KeyboardKey) -> bool
Check if a key has been released once
Sourcepub fn is_key_up(&self, key: KeyboardKey) -> bool
pub fn is_key_up(&self, key: KeyboardKey) -> bool
Check if a key is NOT being pressed
Sourcepub fn set_exit_key(&mut self, key: KeyboardKey)
pub fn set_exit_key(&mut self, key: KeyboardKey)
Set a custom key to exit program (default is ESC)
Sourcepub fn get_key_pressed(&self) -> KeyboardKey
pub fn get_key_pressed(&self) -> KeyboardKey
Get key pressed (keycode), call it multiple times for keys queued, returns KeyboardKey::Null
when the queue is empty
Sourcepub fn get_char_pressed(&self) -> Option<char>
pub fn get_char_pressed(&self) -> Option<char>
Get char pressed (unicode), call it multiple times for chars queued, returns None
when the queue is empty
Sourcepub fn is_gamepad_available(&self, gamepad: u32) -> bool
pub fn is_gamepad_available(&self, gamepad: u32) -> bool
Check if a gamepad is available
Sourcepub fn get_gamepad_name(&self, gamepad: u32) -> String
pub fn get_gamepad_name(&self, gamepad: u32) -> String
Get gamepad internal name id
Check if a gamepad button has been pressed once
Check if a gamepad button is being pressed
Check if a gamepad button has been released once
Check if a gamepad button is NOT being pressed
Get the last gamepad button pressed
Sourcepub fn get_gamepad_axis_count(&self, gamepad: u32) -> u32
pub fn get_gamepad_axis_count(&self, gamepad: u32) -> u32
Get gamepad axis count for a gamepad
Sourcepub fn get_gamepad_axis_movement(&self, gamepad: u32, axis: GamepadAxis) -> f32
pub fn get_gamepad_axis_movement(&self, gamepad: u32, axis: GamepadAxis) -> f32
Get axis movement value for a gamepad axis
Sourcepub fn set_gamepad_mappings(&mut self, mappings: &str) -> i32
pub fn set_gamepad_mappings(&mut self, mappings: &str) -> i32
Set internal gamepad mappings (SDL_GameControllerDB)
Check if a mouse button has been pressed once
Check if a mouse button is being pressed
Check if a mouse button has been released once
Check if a mouse button is NOT being pressed
Sourcepub fn get_mouse_x(&self) -> i32
pub fn get_mouse_x(&self) -> i32
Get mouse position X
Sourcepub fn get_mouse_y(&self) -> i32
pub fn get_mouse_y(&self) -> i32
Get mouse position Y
Sourcepub fn get_mouse_position(&self) -> Vector2
pub fn get_mouse_position(&self) -> Vector2
Get mouse position XY
Sourcepub fn get_mouse_delta(&self) -> Vector2
pub fn get_mouse_delta(&self) -> Vector2
Get mouse delta between frames
Sourcepub fn set_mouse_position(&mut self, x: i32, y: i32)
pub fn set_mouse_position(&mut self, x: i32, y: i32)
Set mouse position XY
Sourcepub fn set_mouse_offset(&mut self, offset_x: i32, offset_y: i32)
pub fn set_mouse_offset(&mut self, offset_x: i32, offset_y: i32)
Set mouse offset
Sourcepub fn set_mouse_scale(&mut self, scale_x: f32, scale_y: f32)
pub fn set_mouse_scale(&mut self, scale_x: f32, scale_y: f32)
Set mouse scaling
Sourcepub fn get_mouse_wheel_move(&self) -> f32
pub fn get_mouse_wheel_move(&self) -> f32
Get mouse wheel movement for X or Y, whichever is larger
Sourcepub fn get_mouse_wheel_move_vec(&self) -> Vector2
pub fn get_mouse_wheel_move_vec(&self) -> Vector2
Get mouse wheel movement for both X and Y
Sourcepub fn set_mouse_cursor(&mut self, cursor: MouseCursor)
pub fn set_mouse_cursor(&mut self, cursor: MouseCursor)
Set mouse cursor
Sourcepub fn get_touch_x(&self) -> i32
pub fn get_touch_x(&self) -> i32
Get touch position X for touch point 0 (relative to screen size)
Sourcepub fn get_touch_y(&self) -> i32
pub fn get_touch_y(&self) -> i32
Get touch position Y for touch point 0 (relative to screen size)
Sourcepub fn get_touch_position(&self, index: u32) -> Vector2
pub fn get_touch_position(&self, index: u32) -> Vector2
Get touch position XY for a touch point index (relative to screen size)
Sourcepub fn get_touch_point_id(&self, index: u32) -> u32
pub fn get_touch_point_id(&self, index: u32) -> u32
Get touch point identifier for given index
Sourcepub fn get_touch_point_count(&self) -> u32
pub fn get_touch_point_count(&self) -> u32
Get number of touch points
Sourcepub fn set_gestures_enabled(&mut self, flags: Gesture)
pub fn set_gestures_enabled(&mut self, flags: Gesture)
Enable a set of gestures using flags
Sourcepub fn is_gesture_detected(&self, gesture: Gesture) -> bool
pub fn is_gesture_detected(&self, gesture: Gesture) -> bool
Check if a gesture have been detected
Sourcepub fn get_gesture_detected(&self) -> Gesture
pub fn get_gesture_detected(&self) -> Gesture
Get latest detected gesture
Sourcepub fn get_gesture_hold_duration(&self) -> Duration
pub fn get_gesture_hold_duration(&self) -> Duration
Get gesture hold time
Sourcepub fn get_gesture_drag_vector(&self) -> Vector2
pub fn get_gesture_drag_vector(&self) -> Vector2
Get gesture drag vector
Sourcepub fn get_gesture_drag_angle(&self) -> f32
pub fn get_gesture_drag_angle(&self) -> f32
Get gesture drag angle
Sourcepub fn get_gesture_pinch_vector(&self) -> Vector2
pub fn get_gesture_pinch_vector(&self) -> Vector2
Get gesture pinch delta
Sourcepub fn get_gesture_pinch_angle(&self) -> f32
pub fn get_gesture_pinch_angle(&self) -> f32
Get gesture pinch angle
Sourcepub fn begin_drawing(&mut self) -> DrawHandle<'_>
pub fn begin_drawing(&mut self) -> DrawHandle<'_>
Setup canvas (framebuffer) to start drawing
Sourcepub fn set_trace_log_level(&mut self, level: TraceLogLevel)
pub fn set_trace_log_level(&mut self, level: TraceLogLevel)
Set the current threshold (minimum) log level (for raylib’s own logging)