AdrianPi's picture

OpenTK.Graphics.OpenGL.GL.SupportsExtension missing?

I'm porting some code from to

I've found SupportsExtension method missing in OpenTK.Graphics.OpenGL.GL.

Is there a replacement method?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

No, there is no direct replacement. The SupportsExtension method was becoming increasingly difficult to maintain and its implementation suffered from several other issues without simple solutions.

The recommended workaround is to check for extensions using regular OpenGL commands:

// Compatible context (GL 1.0-2.1)
string[] extensions = GL.GetString(StringName.Extensions).Split(' ');
if (extensions.Contains("GL_ARB_foo_bar"))
    // Use it
// Forward compatible context (GL 3.0+)
int extensions;
GL.GetInteger(GetPName.NumExtensions, out extensions);
bool found = false;
while (--extensions > 0 && !found)
    found = GL.GetString(StringName.Extensions, extensions) == "GL_ARB_foo_bar";
if (found)
    // Use it

Note that it is an error to use the first approach in a forward-compatible context.

Edit: renamed num_extensions to extensions.

AdrianPi's picture

thank you!