#extension mechanism, query if extension is available?

Is there any built-in way to query if an extension is available inside a shader?

So you could do something like:


        #if GL_EXT_gpu_shader4
            #extension GL_EXT_gpu_shader4 : enable
        #endif

Or is the only option for the application to query the extension and pass the information to the shader somehow?

You can do exactly that.

Great, thanks!

I see now in the the spec for gpu_shader4 it says:

“A new preprocessor #define is added to the OpenGL Shading Language:
#define GL_EXT_gpu_shader4 1”

So this isn’t something that’s necessarily going to be the case for every extension? I couldn’t find any mention of it in the GLSL spec.

Yes, all extensions have a preprocessor #define.

And yes, that’s not discussed in the GLSL spec as the GLSL spec discusses only core features (i.e. ones that are part of the core spec, thus they don’t have to be explicitly enabled).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.