glfwOpenWindow() is failing

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.

In appendix A.2 of the GLFW Reference manual it says:

GLFW uses the GLX_ARB_create_context_profile extension to provide support for context profiles. Where this extension is unavailable, setting the GLFW_OPENGL_PROFILE hint to anything but zero will cause glfwOpenWindow to fail.

So I set GLFW_OPENGL_PROFILE to 0 and it works. The reference also says that setting GLFW_OPENGL_PROFILE to 0 let’s the system choose. Is this a good or a bad thing? I want to use just the features available in the core profile, so will this matter?

I’m not sure but, is the core_profile compatible with opengl 3.1? You could try with 3.2 if your card is capable

I got it working. You can’t have GLFW_OPENGL_VERSION_MINOR set to anything less than 3 if you want to use just the core profile which makes perfect sense. I don’t know why I didn’t realize that sooner.