|
Boost Users : |
From: Nicholas Yue (yue.nicholas_at_[hidden])
Date: 2007-08-15 21:19:11
Hi,
I am attempting to use Boost bind and function to help me pass a member
function as a function pointer to the GLUT C-library.
I have difficulty understanding the usage of bind and function in the
Boost library. When I attempt to pass what I thought was a function pointer,
the compiler indicated that it is actually not a function pointer.
class MyGlut {
public:
MyGlut();
virtual ~MyGlut();
void loop(int argc, char **argv);
void draw(void);
void displayFunc(boost::function<void()> func);
private:
boost::function<void()> display_callback;
};
void MyGlut::displayFunc(boost::function<void()> func)
{
glutDisplayFunc(func); // ERROR IN COMPILATION
}
void MyGlut::loop(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH |
GLUT_MULTISAMPLE);
glutCreateWindow("Hello World");
//glutDisplayFunc(redraw); // Original way to pass C-function pointer
displayFunc( boost::bind(&MyGlut::draw, *this) );
}
Regards
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net