Skip to content

Instantly share code, notes, and snippets.

@dpc
Last active December 12, 2015 12:38
Show Gist options
  • Save dpc/4773161 to your computer and use it in GitHub Desktop.
Save dpc/4773161 to your computer and use it in GitHub Desktop.
extern mod glfw3;
use glfw3;
use glfw3::*;
extern mod glfw {
}
fn os_thread() {
if (!glfw3::init()) {
die!(~"glfwInit() failed\n");
}
window_hint(SAMPLES, 4); // 4x antialiasing
window_hint(CONTEXT_VERSION_MAJOR, VERSION_MAJOR);
window_hint(CONTEXT_VERSION_MINOR, VERSION_MINOR);
window_hint(OPENGL_PROFILE, OPENGL_CORE_PROFILE); //We don't want the old OpenGL
// Open a window and create its OpenGL context
let window = Window::create(800, 600, "Title", Windowed);
/*
// Initialize GLEW
glewExperimental=true; // Needed in core profile
if (glewInit() != GLEW_OK) {
die!("glewInit() failed\n");
}
*/
// window.set_title("Tutorial 01");
// Ensure we can capture the escape key being pressed below
//window.set_input_mode(STICKY_KEYS, 1);
//while ( window.get_key(KEY_ESC ) != PRESS && window.get_param(OPENED) ) {
while (window.get_key(KEY_ESC) != PRESS) {
// Draw nothing, see you in tutorial 2 !
// Swap buffers
window.swap_buffers();
} // Check if the ESC key was pressed or the window was closed
}
fn main() {
do task::task().sched_mode(task::PlatformThread).spawn { os_thread(); }
}
RUSTC ?= rustc
#LOG_FLAGS ?= RUST_LOG=rustc::metadata::creader
all: glhex
run: all
./glhex
glhex: main.rs *.rs
$(LOG_FLAGS) $(RUSTC) -L glfw3/lib -o $@ $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment