I’m trying to make a library I wrote portable. It is a graphics library, making very heavy use of advanced OpenGL. I developed this library on a machine that supports through OpenGL 4.2.
There are a number of OpenGL 4 functions (a simple example is glGenerateMipmap) that aren’t core functionality in OpenGL 2, but are available under extensions (in this case, glGenerateMipmapEXT). When running on older hardware, I’ve found, the OpenGL 4 function pointer is NULL, but the OpenGL 2 extension function suffixed with EXT isn’t, and works just fine.
I’m using GLEW. While I realize that occasionally OpenGL 4 functions aren’t identical to OpenGL 2 EXT functions, they most often are identical. Is there a way to make GLEW load the EXT functions as the OpenGL 4 functions? Or am I stuck renaming all the OpenGL 4 functions to their EXT counterparts? Something else?
No, you can’t make GLEW lie to you and pretend an extension function is a core function.
In general, when writing OpenGL code, you pick a specific version + set of extensions and write to that. If you want optional functionality (something hardware-specific), then you write additional codepaths that call those APIs.
With the exception of the MacOSX’s core 3.2 support, you can expect old extensions to be supported indefinitely on new hardware. That way, old programs can still run on newer implementations. So it’s not like you’re going to find a GL 4.x implementation that doesn’t implement GL_EXT_framebuffer_object.