I've been trying to write some opengl code that works everywhere, but without restricting myself too much.
I wanted to use opengles2 on devices that only support it, and opengl core where supported.
Also, I wanted to be able to select which one I'd use, in runtime ( if available, of course ).
My questions are:
if I link my code with OpenGL library every time it is available, and then either create a GLES2 or GL core context, will the GLES2 context behave exactly the same as GLESv2 library? What will be the repercussions of this, header-wise?
For example, GLESv2 does not define BGRA texture formats, so I guess I'd have to convert all to RGBA. It's not much of a hassle, but I'm interested in knowing about alternatives.
I've thought of dynamically loading the library and loading all used functions pointers, but that's a huge amount of work for something that maybe has a easier answer. In this case, I would just include glext.h, and declare all the function pointers for the used functions, and populate them. The problem here, is that glext does not define any data types ( glenum, etc ), so I always have to include gl.h. By including both, I get the gl.h function declaration AND my own function pointer declaration, so I couldn't just use the general namespace for the function pointers... And even then, some functions ( like glGetError ) do not seem to have an associated typedef for their function pointer.
I know about GLEW, but unfortunately, most linux distros distribute a version of GLEW that is still not GLES2 compatible ( debian, i'm looking at you ). It just segfaults.
How would you guys do this? Any other approaches for opengl function linking?