Crate riddle_platform_winit[][src]

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::{ext::*, *};

fn main() -> Result<(), PlatformError> {
    let (platform_system, main_thread_state) = PlatformSystem::new_shared();
    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;

Modules

ext

Types which are needed to use the input system independent from the root riddle crate.

winit_ext

Traits which expose underlying winit crate’s types

Structs

PlatformContext

The platform system context provided to the application main thread.

PlatformMainThreadState
PlatformSystem

The winit platform system core state, along with PlatformMainThreadState.

PlatformSystemHandle
PlatformSystemWeak
Window

A platform native window.

WindowBuilder

Builder for Window instances.

WindowHandle
WindowWeak

Enums

PlatformError
PlatformEvent