I am running Arch Linux with Mesa 10 on an HP laptop with an Intel HD 3000 GPU. (There is also an ATI card but I shut it off at boot.) I am trying to run OpenGL code with the core profile. OpenGL 3.1 and GLSL 1.4 should be supported according to glxinfo:
-> % glxinfo | grep version
OpenGL core profile version string: 3.1 (Core Profile) Mesa 10.0.1
OpenGL core profile shading language version string: 1.40
OpenGL version string: 3.0 Mesa 10.0.1
OpenGL shading language version string: 1.3
However, when I compile a GLFW program, try to force the core profile, and ask for the OpenGL version like so:
#include <GL/glew.h>
#include <GLFW/glfw3.h>
int main(void)
{
// Use OpenGL 3.1 core profile
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_CONTEXT_REVISION, 0);
// Create opengl context
int window_width = 1024;
int window_height = 768;
GLFWwindow* window = initialize_glfw(window_width, window_height);
if (!window)
{
glfwTerminate();
std::exit(EXIT_FAILURE);
}
// Display OpenGL version
int major, minor, rev, client, forward, profile;
glfwGetVersion(&major, &minor, &rev);
std::cout << "OpenGL - " << major << "." << minor << "." << rev << std::endl;
}
as well as compile shaders with GLSL #version 140, this is the printed output:
-> % ./main
OpenGL - 3.0.3
Shader compilation failed with this message:
0:1(10): error: GLSL 1.40 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
So, it seems like OpenGL 3.1 and GLSL 1.4 should be supported, but they are not being used in my GLFW program. Can anyone tell me what might be wrong?
After re-reading the documentation, there seem to have been two problems. One, as elmindreda pointed out, is that calling init after making window hints sets the window hints back to their defaults, so init must be called first.
Second, I am using OpenGL 3.1, and the GLFW docs say "If requesting an OpenGL version below 3.2, GLFW_OPENGL_ANY_PROFILE must be used." I was trying to use GLFW_OPENGL_CORE_PROFILE.