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§
sourcefn new(window: &mut GlfwWindow) -> Result<Self>where
Self: Sized,
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§
sourcefn handle_event(
&mut self,
_window: &mut GlfwWindow,
_window_event: WindowEvent
) -> Result<()>
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 callingset_should_close
on the window.window_event
- The event currently being processed by the window.
sourcefn update(&mut self, _window: &mut GlfwWindow) -> Result<()>
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 callingset_should_close
on the window.