Extensions and .net

hey guys,

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);
glGetInfoLog_Delegate glGetInfoLog;

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 :wink:

any comments/ideas/musings are welcome.

thanks

in C++ you can define similiar system as you wrote using delegates too.
Here is a link
http://www.codeproject.com/cpp/FastDelegate.asp#xx1303337xx

thanks slider666, i’ll give that a good read tonight.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.