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.
This commit is contained in:
Stefanos A. 2013-11-25 00:26:20 +01:00
parent c92c232910
commit e65f206554

View file

@ -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