At runtime, I’d like to ask the system (driver) if some extensions (like GL_EXT_gpu_shader4 or GL_ARB_draw_instanced) are supported before I try to load a shader using those extensions.
I’m almost sure there’s some neat way in Panda to do this from python, but searching the forum and API for ‘extension’ didn’t give me anything useful.
Well, first of all, there is setting “notify-level-glgsg debug” in Config.prc. This should make Panda print out a list of supported extensions.
Many of the extensions available in Panda are exposed via specific getters, such as get_supports_geometry_instancing() for instanced draw.
If you want to query for arbitrary extensions, I don’t think that’s currently available, but it’d just be a matter of marking a function as public. I’ll look into it if you think it would be useful.
I think it would be useful.
There’s still a lot of old hardware and bad drivers out there, and there should be a way to detect if the system can (or at least should) handle a shader other than trying and failing (especially when a miss-compiled shader fails silently and the end user is left with a black screen and no info).
Just call base.win.getGsg().hasExtension(“GL_ARB_draw_instanced”). You should also check getDriverVersionMajor() and getDriverVersionMinor() for whether the OpenGL version is 3.1 or higher, which is when GL_ARB_draw_instanced was promoted to core OpenGL.
You can also check getDriverShaderVersionMajor() and getDriverShaderVersionMinor() to get the available GLSL version.
There is also getSupportsGeometryInstancing(), which returns true if the ARB or EXT extension is available, or if the core OpenGL version is high enough.