i’ve been tinkering with the tao framework and they seem to go to extraordinary lengths to load extensions (i.e. creating il code stubs for parameter marshaling and method invocation). am i missing something here?
in .net 2.0, you can now simply treat the extension as a delegate and let the marshal class work its magic for you.
for example, if you declare a delegate
delegate void glGetInfoLog_Delegate(int obj, int maxLength, out int length, IntPtr infoLog);
then you can load your extension like so (assuming wglGetProcAddress was imported normally)
IntPtr proc = wglGetProcAddress(“glGetInfoLogARB”);
glGetInfoLog = (glGetInfoLog_Delegate)Marshal.GetDelegateForFunctionPointer(proc, typeof(glGetInfoLog_Delegate));
this is simple, it works, but i’m not sure if it’s a good practice or not. guessing it might be a hair slower than the hand-rolled approach, but that’s no biggie.
i’m mainly wondering if there’s a “better” way to do this without resorting to il stubs
any comments/ideas/musings are welcome.