I can’t seem to open a glfw window. Can somebody help me out?
#include <stdio.h>
#include <stdlib.h>
#include <GL\glew.h>
#include <GL\glfw.h>
#include <glm\glm.hpp>
int main() {
// Initialize GLFW
if(!glfwInit()) {
fprintf(stderr, "Failed to initialize GLFW!
");
return 1;
}
// Create the OpenGL window
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x AA
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWvidmode vm;
glfwGetDesktopMode(&vm);
// Open a window and create the OpenGL context
if(!glfwOpenWindow(800, 600, vm.RedBits, vm.GreenBits, vm.BlueBits, 0, 0, 0, GLFW_WINDOW)) {
fprintf(stderr, "Failed to open GLFW window!
");
glfwTerminate();
return 2;
}
// Initialize GLEW
if(glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW!
");
return 3;
}
glfwSetWindowTitle("OpenGL Application");
// Navy blue background
glClearColor(0.0f, 0.1f, 0.3f, 1.0f);
glfwEnable(GLFW_STICKY_KEYS);
do {
// Swap the front and back buffers
glfwSwapBuffers();
} while (glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS
&& glfwGetWindowParam(GLFW_OPENED));
return 0;
}
The program compiles and links properly in VC++ 2010 Express. I’ve tried using various arguments to glfwOpenWindow(), but it fails every time.