[−][src]Crate riddle_platform_winit
Riddle platform system implementation based on winit
, managing the OS's main
event loop and windowing system.
Riddle Example
The recommended way to use this crate is through the main riddle
crate.
Riddle exposes this crate through riddle::platform
.
use riddle::{*, platform::*}; fn main() -> Result<(), RiddleError> { let rdl = RiddleLib::new()?; let window = WindowBuilder::new().build(rdl.context())?; rdl.run(move |rdl| { match rdl.event() { Event::Platform(PlatformEvent::WindowClose(_)) => rdl.quit(), _ => (), } }) }
Direct Example
If you don't want to depend on riddle
, you can use this crate directly. There isn't much point
in doing so over using winit
directly though - the main function of this crate is to integrate
winit
in to Riddle.
use riddle_platform_winit::*; fn main() -> Result<(), PlatformError> { let (platform_system, main_thread_state) = PlatformSystem::new(); let window = WindowBuilder::new().build(main_thread_state.borrow_context())?; main_thread_state.run::<PlatformError, _>(move |ctx| { match ctx.event() { PlatformEvent::WindowClose(_) => { ctx.quit(); } _ => () }; Ok(()) }) }
Re-exports
pub use riddle_platform_common as common; |
Structs
PlatformContext | The platform system context provided to the application main thread. |
PlatformMainThreadState | |
PlatformSystem | The winit platform system core state, along with |
PlatformSystemHandle | |
PlatformSystemWeak | |
Window | A platform native window. |
WindowBuilder | Builder for |
WindowHandle | |
WindowWeak |
Enums
PlatformError | |
PlatformEvent |