2
votes

I'm playing a little bit with opengl programming on linux and I've some doubts.

The glxinfo gives me the following for the OpenGL version:

OpenGL version string: 2.1 Mesa 7.11

I guess this means that my system support OpenGL 2.1 using the Mesa implementation.

Then, if I look at GL/gl.h from /usr/include I found something like:

#define GL_VERSION_1_1 1
#define GL_VERSION_1_2 1
#define GL_VERSION_1_3 1
#define GL_ARB_imaging 1

so the GL_VERSION_xx are not defined for 1.4, 1.5, 2.0. So my question is, why the header file does not include the definitions for GL versions up to 2.0 (at least) ? I'm supposed to change the GL/gl.h header file with something more appropriate ?

For information, I'm using a standard ubuntu linux installation. Here some more informations from glxinfo:

OpenGL vendor string: X.Org R300 Project
OpenGL renderer string: Gallium 0.4 on ATI RV515
OpenGL version string: 2.1 Mesa 7.11
OpenGL shading language version string: 1.20

Francesco

1

1 Answers

3
votes

You need to separate between the OpenGL version actually implemented and what's present in the header files. The contents of OpenGL header files usually are some kind of lowest common denominator, for the reason that OpenGL has an extension system. OpenGL implementations offer their capabilities (also) through the extension system, which is effectively some form of dynamic library linkage.

This allows programs which require extended functionality to run on systems with less capabilities to either abort gracefully, giving some usefull error message instead of a "required symbol glShaderSource in libGL.so doesn't resolve", which may confuse the user, or even drop down into a compatibility mode.

The most simple way to get higher OpenGL version capabilities is by using the GLEW library ( http://glew.sourceforge.net ), which boils down to include GL/glew.h instead of GL/gl.h and calling glewInit() right after context creation.