Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created September 14, 2012 04:44
Show Gist options
  • Save nikomatsakis/3719846 to your computer and use it in GitHub Desktop.
Save nikomatsakis/3719846 to your computer and use it in GitHub Desktop.
use std;
use glfw3;
import glfw3::*;
fn main() {
do task::task().sched_mode(task::PlatformThread).spawn {
if (glfwInit() == 0) {
glfwTerminate();
fail(~"glfwInit() failed\n");
}
let mut window = glfwCreateWindow(300, 300, GLFW_WINDOWED, ~"Hello, I am a window.");
io::println(fmt!("Window ptr: %d", window.ptr as int));
if (ptr::is_null(window.ptr)) {
glfwTerminate();
io::println(~"Error: " + glfwErrorString(glfwGetError()));
fail(~"glfwOpenWindow() failed\n");
}
let mut done = false;
while (!done) {
io::println(~"Hello, world");
glfwPollEvents();
if (glfwGetKey(&mut window, GLFW_KEY_ESC) == GLFW_PRESS || glfwGetWindowParam(&mut window, GLFW_CLOSE_REQUESTED) != 0) {
done = true;
}
}
glfwTerminate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment