Added loading code for OpenCL entry points.

This commit is contained in:
the_fiddler 2009-08-11 20:16:28 +00:00
parent ea6a4479e5
commit 1df3101a47

View file

@ -1,11 +1,38 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Reflection;
namespace OpenTK.Compute.CL10 namespace OpenTK.Compute.CL10
{ {
/// <summary>
/// Provides access to the OpenCL 1.0 flat API.
/// </summary>
public partial class CL public partial class CL
{ {
#region Private Members
const string Library = "opencl.dll"; const string Library = "opencl.dll";
#endregion
#region Constructors
static CL()
{
Type imports = typeof(CL).GetNestedType("Core", BindingFlags.Static | BindingFlags.NonPublic);
FieldInfo[] delegates = typeof(CL).GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic).GetFields(BindingFlags.Static | BindingFlags.NonPublic);
if (delegates == null || imports == null)
throw new Exception("[Internal Error] Failed to locate CL.Delegates. Please file a bug report at http://www.opentk.com/issues");
for (int i = 0; i < delegates.Length; i++)
{
MethodInfo method = imports.GetMethod(delegates[i].Name.Substring(2), BindingFlags.Static | BindingFlags.NonPublic);
Delegate @new = Delegate.CreateDelegate(delegates[i].FieldType, method);
delegates[i].SetValue(null, @new);
}
}
#endregion
} }
} }