From 742e70e3efad2a000abf0aee0b036e05d931a342 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 20 Apr 2008 17:47:26 +0000 Subject: [PATCH] Fixed a missing call to Debug.Unindent() during context construction. --- Source/OpenTK/Graphics/GraphicsContext.cs | 55 +++++++++++++---------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/Source/OpenTK/Graphics/GraphicsContext.cs b/Source/OpenTK/Graphics/GraphicsContext.cs index 352e2d87..01f5d5c1 100644 --- a/Source/OpenTK/Graphics/GraphicsContext.cs +++ b/Source/OpenTK/Graphics/GraphicsContext.cs @@ -57,38 +57,45 @@ namespace OpenTK.Graphics else if (window == null) throw new ArgumentNullException("window", "Must point to a valid window."); Debug.Print("Creating GraphicsContext."); - Debug.Indent(); - Debug.Print("GraphicsMode: {0}", mode); - Debug.Print("IWindowInfo: {0}", window); - - IGraphicsContext shareContext = null; - if (GraphicsContext.ShareContexts) + try { - lock (context_lock) + Debug.Indent(); + Debug.Print("GraphicsMode: {0}", mode); + Debug.Print("IWindowInfo: {0}", window); + + IGraphicsContext shareContext = null; + if (GraphicsContext.ShareContexts) { - // A small hack to create a shared context with the first available context. - foreach (WeakReference r in GraphicsContext.available_contexts.Values) + lock (context_lock) { - shareContext = (IGraphicsContext)r.Target; - break; + // A small hack to create a shared context with the first available context. + foreach (WeakReference r in GraphicsContext.available_contexts.Values) + { + shareContext = (IGraphicsContext)r.Target; + break; + } } } + + if (designMode) + implementation = new OpenTK.Platform.DummyGLContext(mode); + else if (Configuration.RunningOnWindows) + implementation = new OpenTK.Platform.Windows.WinGLContext(mode, window, shareContext); + else if (Configuration.RunningOnX11) + implementation = new OpenTK.Platform.X11.X11GLContext(mode, window, shareContext, DirectRendering); + else + throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information."); + + lock (context_lock) + { + available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); + } + //(implementation as IGraphicsContextInternal).LoadAll(); } - - if (designMode) - implementation = new OpenTK.Platform.DummyGLContext(mode); - else if (Configuration.RunningOnWindows) - implementation = new OpenTK.Platform.Windows.WinGLContext(mode, window, shareContext); - else if (Configuration.RunningOnX11) - implementation = new OpenTK.Platform.X11.X11GLContext(mode, window, shareContext, DirectRendering); - else - throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information."); - - lock (context_lock) + finally { - available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); + Debug.Unindent(); } - //(implementation as IGraphicsContextInternal).LoadAll(); } #endregion