LoadDelegate() static private method

Creates a System.Delegate that can be used to call an OpenGL function, core or extension.
static private LoadDelegate ( string name, Type signature ) : Delegate
name string The name of the Wgl function (eg. "wglNewList")
signature Type The signature of the OpenGL function.
return Delegate
Esempio n. 1
0
            public override int LoadDelegates()
            {
                loadedExtNames = new System.Collections.Generic.Dictionary <string, bool>();
                int  supported        = 0;
                Type extensions_class = typeof(Wgl.Delegates);

                //get all fields
                FieldInfo[] delegates = extensions_class.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                //
                if (delegates == null)
                {
                    throw new InvalidOperationException("The specified type does not have any loadable extensions.");
                }
                //
                foreach (FieldInfo f in delegates)
                {
                    //so... this field name must be preserved!
                    Delegate d = Wgl.LoadDelegate(f.Name, f.FieldType);
                    if (d != null)
                    {
                        loadedExtNames.Add(f.Name, true);
                        ++supported;
                    }
                    f.SetValue(null, d);
                }
                Wgl.rebuildExtensionList = true;

                return(supported);
            }