Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: extensions and .net

  1. #1
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    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.GetDelegateForFunct ionPointer(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.

    thanks

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2005
    Location
    Lithuania
    Posts
    2

    Re: extensions and .net

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

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: extensions and .net

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •