Problem setting required OpenGL version in glfwWindowHint()

rensutheart wrote on Wednesday, December 02, 2015:

Hello,

I have a problem setting the required OpenGL version in my application. What is strange is that it used to work, but recently I upgraded to Windows 10 and updated all my graphics card drivers (NVIDIA GT540M) and now my my program creates NULL windows (with glfwCreateWindow()).

Using the exact code from http://www.glfw.org/docs/3.0/quick.html my programs funcions perfectly, but as soon as I call glfwWindowHint to set the OpenGL version I want to use (OpenGL 3.3) it causes the mentioned NULL windows to be created. However, if I set the version to OpenGL 2.1 or lower it works fine again.

I’m using Visual Studio Community 2013 (and 2015) and I’m quite sure I set up the libraries and includes up correctly (also included opengl32.lib).

Here is my code segment where I changed the example:

	GLFWwindow* window;
	glfwSetErrorCallback(error_callback);
	if (!glfwInit())
		exit(EXIT_FAILURE);

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

	window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
	if (!window)
	{
		glfwTerminate();
		exit(EXIT_FAILURE);
	}
	glfwMakeContextCurrent(window);

Any help would be appreciated!

To help with diagnosis I would run the glfwinfo.c tests to check which OpenGL version is being reported. For a second check you could also try using glView http://www.realtech-vr.com/glview/.

This sounds like a driver issue, but if glView is reporting OGL >= 3.3 then perhaps there is some other issue.

rensutheart wrote on Wednesday, December 02, 2015:

I found the solution to my problem. The problem was that my NVIDIA Control Panel was set to choose which graphics processor to use automatically, and it chose my Intel Integrated Graphics processor instead of the graphics card. So Under Mangage 3D settings, under the Global Settings tab, I just set the Preferred graphics processor to “High-performance NVIDIA processor”. That fixed it!

Do check out the GLFW_USE_HYBRID_HPG option:

http://www.glfw.org/docs/latest/compile.html#compile_options_win32

rensutheart wrote on Thursday, December 03, 2015:

Thank you! Very useful!