Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created March 9, 2016 20:43
Show Gist options
  • Save hadronized/1262f77a9577ff0ecbed to your computer and use it in GitHub Desktop.
Save hadronized/1262f77a9577ff0ecbed to your computer and use it in GitHub Desktop.
extern crate glfw;
use glfw::{Action, Context, Key};
fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
// Create a windowed mode window and its OpenGL context
let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");
// Make the window's context current
window.make_current();
// Loop until the user closes the window
while !window.should_close() {
// Swap front and back buffers
window.swap_buffers();
// Poll for and process events
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
println!("{:?}", event);
match event {
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
window.set_should_close(true)
},
_ => {},
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment