Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

it works with a class, it just needs some work with the indirection:

namespace mylib {
class MyClass
{
public:
  MyClass();
private:
  // note static, this-ptr cames per userdata
  static void openGlDrawCallbackFunc(void* userdata); 

  void realdraw(); // can call class data
};
}

namespace mylib {

MyClass::MyClass()
{
  // it needs a static callback function, and to save the instance pointer for later use:
  cv::setOpenGlDrawCallback("window", openGlDrawCallbackFunc, this); 
}

void MyClass::openGlDrawCallbackFunc(void* userdata)
{
   // we get back, what we passed in above,just cast it back:
   MyClass * ptr = static_cast<MyClass*>(userdata);
   ptr->realdraw();
}
void MyClass::realdraw()
{
}

}