Laar's picture

OpenGl.GL.SupportsExtension

OpenGl.GL.SupportsExtension is mentioned in the refference, but it doesn't exist (anymore). Is there a reason why it has been removed? Also GL.SupportsFunction doesn't exist anymore.

Thoufh both functions do exist in the OpenTk.Graphics.GL class.


Comments

Comment viewing options

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

The problem was that OpenGL 3.x changed the way to query extensions. Instead of using hacks to guess which OpenGL profile is being used (2.1, 3.0/3.1 compatible/forward-compatible, 3.2 core/compatibility), it's easier to move this to user code which already knows what version is being used. For example, if you are using 1.1-2.1 or 3.x compatibility, you can use GL.GetString(StringName.Extensions).Contains("foo"). For 3.x core, you'll have to iterate through available extensions using GL.GetString(StringName.Extensions, i).

GL.SupportsFunction cannot be supported cleanly now that it is possible to create multiple OpenGL contexts (that wasn't a consideration when the function was first introduced). Right now, the same functionality can be achieved with this extension method:

static class GraphicsContextExtensions
{
    public static bool SupportsFunction(this IGraphicsContextInternal context)
    {
        if (context == null)
            throw new ArgumentNullException("context");
        return context.GetAddress("foo") != IntPtr.Zero;
    }
}

but I think this should be added directly to IGraphicsContext.