Search code examples
c#.netopenglopentk

How to set OpenGL API version in OpenTK .NET Core?


How to set OpenGl version in OpenTk 4.6.4 using .NET Core 5.0 using NativeWindowSettings class? and how to implement it correctly in this code

var nativeWindowSettings = new NativeWindowSettings
        {
            Size = new Vector2i(width, height),
            Title = title,
            API = ContextAPI.OpenGL,
            Profile = ContextProfile.Core,
            // APIVersion = ??
        };

Solution

  • You can set the APIVersion property (see also OpenTK_hello_triangle. e.g.:

    var nativeWindowSettings = new NativeWindowSettings()
    {
        // [...]
    
        APIVersion = new System.Version(4, 6)
    };