From d3f5a87809676c50e325193029ec7cd91a49d7bf Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Sun, 1 Oct 2017 20:11:58 +0200 Subject: [PATCH] Override context creation in GLArea. 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. --- src/OpenTK.GLWidget/GLWidget.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/OpenTK.GLWidget/GLWidget.cs b/src/OpenTK.GLWidget/GLWidget.cs index 54b6bd78..afe0ffe7 100644 --- a/src/OpenTK.GLWidget/GLWidget.cs +++ b/src/OpenTK.GLWidget/GLWidget.cs @@ -109,6 +109,22 @@ namespace OpenTK return true; } + + /// + 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; + } + /// /// Destructs this object. ///