shadiertoy 0.1.0

A shadertoy rip-off.
Documentation
use Window;
use glutin::{Event, EventsLoop, WindowEvent};

/// A game, which is hopefully what you're making.
pub trait Game {
    /// Initialize.
    fn new(&mut Window) -> Self;

    /// Handle an event.
    ///
    /// All input handling goes here.
    fn event(&mut self, &mut Window, Event) {}

    /// Draw a frame.
    ///
    /// Call `Window::draw` inside this function.
    fn draw(&mut self, &mut Window);

    /// Run the game!
    fn run() where Self: Sized {
        let mut events = EventsLoop::new();
        let mut window = Window::new(&events);
        let mut game = Self::new(&mut window);
        let mut running = true;

        while running {
            game.draw(&mut window);
            window.flush();

            events.poll_events(|e| {
                match e {
                    Event::WindowEvent { event: WindowEvent::Resized(..), .. } => {
                        window.resize();
                    }
                    Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
                        running = false;
                    }
                    _ => {}
                }

                game.event(&mut window, e);
            });
        }
    }
}