Function oxid::core::start

source · []
pub fn start<F>(conf: Conf, f: F)where
    F: 'static + FnOnce(Context) -> UserData,
Expand description

Start oxid::core. Initialization callback will be called when oxid’s Context is ready. User can take ownership on Context and store it in user Code. Or return it back to oxid and give oxid ownership on Context.

Variant wth EventHandler:

struct Stage;

impl EventHandler for Stage {
    fn update(&mut self, _ctx: &mut Context) {}
    fn draw(&mut self, _ctx: &mut Context) {}
}
fn main() {
    oxid::core::start(conf::Conf::default(), |ctx| UserData::owning(Stage, ctx));
}

Variant wth EventHandlerFree:

struct Stage {
    ctx: Context,
}
impl EventHandlerFree for Stage {
    fn update(&mut self) {}
    fn draw(&mut self) {}
}
fn main() {
    oxid::core::start(conf::Conf::default(), |ctx| UserData::free(Stage { ctx }));
}