Struct Raylib

Source
pub struct Raylib(/* private fields */);
Expand description

Main raylib handle

Implementations§

Source§

impl Raylib

Source

pub fn init_window(width: u32, height: u32, title: &str) -> Option<Self>

Initialize window and OpenGL context

Source

pub fn init_window_ex( width: u32, height: u32, title: &str, flags: ConfigFlags, ) -> Option<Self>

Initialize window and OpenGL context with config flags

Source

pub fn window_should_close(&self) -> bool

Check if Escape key or Close icon is pressed

Source

pub fn close_window(self)

Close window and unload OpenGL context

Source

pub fn is_window_fullscreen(&self) -> bool

Check if window is currently fullscreen

Source

pub fn is_window_hidden(&self) -> bool

Check if window is currently hidden (only PLATFORM_DESKTOP)

Source

pub fn is_window_minimized(&self) -> bool

Check if window is currently minimized (only PLATFORM_DESKTOP)

Source

pub fn is_window_maximized(&self) -> bool

Check if window is currently maximized (only PLATFORM_DESKTOP)

Source

pub fn is_window_focused(&self) -> bool

Check if window is currently focused (only PLATFORM_DESKTOP)

Source

pub fn is_window_resized(&self) -> bool

Check if window has been resized last frame

Source

pub fn is_window_state(&self, flag: ConfigFlags) -> bool

Check if one specific window flag is enabled

Source

pub fn set_window_state(&mut self, flags: ConfigFlags)

Set window configuration state using flags (only PLATFORM_DESKTOP)

Source

pub fn clear_window_state(&mut self, flags: ConfigFlags)

Clear window configuration state flags

Source

pub fn toggle_fullscreen(&mut self)

Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)

Source

pub fn maximize_window(&mut self)

Set window state: maximized, if resizable (only PLATFORM_DESKTOP)

Source

pub fn minimize_window(&mut self)

Set window state: minimized, if resizable (only PLATFORM_DESKTOP)

Source

pub fn restore_window(&mut self)

Set window state: not minimized/maximized (only PLATFORM_DESKTOP)

Source

pub fn set_window_icon(&mut self, image: &Image)

Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)

Source

pub fn set_window_icons(&mut self, images: &[&Image])

Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)

Source

pub fn set_window_title(&mut self, title: &str)

Set title for window (only PLATFORM_DESKTOP)

Source

pub fn set_window_position(&mut self, x: i32, y: i32)

Set window position on screen (only PLATFORM_DESKTOP)

Source

pub fn set_window_monitor(&mut self, monitor: u32)

Set monitor for the current window (fullscreen mode)

Source

pub fn set_window_min_size(&mut self, width: u32, height: u32)

Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)

Source

pub fn set_window_size(&mut self, width: u32, height: u32)

Set window dimensions

Source

pub fn set_window_opacity(&mut self, opacity: f32)

Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)

Source

pub fn get_window_handle(&self) -> *mut c_void

Get native window handle

Source

pub fn get_screen_width(&self) -> u32

Get current screen width

Source

pub fn get_screen_height(&self) -> u32

Get current screen height

Source

pub fn get_render_width(&self) -> u32

Get current render width (it considers HiDPI)

Source

pub fn get_render_height(&self) -> u32

Get current render height (it considers HiDPI)

Source

pub fn get_monitor_count(&self) -> u32

Get number of connected monitors

Source

pub fn get_current_monitor(&self) -> u32

Get current connected monitor

Source

pub fn get_monitor_position(&self, monitor: u32) -> Vector2

Get specified monitor position

Source

pub fn get_monitor_width(&self, monitor: u32) -> u32

Get specified monitor width (current video mode used by monitor)

Source

pub fn get_monitor_height(&self, monitor: u32) -> u32

Get specified monitor height (current video mode used by monitor)

Source

pub fn get_monitor_physical_width(&self, monitor: u32) -> u32

Get specified monitor physical width in millimetres

