Struct SdlPlatform

Source
pub struct SdlPlatform { /* private fields */ }
Expand description

SDL2 backend platform state.

A backend platform handles window/input device events and manages their state.

There are three things you need to do to use this library correctly:

  1. Initialize a SdlPlatform instance
  2. Pass events to the platform (every frame)
  3. Call frame preparation callback (every frame)

Implementations§

Source§

impl SdlPlatform

Source

pub fn new(imgui: &mut Context) -> SdlPlatform

Initializes a SDL platform instance and configures imgui.

This function configures imgui-rs in the following ways:

  • backend flags are updated
  • keys are configured
  • platform name is set
Source

pub fn init(imgui: &mut Context) -> SdlPlatform

👎Deprecated: use new instead

Initializes a SDL platform instance and configures imgui.

Deprecated since 0.13.0 – use new instead

Source

pub fn handle_event(&mut self, context: &mut Context, event: &Event) -> bool

Handles a SDL event.

This function performs the following actions (depends on the event):

  • keyboard state is updated
  • mouse state is updated
Source

pub fn prepare_frame( &mut self, context: &mut Context, window: &Window, event_pump: &EventPump, )

Frame preparation callback.

Call this before calling the imgui-rs context frame function. This function performs the following actions:

  • display size and the framebuffer scale is set
  • mouse cursor is repositioned (if requested by imgui-rs)
  • current mouse cursor position is passed to imgui-rs
  • changes mouse cursor icon (if requested by imgui-rs)

Auto Trait Implementations§

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.