From e65f206554cc420069be76dfaddb10a2107a8775 Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Mon, 25 Nov 2013 00:26:20 +0100 Subject: [PATCH] Fixed core loading on Windows On Windows, entry points for OpenGL 1.0 and 1.1 are not exposed by wglGetProcAddress. We fall back to LoadLibrary+GetProcAddress when wglProcAddress fails. --- Source/OpenTK/Platform/Windows/WinGLContext.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Platform/Windows/WinGLContext.cs b/Source/OpenTK/Platform/Windows/WinGLContext.cs index 0312c280..73b0eca3 100644 --- a/Source/OpenTK/Platform/Windows/WinGLContext.cs +++ b/Source/OpenTK/Platform/Windows/WinGLContext.cs @@ -338,7 +338,22 @@ namespace OpenTK.Platform.Windows public override IntPtr GetAddress(string function_string) { - return Wgl.Imports.GetProcAddress(function_string); + IntPtr address = Wgl.Imports.GetProcAddress(function_string); + if (!IsValid(address)) + { + address = Functions.GetProcAddress(opengl32Handle, function_string); + } + return address; + } + + static bool IsValid(IntPtr address) + { + unsafe + { + // See https://www.opengl.org/wiki/Load_OpenGL_Functions + void* a = address.ToPointer(); + return a < (void*)-1 || a > (void*)3; + } } #endregion