From 81b06b8a08d9b2b30c6a68c311fef97f374f0c6d Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 11 Aug 2009 21:45:32 +0000 Subject: [PATCH] Ensure Wgl core entry points are loaded prior to first use, even without a Wgl context. Do not query actual GraphicsMode.Default in DummyGLContext constructor. Doing so creates a temporary context, which should not be done when creating a dummy context. Fixed issue [#993]: "Possible bug in GraphicsContext.CreateDummyContext()". --- Source/OpenTK/Platform/Dummy/DummyGLContext.cs | 3 ++- Source/OpenTK/Platform/Windows/WglHelper.cs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/Dummy/DummyGLContext.cs b/Source/OpenTK/Platform/Dummy/DummyGLContext.cs index 71312c3d..137a9323 100644 --- a/Source/OpenTK/Platform/Dummy/DummyGLContext.cs +++ b/Source/OpenTK/Platform/Dummy/DummyGLContext.cs @@ -19,7 +19,8 @@ namespace OpenTK.Platform.Dummy /// internal sealed class DummyGLContext : IGraphicsContext, IGraphicsContextInternal { - GraphicsMode format = GraphicsMode.Default; + // This mode is not real. To receive a real mode we'd have to create a temporary context, which is not desirable! + GraphicsMode format = new GraphicsMode(new IntPtr(2), 32, 16, 0, 0, 0, 2, false); bool vsync; ContextHandle handle; static int handle_count; diff --git a/Source/OpenTK/Platform/Windows/WglHelper.cs b/Source/OpenTK/Platform/Windows/WglHelper.cs index 69dba398..30a46e17 100644 --- a/Source/OpenTK/Platform/Windows/WglHelper.cs +++ b/Source/OpenTK/Platform/Windows/WglHelper.cs @@ -24,7 +24,9 @@ namespace OpenTK.Platform.Windows delegatesClass = wglClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic); importsClass = wglClass.GetNestedType("Imports", BindingFlags.Static | BindingFlags.NonPublic); - //LoadAll(); + // Ensure core entry points are ready prior to accessing any method. + // Resolves bug [#993]: "Possible bug in GraphicsContext.CreateDummyContext()" + LoadAll(); } #endregion