From 456d7cde37b3a62b28dec1b526f5c765af691613 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Fri, 15 Sep 2017 11:51:11 +0200 Subject: [PATCH] Initialize an OpenTK::GraphicsContext from the foreign GDK context. --- src/OpenTK.GLWidget/GLWidget.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/OpenTK.GLWidget/GLWidget.cs b/src/OpenTK.GLWidget/GLWidget.cs index 53d31897..db1833e0 100644 --- a/src/OpenTK.GLWidget/GLWidget.cs +++ b/src/OpenTK.GLWidget/GLWidget.cs @@ -386,9 +386,14 @@ namespace OpenTK _WindowInfo = XWindowInfoInitializer.Initialize(graphicsMode, this.Display.Handle, this.Screen.Number, widgetWindowHandle, this.Screen.RootWindow.Handle); } - // GraphicsContext + // Make the GDK GL context current + Context.MakeCurrent(); - _GraphicsContext = new GraphicsContext(graphicsMode, _WindowInfo, GlVersionMajor, GlVersionMinor, GraphicsContextFlags); + // Create an OpenTK graphics context using the GdkGLContext as a foreign context + // Since the GDK context is already created and has been made current, we can retrieve its handle. + var gdkContextHandle = Factory.Default.CreateGetCurrentGraphicsContext()(); + + _GraphicsContext = new GraphicsContext(gdkContextHandle, _WindowInfo, null, GlVersionMajor, GlVersionMinor, GraphicsContextFlags); _GraphicsContext.MakeCurrent(_WindowInfo); if (GraphicsContext.ShareContexts)