Source

pub fn get_monitor_physical_height(&self, monitor: u32) -> u32

Get specified monitor physical height in millimetres

Source

pub fn get_monitor_refresh_rate(&self, monitor: u32) -> u32

Get specified monitor refresh rate

Source

pub fn get_window_position(&self) -> Vector2

Get window position XY on monitor

Source

pub fn get_window_scale_dpi(&self) -> Vector2

Get window scale DPI factor

Source

pub fn get_monitor_name(&self, monitor: u32) -> String

Get the human-readable, UTF-8 encoded name of the primary monitor

Source

pub fn set_clipboard_text(&mut self, text: &str)

Set clipboard text content

Source

pub fn get_clipboard_text(&self) -> String

Get clipboard text content

Source

pub fn enable_event_waiting(&mut self)

Enable waiting for events on EndDrawing(), no automatic event polling

Source

pub fn disable_event_waiting(&mut self)

Disable waiting for events on EndDrawing(), automatic events polling

Source

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

Source

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

Source

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

Source

pub fn show_cursor(&mut self)

Shows cursor

Source

pub fn hide_cursor(&mut self)

Hides cursor

Source

pub fn is_cursor_hidden(&self) -> bool

Check if cursor is not visible

Source

pub fn enable_cursor(&mut self)

Enables cursor (unlock cursor)

Source

pub fn disable_cursor(&mut self)

Disables cursor (lock cursor)

Source

pub fn is_cursor_on_screen(&self) -> bool

Check if cursor is on the screen

Source

pub fn set_target_fps(&mut self, fps: u32)

Set target FPS (maximum)

Source

pub fn get_fps(&self) -> u32

Get current FPS

Source

pub fn get_frame_time(&self) -> Duration

Get time for last frame drawn (delta time)

Source

pub fn get_time(&self) -> Duration

Get elapsed time since InitWindow()

Source

pub fn get_random_value(&self, min: i32, max: i32) -> i32

Get a random value between min and max (both included)

Source

pub fn set_random_seed(&mut self, seed: u32)

Set the seed for the random number generator

Source

pub fn take_screenshot(&mut self, file_name: &str)

Takes a screenshot of current screen (file_name extension defines format)

Source

pub fn open_url(&self, url: &str)

Open URL with default system browser (if available)

Source

pub fn is_file_dropped(&self) -> bool

Check if a file has been dropped into window

Source

pub fn get_dropped_files(&self) -> Vec<String>

Load dropped filepaths

Source

pub fn is_key_pressed(&self, key: KeyboardKey) -> bool

Check if a key has been pressed once

Source

pub fn is_key_down(&self, key: KeyboardKey) -> bool

Check if a key is being pressed

Source

pub fn is_key_released(&self, key: KeyboardKey) -> bool

Check if a key has been released once

Source

pub fn is_key_up(&self, key: KeyboardKey) -> bool

Check if a key is NOT being pressed

Source

pub fn set_exit_key(&mut self, key: KeyboardKey)

Set a custom key to exit program (default is ESC)

Source

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

Source

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

Source

pub fn is_gamepad_available(&self, gamepad: u32) -> bool

Check if a gamepad is available

Source

pub fn get_gamepad_name(&self, gamepad: u32) -> String

Get gamepad internal name id

Source

pub fn is_gamepad_button_pressed( &self, gamepad: u32, button: GamepadButton, ) -> bool

Check if a gamepad button has been pressed once

Source

pub fn is_gamepad_button_down( &self, gamepad: u32, button: GamepadButton, ) -> bool

Check if a gamepad button is being pressed

Source

pub fn is_gamepad_button_released( &self, gamepad: u32, button: GamepadButton, ) -> bool

Check if a gamepad button has been released once

Source

pub fn is_gamepad_button_up(&self, gamepad: u32, button: GamepadButton) -> bool

Check if a gamepad button is NOT being pressed

Source

pub fn get_gamepad_button_pressed(&self) -> GamepadButton

