
On 6/30/06, Stephen Torri
I have a main file from my OpenGL program which contains global variables and the functions that are used by OpenGL as callback functions. For example:
int a; float b;
void display () { .... display code calls ... }
int main (int argc, char **argv) { glutDisplayFunc( display ); }
Now I thought I would put all the variables and functions into a class and use that in the main. Here is where I am getting stuck on the use of boost::function. I changed the code to look something like the following:
class MyMain { int a; float b;
void display() { ... display code calls ... } }
int main (int argc, char **argv) { MyMain m_ref; boost::function
disp_func = boost::bind ( &MyMain::display, &m_ref ); glutDisplayFunc ( disp_func ); } What I am getting back from the g++ compiler is the following error message:
error: cannot convert `boost::function
' to `void (*)()' for argument `1' to `void glutDisplayFunc(void (*)())' Any ideas where I am going wrong?
You are passing a function object to a C function which expects a function pointer. A boost::function can not be converted into a function pointer.
Stephen
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org