4
$\begingroup$

When using the GLAD web service, I am allowed to pick any version of OpenGL and any extensions I want.

If I pick the latest version of OpenGL and "all extensions", will the header file returned by the Web Service #define extensions on my machine that I do not actually have or does it just define those that exist?

In other words, if I include the GL_ARB_SHADER_CLOCK extension, on GLAD, does it get defined even if not available on the machine I use?

I don't see how it could be selectively defining extensions because the script is generated on a server ahead of time but I want to make sure that I am not trying to use unsupported extensions.

$\endgroup$

2 Answers 2

7
$\begingroup$

In this github issue the GLAD author offers the following way to correctly check if there is an extension is available at runtime:

The defines just allow you to check at compile time which extensions (and opengl versions) are potentially available. After loading/initilaizing glad you can check with GLAD_ if the extension is available at runtime (= supported by the driver and loaded).

// [initialize glad] // ...
if (!GLAD_GL_EXT_memory_object) {
    die("GL_EXT_memory_object not supported!"); 
}
$\endgroup$
0
1
$\begingroup$

The "all" extensions option means exactly what it says: all extensions. If it exists, then its in the generated header. But this doesn't mean that the code will fail to execute on an implementation that doesn't provide every extension. The extensions you select are merely what the generated files make available to you.

But of course, the whole point of selecting specific extensions is that you don't have stuff you don't use cluttering up your header. If you're going to select everything, you may as well be using GLEW.

$\endgroup$
2
  • $\begingroup$ So, the only reason not to include all extensions, is that you have a smaller header file generated from glad? $\endgroup$
    – Startec
    Nov 9, 2017 at 9:04
  • 2
    $\begingroup$ @Startec: It's not just a smaller header. It means that you can't accidentally use extensions that you don't want to. It also means that you get better IntelliSense, since you're only going to see functions and enums that you want to be able to use. $\endgroup$ Nov 9, 2017 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.