Created
September 14, 2012 04:44
-
-
Save nikomatsakis/3719846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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