I guess I should reply to the rest of the thread as well… The solution I mentioned is of course IL and not C# and would require a post-processing step to inject the IL into your assembly. I agree it’d be nice if you could do it in C# or using inline IL, but neither is available. This doesn’t mean that it can’t be done in a managed fashion as it is supported by IL. So it’s somewhat of an extraneous step, but it can be completely automated and it won’t affect your deployment (e.g. you can just modify your own assembly). I guess I should give a little example:
[CustomIL IL="
ldarg.1 // push foo
ldarg.0 // push extensionPointer
calli unmanaged stdcall void(float32)
ret
"]
public static void glFogCoordfEXT(IntPtr extensionPointer, Single foo) {}
So your application call would look something like:
glFogCoordfEXT(wglGetProcAddress(“glFogCoordfEXT”), 1.0f);
You’d likely want to cache the extension’s pointer however…
That’s off the top of my head, so please excuse… So, the CustomIL attribute is parsed post-build, the IL is injected into the appropriate method for me automagically using an external utility. It’s the closest thing we’ve got to inline IL with the exception of Reflection.Emit…
I’ve yet to find any need to rely on unmanaged components outside of what’s being wrapped. In CsGL there is an unmanaged component that does a number of things, including invoking extensions. If I recall correctly, Lloyd’s parser parsed the extension headers to write the c# that invoked the unmanaged component. In the case of Tao there are no extraneous unmanaged components, everything’s either in C# using P/Invoke, or in the cases of extensions and cdecl delegates injected IL that’s put in by a post-build utility.
In the Whidbey release, IL will be able to be compiled into your assembly, making this ‘hack’ a non-issue. I don’t believe it’ll be inline IL, but you will be able to combine IL compiled with ILASM into your assembly. Hopefully they’ll add cdecl delegates too and that would completely get rid of my post-build event.
Mono is the main alternative .NET platform. Tao has been reported to run under linux (mono), freebsd (mono), and windows (microsoft and mono) using the same code. In these cases the programs were GLUT based, it would be fairly trivial to add GLX support, but I don’t run either linux or freebsd, so it’s not real high on my priority list.
I think that covers about everything…
[This message has been edited by Ridge (edited 06-12-2003).]
[This message has been edited by Ridge (edited 06-12-2003).]