PistonDevelopers/piston_window

Name: piston_window

Owner: PistonDevelopers

Description: The official Piston convenience window wrapper for the Piston game engine

Created: 2015-04-13 10:55:40.0

Updated: 2018-05-12 22:13:13.0

Pushed: 2018-04-26 15:20:38.0

Homepage:

Size: 746

Language: Rust

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

piston_window Build Status Crates.io Crates.io

The official Piston convenience window wrapper for the Piston game engine

Notice! If this is your first time visiting Piston, start here.

Piston-Window is designed for only one purpose: Convenience.

Documentation

rn crate piston_window;
piston_window::*;
ain() {
let mut window: PistonWindow = WindowSettings::new("Hello Piston!", (640, 480))
    .exit_on_esc(true)
    .build()
    .unwrap_or_else(|e| { panic!("Failed to build PistonWindow: {}", e) });
while let Some(e) = window.next() {
    window.draw_2d(&e, |_c, g| {
        clear([0.5, 1.0, 0.5, 1.0], g);
    });
}

PistonWindow uses Glutin as window back-end by default, but you can change to another back-end, for example SDL2 or GLFW by changing the type parameter:

mut window: PistonWindow<Sdl2Window> = WindowSettings::new("Hello Piston!", [640, 480])
.exit_on_esc(true).build().unwrap();

PistonWindow implements AdvancedWindow, Window and EventLoop. Nested game loops are supported, so you can have one inside another.

e let Some(e) = window.next() {
if let Some(button) = e.press_args() {
    // Intro.
    while let Some(e) = window.next() {
        ...
    }
}

Ideas or feedback? Open up an issue here.

Dependency graph

Dependencies


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.