From 42fdd873ff46bebba40e73e0b65a6ce9441b90d4 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sat, 9 Oct 2010 18:53:20 +0000 Subject: [PATCH] Set the correct, platform-specific GetCurrentContext implementation on startup. Ensures the correct function of dummy contexts. --- Source/OpenTK/Graphics/GraphicsContext.cs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/Source/OpenTK/Graphics/GraphicsContext.cs b/Source/OpenTK/Graphics/GraphicsContext.cs index 65eb4f2d..54b859d5 100644 --- a/Source/OpenTK/Graphics/GraphicsContext.cs +++ b/Source/OpenTK/Graphics/GraphicsContext.cs @@ -269,24 +269,8 @@ namespace OpenTK.Graphics #region public static IGraphicsContext CurrentContext internal delegate ContextHandle GetCurrentContextDelegate(); - internal static GetCurrentContextDelegate GetCurrentContext = delegate - { - // Note: this is a slow, generic fallback for use with DummyGLContext. - // Most other platforms can query the current context directly (via - // [Wgl|Glx|Agl|Egl].GetCurrentContext()) so the GraphicsContext - // constructor will replace this implementation with a platform-specific - // one, if it exists. - foreach (WeakReference weak_ref in available_contexts.Values) - { - IGraphicsContext context = (IGraphicsContext)weak_ref.Target; - if (context.IsCurrent) - { - return (context as IGraphicsContextInternal).Context; - } - } - - return ContextHandle.Zero; - }; + internal static GetCurrentContextDelegate GetCurrentContext = + Platform.Factory.Default.CreateGetCurrentGraphicsContext(); /// /// Gets the GraphicsContext that is current in the calling thread.