From 770b697583000d17e175f17b85919e1693243cfa Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Tue, 21 Jan 2014 09:04:27 +0100 Subject: [PATCH] [Win] Clear extension list on reload --- Source/OpenTK/Platform/Windows/WglHelper.cs | 45 ++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/Source/OpenTK/Platform/Windows/WglHelper.cs b/Source/OpenTK/Platform/Windows/WglHelper.cs index 1f49dd62..d342a473 100644 --- a/Source/OpenTK/Platform/Windows/WglHelper.cs +++ b/Source/OpenTK/Platform/Windows/WglHelper.cs @@ -48,25 +48,28 @@ namespace OpenTK.Platform.Windows /// True if the extension is supported by the given context, false otherwise public static bool SupportsExtension(IntPtr dc, string name) { - if (extensions.Count == 0) + lock (sync) { - // We cache this locally, as another thread might create a context which doesn't support this method. - // The design is far from ideal, but there's no good solution to this issue as long as we are using - // static WGL/GL classes. Fortunately, this issue is extremely unlikely to arise in practice, as you'd - // have to create one accelerated and one non-accelerated context in the same application, with the - // non-accelerated context coming second. - bool get_arb = SupportsFunction("wglGetExtensionsStringARB"); - bool get_ext = SupportsFunction("wglGetExtensionsStringEXT"); - string str = - get_arb ? Arb.GetExtensionsString(dc) : - get_ext ? Ext.GetExtensionsString() : - String.Empty; - - if (!String.IsNullOrEmpty(str)) + if (extensions.Count == 0) { - foreach (string ext in str.Split(' ')) + // We cache this locally, as another thread might create a context which doesn't support this method. + // The design is far from ideal, but there's no good solution to this issue as long as we are using + // static WGL/GL classes. Fortunately, this issue is extremely unlikely to arise in practice, as you'd + // have to create one accelerated and one non-accelerated context in the same application, with the + // non-accelerated context coming second. + bool get_arb = SupportsFunction("wglGetExtensionsStringARB"); + bool get_ext = SupportsFunction("wglGetExtensionsStringEXT"); + string str = + get_arb ? Arb.GetExtensionsString(dc) : + get_ext ? Ext.GetExtensionsString() : + String.Empty; + + if (!String.IsNullOrEmpty(str)) { - extensions.Add(ext, true); + foreach (string ext in str.Split(' ')) + { + extensions.Add(ext, true); + } } } } @@ -132,11 +135,15 @@ namespace OpenTK.Platform.Windows internal override void LoadEntryPoints() { - if (Wgl.GetCurrentContext() != IntPtr.Zero) + lock (SyncRoot) { - for (int i = 0; i < EntryPointsInstance.Length; i++) + if (Wgl.GetCurrentContext() != IntPtr.Zero) { - EntryPointsInstance[i] = GetAddress(EntryPointNamesInstance[i]); + for (int i = 0; i < EntryPointsInstance.Length; i++) + { + EntryPointsInstance[i] = GetAddress(EntryPointNamesInstance[i]); + } + extensions.Clear(); } } }