Skip to content

Instantly share code, notes, and snippets.

@0e4ef622
Last active November 6, 2018 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0e4ef622/085fcd4e0cb1b51e431b113b48474723 to your computer and use it in GitHub Desktop.
Save 0e4ef622/085fcd4e0cb1b51e431b113b48474723 to your computer and use it in GitHub Desktop.
bug in glutin_window
[package]
name = "glutin-window-bug"
version = "0.1.0"
authors = ["Matthew Tran <0e4ef622@gmail.com>"]
edition = "2018"
[dependencies]
piston = "0.37"
piston-texture = "0.6"
# uncomment one of the below
# pistoncore-glutin_window = "0.48"
# pistoncore-glutin_window = "0.47"
piston2d-graphics = "0.26"
piston2d-opengl_graphics = "0.54"
image = "0.20.0"
extern crate piston;
extern crate texture;
extern crate glutin_window;
extern crate graphics;
extern crate opengl_graphics;
extern crate image;
fn main() {
use piston::window::WindowSettings;
use piston::event_loop::{ Events, EventSettings };
use piston::input::{ RenderEvent, UpdateEvent, PressEvent, ReleaseEvent };
use glutin_window::GlutinWindow as Window;
use opengl_graphics::{ OpenGL, GlGraphics };
use graphics::draw_state::DrawState;
let opengl = OpenGL::V3_2;
let mut window: Window = WindowSettings::new("Remani", [1024, 768])
.opengl(opengl)
.srgb(false)
.build()
.expect("Could not create window");
let mut gl = GlGraphics::new(opengl);
let draw_state = DrawState::default();
let mut events = Events::new(EventSettings::new());
while let Some(e) = events.next(&mut window) {
if let Some(r) = e.render_args() {
gl.draw(r.viewport(), |c, gl| {
graphics::clear([1.0; 4], gl);
let red_rect = graphics::rectangle::Rectangle::new([1.0, 0.0, 0.0, 1.0]);
red_rect.draw([0.0, 200.0, 100.0, 100.0], &draw_state, c.transform, gl);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment