Skip to content

Instantly share code, notes, and snippets.

@brendanzab
Created September 14, 2012 03:26
Show Gist options
  • Save brendanzab/3719612 to your computer and use it in GitHub Desktop.
Save brendanzab/3719612 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <GL/glfw3.h>
int main()
{
GLFWwindow window;
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
exit( EXIT_FAILURE );
}
window = glfwCreateWindow( 300, 300, GLFW_WINDOWED, "Test", NULL );
if (!window)
{
fprintf( stderr, "Failed to open GLFW window\n" );
glfwTerminate();
exit( EXIT_FAILURE );
}
GLboolean running = GL_TRUE;
while( running )
{
glfwPollEvents();
if (glfwGetKey(window, GLFW_KEY_ESC) || glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) {
running = GL_FALSE;
}
}
glfwTerminate();
exit( EXIT_SUCCESS );
}
use std;
use glfw3;
import glfw3::*;
fn main() {
if (glfwInit() == 0) {
glfwTerminate();
fail(~"glfwInit() failed\n");
}
let mut window = glfwCreateWindow(800, 600, 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) {
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