The official Piston convenience window wrapper for the Piston game engine

License: MIT

Language: Rust

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.


  • Reexports everything you need to write 2D interactive applications
  • .draw_2d for drawing 2D, and .draw_3d for drawing 3D
  • Uses Gfx to work with 3D libraries in the Piston ecosystem
extern crate piston_window;
use piston_window::*;
fn main() {
    let mut window: PistonWindow = WindowSettings::new("Hello Piston!", (640, 480))
        .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:

let mut window: PistonWindow<Sdl2Window> = WindowSettings::new("Hello Piston!", [640, 480])

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

while 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


Project Statistics

Sourcerank 12
Repository Size 737 KB
Stars 82
Forks 34
Watchers 72
Open issues 32
Dependencies 8
Contributors 17
Tags 1
Last updated
Last pushed

Top Contributors See all

Sven Nilsen mitchmindtree Nikita Belyakov Dzmitry Malyshau Marcel Müller Steve Jahns Ilan Scheinkman Chris Tolliday Alexander Kuvaev Light Ning Mike MacDonald Jason Schein Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer R. Deckers Gabriel Martinez johnthagen Xavier Shay

Packages Referencing this Repo

The official Piston window wrapper for the Piston game engine
Latest release 0.88.0 - Updated - 82 stars

Recent Tags See all

v0.2 June 05, 2015

Something wrong with this page? Make a suggestion

Last synced: 2019-01-20 19:10:02 UTC

Login to resync this repository