I have the following code:
glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open window and create OpenGL context
GLFWwindow * window;
window = glfwCreateWindow(1024, 768, "OpenGL Testing", NULL, NULL);
if(window == NULL)
{
fprintf(stderr, "Failed to open GLFW Window.\n");
glfwTerminate();
return -1;
}
It works fine on my desktop on both Ubuntu and Windows, but it fails on my laptop running OSX. I thought it was an issue with the laptop not supporting this version of OpenGL, but it supports up to 4.1 with the video card.
I have thought that it may be using the integrated intel GPU instead of the nVidia one, but as I understand from what I have seen, GLFW will force the correct GPU to do the rendering.
If I change the context to 2.1, everything seems to work, but then the shaders aren't compatible.
Any ideas?
UPDATE: If all of the glfwWindowHint()
calls are removed, the window is created, but the shaders are incompatible. I assume if these are removed, GLFW automatically chooses a context, which happens to be incompatible with shaders with version 330 core
.
The problem came down to setting a forward compatibility flag in GLFW. This answer led to the answer of making the following call:
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
This is also shown in the GLFW FAQ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With