Added static GetExtensionDelegate implementation
This commit is contained in:
parent
2ace001203
commit
ffe934fa5d
1 changed files with 20 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenTK.Graphics
|
||||
{
|
||||
|
@ -56,5 +57,24 @@ namespace OpenTK.Graphics
|
|||
throw new GraphicsContextMissingException();
|
||||
return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
|
||||
}
|
||||
|
||||
internal static Delegate GetExtensionDelegateStatic(string funcname, Type signature)
|
||||
{
|
||||
var context = GraphicsContext.CurrentContext as IGraphicsContextInternal;
|
||||
if (context == null)
|
||||
throw new GraphicsContextMissingException();
|
||||
|
||||
IntPtr address = context.GetAddress(funcname);
|
||||
if (address == IntPtr.Zero ||
|
||||
address == new IntPtr(1) || // Workaround for buggy nvidia drivers which return
|
||||
address == new IntPtr(2)) // 1 or 2 instead of IntPtr.Zero for some extensions.
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Marshal.GetDelegateForFunctionPointer(address, signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue