Search code examples
c++openglopengl-3

Some OpenGL features working, some not


I have been trying to start using OpenGL with C++ on my new arch linux box, but I can only use functions from before OpenGL 3.0.

For example, the following code works:

glBegin(GL_TRIANGLES);  
{  
glColor3f(0.0f,0.0f,1.0f);  
glVertex3f( 0.0f, 1.0f, 0.0f);  
glColor3f(0.0f,1.0f,0.0f);  
glVertex3f(-1.0f,-1.0f, 0.0f);  
glColor3f(1.0f,0.0f,0.0f);  
glVertex3f( 1.0f,-1.0f, 0.0f);  
}  
glEnd();

but the following does not:

GLuint vertexArrayID;
glGenVertexArrays(1, &vertexArrayID);
glBindVertexArray(vertexArrayID);

It cannot find the functions glGenVertexArrays and glBindVertexArray, as indicated by output from Eclipse: function glGenVertexArrays cannot be resolved.

So what would cause this? Bad library linking? Old drivers?

My glxinfo:
OpenGL renderer string: AMD Radeon HD 6450
OpenGL core profile version string: 4.3.12414 Core Profile Context 13.15.100.1 OpenGL core profile shading language version string: 4.30


Solution

  • I think I found a solution. I am using Arch Linux with an AMD GPU, so there are two drivers: Mesa(Open Source) and Catalyst(Proprietary). I am using catalyst because mesa does not support opengl 3.0+. But I was including GL/gl.h, which is mesa's header file. I fixed this by including GL/glATI.h.

    I am not sure if this is a good fix and if it would work on all systems, but it seems to be working for me.