namespace WPFOpenGLLib { public ref class OpenGLUserControl : public UserControl { .... delegate void MyDel(); // Funktion soll von glutIdleFunc aufgerufen werden void anim() { OnIdle(); } .... MyDel ^ StaticDelInst = gcnew MyDel(this, &WPFOpenGLLib::OpenGLUserControl::anim); IntPtr myPtr = System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(StaticDelInst); glutIdleFunc(myPtr); };}
MyDel ^ StaticDelInst = gcnew MyDel(this, &WPFOpenGLLib::OpenGLUserControl::anim);pin_ptr<MyDel^> myPinPtr= &StaticDelInst;
glutIdleFunc((void)myPtr.ToPointer());
MyDel^ StaticDelInst = gcnew MyDel(this, &WPFOpenGLLib::OpenGLUserControl::anim);pin_ptr<MyDel^> myPinPtr = &StaticDelInst;IntPtr myPtr = System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(StaticDelInst);glutIdleFunc((void (__cdecl *)(void))myPtr.ToPointer());