I’m trying to use OpenGL on Linux with the Mesa libraries but I’m confused as to what header/library combination I should actually be using.
The GL/gl.h file does not include any of the OpenGL 3.0+ functions, like glCreateProgram. These are however in the GL/glext.h file but only if GL_GLEXT_PROTOTYPES is defined. This would be linked against the GL library.
The GLES2/gl2.h includes all the definitions I need, and also has a different library GLESv2.
What is the correct combination of headers and libraries for a Linux desktop?
I can also add to this list should I be using GLUT, GLEW, or GLEX or EGL? All of these are all part of MESA and the samples seem to choose at random.
IMO it’s completely up to you on what you need, what you want to code yourself (esp. in case of GLUT) and what target platforms you’ve got:
If you’d like to target mobile platforms as well, GLES might be the better choice (as they usually don’t support OpenGL, but OpenGL ES).
If you’d like to target Windows as well, you’ll have to go OpenGL, as OpenGL ES is not supported (unless you use some additional layer, e.g. the Angle library).
Regarding the additional libraries mentioned – you don’t need either for a minimal program, but they can save you time:
GLUT is a collection of useful snippets/functions commonly being “nice to have”, e.g. a quick way to create a window or handle basic texture loading.
GLEW is a similar collection, making it easier to use extension not being in basic OpenGL (e.g. the mentioned
glCreateProgram.