From ec2c64ee15f2f1ec5a0fe11a63e60fb0fbf5a7c0 Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Fri, 8 Nov 2013 10:41:58 +0100 Subject: [PATCH] Remove static init of GetCurrentContext The static initializer of GetCurrentContext would always default to the desktop PlatformFactory, which caused problems when trying to run OpenGL ES code on the desktop. The initializer is now removed and GetCurrentContext is set in the context constructor, before creating any contexts. --- Source/OpenTK/Graphics/GraphicsContext.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/OpenTK/Graphics/GraphicsContext.cs b/Source/OpenTK/Graphics/GraphicsContext.cs index c9c57432..bcd9dc49 100644 --- a/Source/OpenTK/Graphics/GraphicsContext.cs +++ b/Source/OpenTK/Graphics/GraphicsContext.cs @@ -131,7 +131,6 @@ namespace OpenTK.Graphics case true: factory = Factory.Embedded; break; } - implementation = factory.CreateGLContext(mode, window, shareContext, direct_rendering, major, minor, flags); // Note: this approach does not allow us to mix native and EGL contexts in the same process. // This should not be a problem, as this use-case is not interesting for regular applications. // Note 2: some platforms may not support a direct way of getting the current context @@ -140,12 +139,10 @@ namespace OpenTK.Graphics // declaration). if (GetCurrentContext == null) { - GetCurrentContextDelegate temp = factory.CreateGetCurrentGraphicsContext(); - if (temp != null) - { - GetCurrentContext = temp; - } + GetCurrentContext = factory.CreateGetCurrentGraphicsContext(); } + + implementation = factory.CreateGLContext(mode, window, shareContext, direct_rendering, major, minor, flags); } available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); @@ -321,8 +318,7 @@ namespace OpenTK.Graphics #region public static IGraphicsContext CurrentContext internal delegate ContextHandle GetCurrentContextDelegate(); - internal static GetCurrentContextDelegate GetCurrentContext = - Platform.Factory.Default.CreateGetCurrentGraphicsContext(); + internal static GetCurrentContextDelegate GetCurrentContext; /// /// Gets the GraphicsContext that is current in the calling thread.