我使用这里的示例将我的曲面细分回调移动到另一个类.
代码编译,但回调代码永远不会执行.
回调类:
template <class Class, typename ReturnType, typename Parameter>
class SingularCallBack
{
public:
typedef ReturnType (Class::*Method)(Parameter);
SingularCallBack(Class* class_instance, Method method)
: class_instance_(class_instance),
method_(method)
{}
ReturnType operator()(Parameter parameter)
{
return (class_instance_->*method_)(parameter);
}
ReturnType execute(Parameter parameter)
{
return operator()(parameter);
}
private:
Class* class_instance_;
Method method_;
};
Run Code Online (Sandbox Code Playgroud)
回调:
void MyClass::tessBegin(GLenum which)
{
glBegin(which);
cout << "BEGIN CALLBACK IS WORKING";
}
void MyClass::tessVertex(const GLvoid *data)
{
// cast back to double type
const GLdouble *ptr = (const GLdouble*)data;
glVertex3dv(ptr);
cout << …Run Code Online (Sandbox Code Playgroud)