I noticed in panda_glext.h that if an extension is already defined, then the new tokens introduced by the extension will not be defined by Panda3D. Same for the typedefs: if GL_GLEXT_PROTOTYPES is defined then they will not be defined.
I don’t have that much experience with GL extensions and I was wondering:
1 - It is 100% safe make these assumptions?
2 - Where and when is defined GL_GLEXT_PROTOTYPES?
panda_glext.h is actually a copy of glext.h, which is provided by the OpenGL consortium. So this is “official” OpenGL code.
The whole point of glext.h is to ensure that all of the known extensions are available to the code at compilation time. It’s possible that some of the extensions have already been defined by the system OpenGL headers, in which case it’s not necessary to redefine them here. But if your system’s OpenGL headers happen to be more out-of-date than Panda’s code, that’s where panda_glext.h takes over and defines them appropriately.
There’s no danger in defining them this way because the extensions are designed not to be redefined once they have been formally encoded. (If they do need to be redefined later, the necessary changes will be introduced as a new and different extension.) So, all headers that define a particular OpenGL extension should define it in exactly the same way.
It’s necessary to define all extensions that Panda3D code attempts to use, or the code won’t compile. However, this has nothing to do with whether the extensions are available at runtime or not. Panda makes the appropriate runtime checks to ensure a particular extension is available before it attempts to make use of it.
Also note that the set of extensions that are provided by the system OpenGL headers isn’t necessarily the same set as the set of extensions that are available at runtime.
Edit: oh, and GL_GLEXT_PROTOTYPES is intended to be defined by user code prior to including this file, if the code wants to define the actual function prototypes for calling the extension functions directly. Panda doesn’t do this, because to do so may force the resulting code to run only with an OpenGL library that actually provides all of the defined extension functions. Instead, Panda uses the standard runtime functions to get a runtime pointer to the extension functions, rather than relying on the linker to link in the reference.
Ah ok, now I understand it better. So, can I update panda_glext.h to a newer glext.h revision in order to have access to GL_EXT_texture_array? I could just edit the current version otherwise. Just let me know what is better.
This is because the set of extensiond depends on my graphics card drivers right? Thus the OpenGL version supported by the system depends entirely on the drivers?
EDIT:
Ah, one more question: glext.h is included also when OPENGLES is defined? I am asking this because I am not sure how to proceed in the glGraphicsStateGuardian: OpenGL ES doesn’t support texture arrays, so should I:
if (_supports_2d_texture_arrays){
#ifndef OPENGLES
... do something with text arrays
#endif
}
if (_supports_2d_texture_arrays){
... do something with text arrays
}