Trait ccthw::application::State

source ·
pub trait State {
    // Required method
    fn new(window: &mut GlfwWindow) -> Result<Self>
       where Self: Sized;

    // Provided methods
    fn handle_event(
        &mut self,
        _window: &mut GlfwWindow,
        _window_event: WindowEvent
    ) -> Result<()> { ... }
    fn update(&mut self, _window: &mut GlfwWindow) -> Result<()> { ... }
}
Expand description

Application state can be any type which implements the State trait.

State is created after the GLFW window is created, but is allowed to configure the window for things like resizability and event polling.

Required Methods§

source

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

Create a new instance of this state.

Params
  • window - A fully constructed application window. The implementation can use this handle to resize the window, apply GLFW window hints, toggle fullscren, and construct a Vulkan instance which can present surfaces to the window.

Provided Methods§

source

fn handle_event( &mut self, _window: &mut GlfwWindow, _window_event: WindowEvent ) -> Result<()>

Handle a GLFW event and update the application state.

Params
  • window - The fully constructed application window. The application can exit by calling set_should_close on the window.
  • window_event - The event currently being processed by the window.
source

fn update(&mut self, _window: &mut GlfwWindow) -> Result<()>

Called each time through the main application loop after all events have been processed.

Update is not called while an application is paused while minimized.

Params
  • window - The fully constructed application window. The application can exit by calling set_should_close on the window.

Implementors§