Trait demo_vk::app::App

source ·
pub trait App {
    type Args: Sized + Parser;

    // Required method
    fn new(window: &mut Window, args: Self::Args) -> Result<Self>
       where Self: Sized;

    // Provided methods
    fn handle_event(
        &mut self,
        window: &mut Window,
        event: WindowEvent,
    ) -> Result<()> { ... }
    fn update(&mut self, window: &mut Window) -> Result<()> { ... }
}
Expand description

Implementations of this trait can be run with app_main to manage a GLFW window.

Required Associated Types§

Required Methods§

source

fn new(window: &mut Window, args: Self::Args) -> Result<Self>
where Self: Sized,

Creates a new instance of the application. The application is allowed to modify the window based on its own requirements. This includes modifying the polling state, fullscreen status, size, etc…

Provided Methods§

source

fn handle_event( &mut self, window: &mut Window, event: WindowEvent, ) -> Result<()>

Handles a single GLFW event.

This function is called in a loop to consume any pending events before every call to update().

source

fn update(&mut self, window: &mut Window) -> Result<()>

Called in a loop after all pending events have been processed.

This is a good place for rendering logic. This method blocks event processing, so it should be kept as responsive as possible.

Implementors§