Skip to content

Commit

Permalink
Override context creation in GLArea.
Browse files Browse the repository at this point in the history
This allows forward compatible and debug contexts to be created, and
provides more descriptive exceptions in the case where the context
cannot be created with the requested settings.
  • Loading branch information
Nihlus committed Oct 1, 2017
1 parent b1f90c3 commit d3f5a87
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/OpenTK.GLWidget/GLWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ private bool UpdateFrameTime(Widget widget, FrameClock frameClock)
return true;
}


/// <inheritdoc />
protected override GLContext OnCreateContext()
{
var gdkGLContext = Window.CreateGlContext();

GetRequiredVersion(out var major, out var minor);
gdkGLContext.SetRequiredVersion(major, minor);

gdkGLContext.DebugEnabled = GraphicsContextFlags.HasFlag(GraphicsContextFlags.Debug);
gdkGLContext.ForwardCompatible = GraphicsContextFlags.HasFlag(GraphicsContextFlags.ForwardCompatible);

gdkGLContext.Realize();
return gdkGLContext;
}

/// <summary>
/// Destructs this object.
/// </summary>
Expand Down

0 comments on commit d3f5a87

Please sign in to comment.