Application

Trait Application 

Source
pub trait Application<Canvas = WindowCanvas> {
    // Provided methods
    fn on_create(
        &mut self,
        _canvas: &mut Canvas,
        _input: &InputState,
    ) -> ApplicationResult { ... }
    fn on_update(
        &mut self,
        _canvas: &mut Canvas,
        _input: &InputState,
        _elapsed_time: f64,
    ) -> ApplicationResult { ... }
    fn on_quit(&mut self) -> Result<(), Box<dyn Error>> { ... }
}
Expand description

An application using this framework.

Provided Methods§

Source

fn on_create( &mut self, _canvas: &mut Canvas, _input: &InputState, ) -> ApplicationResult

Called once at the start of the program.

§Parameters
  • canvas: A draw target representing the visible window.
  • input: a struct containing info about the state of input devices, such as the keyboard and mouse.
Source

fn on_update( &mut self, _canvas: &mut Canvas, _input: &InputState, _elapsed_time: f64, ) -> ApplicationResult

Called once per frame.

§Parameters
  • canvas: A draw target representing the visible window.
  • input: a struct containing info about the state of input devices, such as the keyboard and mouse.
  • elapsed_time: Duration (in seconds) since the last frame. This can be used to keep time-sensative routines, such as animation, running at a constant speed.
Source

fn on_quit(&mut self) -> Result<(), Box<dyn Error>>

Called when the window’s close button is clicked. Be aware that this isn’t called on std::process::exit, so do any essential cleanup in a Drop implementation instead. Does nothing by default.

Implementors§