Get the last gamepad button pressed

Source

pub fn get_gamepad_axis_count(&self, gamepad: u32) -> u32

Get gamepad axis count for a gamepad

Source

pub fn get_gamepad_axis_movement(&self, gamepad: u32, axis: GamepadAxis) -> f32

Get axis movement value for a gamepad axis

Source

pub fn set_gamepad_mappings(&mut self, mappings: &str) -> i32

Set internal gamepad mappings (SDL_GameControllerDB)

Source

pub fn is_mouse_button_pressed(&self, button: MouseButton) -> bool

Check if a mouse button has been pressed once

Source

pub fn is_mouse_button_down(&self, button: MouseButton) -> bool

Check if a mouse button is being pressed

Source

pub fn is_mouse_button_released(&self, button: MouseButton) -> bool

Check if a mouse button has been released once

Source

pub fn is_mouse_button_up(&self, button: MouseButton) -> bool

Check if a mouse button is NOT being pressed

Source

pub fn get_mouse_x(&self) -> i32

Get mouse position X

Source

pub fn get_mouse_y(&self) -> i32

Get mouse position Y

Source

pub fn get_mouse_position(&self) -> Vector2

Get mouse position XY

Source

pub fn get_mouse_delta(&self) -> Vector2

Get mouse delta between frames

Source

pub fn set_mouse_position(&mut self, x: i32, y: i32)

Set mouse position XY

Source

pub fn set_mouse_offset(&mut self, offset_x: i32, offset_y: i32)

Set mouse offset

Source

pub fn set_mouse_scale(&mut self, scale_x: f32, scale_y: f32)

Set mouse scaling

Source

pub fn get_mouse_wheel_move(&self) -> f32

Get mouse wheel movement for X or Y, whichever is larger

Source

pub fn get_mouse_wheel_move_vec(&self) -> Vector2

Get mouse wheel movement for both X and Y

Source

pub fn set_mouse_cursor(&mut self, cursor: MouseCursor)

Set mouse cursor

Source

pub fn get_touch_x(&self) -> i32

Get touch position X for touch point 0 (relative to screen size)

Source

pub fn get_touch_y(&self) -> i32

Get touch position Y for touch point 0 (relative to screen size)

Source

pub fn get_touch_position(&self, index: u32) -> Vector2

Get touch position XY for a touch point index (relative to screen size)

Source

pub fn get_touch_point_id(&self, index: u32) -> u32

Get touch point identifier for given index

Source

pub fn get_touch_point_count(&self) -> u32

Get number of touch points

Source

pub fn set_gestures_enabled(&mut self, flags: Gesture)

Enable a set of gestures using flags

Source

pub fn is_gesture_detected(&self, gesture: Gesture) -> bool

Check if a gesture have been detected

Source

pub fn get_gesture_detected(&self) -> Gesture

Get latest detected gesture

Source

pub fn get_gesture_hold_duration(&self) -> Duration

Get gesture hold time

Source

pub fn get_gesture_drag_vector(&self) -> Vector2

Get gesture drag vector

Source

pub fn get_gesture_drag_angle(&self) -> f32

Get gesture drag angle

Source

pub fn get_gesture_pinch_vector(&self) -> Vector2

Get gesture pinch delta

Source

pub fn get_gesture_pinch_angle(&self) -> f32

Get gesture pinch angle

Source

pub fn begin_drawing(&mut self) -> DrawHandle<'_>

Setup canvas (framebuffer) to start drawing

Source

pub fn set_trace_log_level(&mut self, level: TraceLogLevel)

Set the current threshold (minimum) log level (for raylib’s own logging)

Trait Implementations§

Source§

impl Debug for Raylib

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Raylib

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Raylib

§

impl RefUnwindSafe for Raylib

§

impl !Send for Raylib

§

impl !Sync for Raylib

§

impl Unpin for Raylib

§

impl UnwindSafe for Raylib

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.