I have a new patch that is compatible with older and newer versions of
OpenGL, compatibility and core profile. Some notes:
The code has two branches, one for < GL 3.0, and one for GL 3.0+. We
determine which branch to choose at runtime, because we don't know what
GL version the end user will be linking against. We can't call
glGetStringi directly because it is only available in GL 3.0+, so we use
glXGetProcAddressARB to acquire the address of glGetStringi and to see
if it is available. It will be available if the user links against a GL
library that is 3.0+, but will not work if the context is < 3.0,
therefore we also check the running GL version. I made sure the program
doesn't crash if any GL functions return a NULL pointer, even when
they shouldn't according to current specs. This patch no longer needs
the GL_GLEXT_PROTOTYPES definition.