Crate piston_window [−] [src]
The official Piston window wrapper for the Piston game engine
Sets up Gfx with an OpenGL back-end.
Uses gfx_graphics
for 2D rendering.
Uses glutin_window
as default window back-end, but this can be swapped.
sRGB is turned on because it is required by gfx_graphics.
Example
extern crate piston_window; use piston_window::*; fn main() { let window: PistonWindow = WindowSettings::new("Hello World!", [512; 2]) .build().unwrap(); for e in window { e.draw_2d(|c, g| { clear([0.5, 0.5, 0.5, 1.0], g); rectangle([1.0, 0.0, 0.0, 1.0], // red [0.0, 0.0, 100.0, 100.0], // rectangle c.transform, g); }); } }
Swap to another window back-end
Change the second generic parameter to the window back-end you want to use.
let window: PistonWindow<(), Sdl2Window> = WindowSettings::new("title", [512; 2]) .build().unwrap();
Do not depend on this library
This library is not meant to be depended on by other libraries.
Instead, libraries should depend on the lower abstractions,
such as the Piston core.
The only purpose of this library is to provide a convenient way to get started.
Reexports
pub use graphics::*; |
pub use piston::window::*; |
pub use piston::input::*; |
pub use piston::event_loop::*; |
Structs
PistonWindow |
Contains everything required for controlling window, graphics, event loop. |
Texture |
Represents a texture. |
TextureSettings |
Texture creation parameters. |
Enums
Error |
An enum to represent various possible run-time errors that may occur. |
Flip |
Flip settings. |
OpenGL |
Functions
empty_app |
Creates a new empty application. |
Type Definitions
G2d |
2D graphics. |
GfxEncoder |
Actual gfx::Stream implementation carried by the window. |
Glyphs |
Glyph cache. |