Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. A simple function pointer question...

A simple function pointer question...

Scheduled Pinned Locked Moved C#
questioncomgraphicsgame-devhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi I'm havinh real trouble using this one OpenGL function I'm trying to import into my app. The C function is declared as this:- void gluTessCallback(GLUtesselator* obj, GLenum type, void(*fn)()); I know that GLUtesselator* is basically just an IntPtr, as I've imported other functions with it in, and they've worked fine. Similarly, GLenum is just a UInt. But what do I do with the void function pointer? I have declared delegates for all of the possible function types it could be, (depending on the 'type' variable), but I don't know where to go from there. MSDN only has info for function pointers that are always a set type, but with this function, the pointer can be to a number of different types of function. Please help me out here! Thanks in advance Dave Dave Kerr focus_business@hotmail.com www.focus.esmartweb.com

    B S 2 Replies Last reply
    0
    • L Lost User

      Hi I'm havinh real trouble using this one OpenGL function I'm trying to import into my app. The C function is declared as this:- void gluTessCallback(GLUtesselator* obj, GLenum type, void(*fn)()); I know that GLUtesselator* is basically just an IntPtr, as I've imported other functions with it in, and they've worked fine. Similarly, GLenum is just a UInt. But what do I do with the void function pointer? I have declared delegates for all of the possible function types it could be, (depending on the 'type' variable), but I don't know where to go from there. MSDN only has info for function pointers that are always a set type, but with this function, the pointer can be to a number of different types of function. Please help me out here! Thanks in advance Dave Dave Kerr focus_business@hotmail.com www.focus.esmartweb.com

      B Offline
      B Offline
      beetung
      wrote on last edited by
      #2

      Dave Kerr wrote: declared as this:- void gluTessCallback(GLUtesselator* obj, GLenum type, void(*fn)()); .... I don't know where to go from there. Is C# really that much different from C++??//declaring three variables GLUtesselator* gPtr =...; GLenum gType =...; void(* gFuncPtr )(void); gFuncPtr = ...; // call the function gluTessCallback(gPtr, gType, gFuncPtr);
      wont compile under C#??

      1 Reply Last reply
      0
      • L Lost User

        Hi I'm havinh real trouble using this one OpenGL function I'm trying to import into my app. The C function is declared as this:- void gluTessCallback(GLUtesselator* obj, GLenum type, void(*fn)()); I know that GLUtesselator* is basically just an IntPtr, as I've imported other functions with it in, and they've worked fine. Similarly, GLenum is just a UInt. But what do I do with the void function pointer? I have declared delegates for all of the possible function types it could be, (depending on the 'type' variable), but I don't know where to go from there. MSDN only has info for function pointers that are always a set type, but with this function, the pointer can be to a number of different types of function. Please help me out here! Thanks in advance Dave Dave Kerr focus_business@hotmail.com www.focus.esmartweb.com

        S Offline
        S Offline
        Stephane Rodriguez
        wrote on last edited by
        #3

        Did you give a look at this[^] ? To ease the marshaller's job, you may also add this attribute : [MarshalAs(UnmanagedType.FunctionPtr)]


        Back to real work : D-21.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups