basic_app/
basic_app.rs

1#![forbid(unsafe_code)]
2
3use std::convert::Infallible;
4use std::error;
5use std::io::{self, Write};
6use std::process::exit;
7
8use ren::prelude::*;
9
10fn main() {
11    exit({
12        let code = match try_main() {
13            Ok(()) => 0,
14            Err(err) => {
15                eprintln!("error: {}", err);
16                1
17            }
18        };
19        let _ = io::stdout().flush();
20        let _ = io::stderr().flush();
21        code
22    });
23}
24
25fn try_main() -> Result<(), Box<dyn error::Error>> {
26    ren::run!(MyApp)
27}
28
29struct MyApp;
30
31impl<'gl> App<'gl> for MyApp {
32    type Err = Infallible;
33
34    fn init(ctx: &mut RenderingContext<'gl>) -> Result<Self, Self::Err> {
35        ctx.set_clear_color((1.0, 0.0, 1.0, 1.0));
36
37        Ok(Self)
38    }
39
40    fn draw(&mut self, ctx: &mut RenderingContext<'gl>, _wnd: &Window) {
41        ctx.clear_color_buffer();
42    }
43}