Boost logo

Boost Users :

From: Baranowski, Daniel (dbaranowski_at_[hidden])
Date: 2006-06-30 16:04:29


[snip]
> 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<void()> disp_func = boost::bind (
> &MyMain::display, &m_ref );
> glutDisplayFunc ( disp_func );
> }
[snip]

Maybe you could leave the display function as it was before, have OpenGL
call that function, and then have Display call disp_func().

Something like this (though I haven't actually tried it):

        typedef boost::function<void()> DisplayFuncType;
        DisplayFuncType CurrentDisplayObject;

        class MyMain {
                int a;
                float b;

                void display()
                {
                        ... display code calls ...
                }
        }

        void display ()
        {
                if(!CurrentDisplayObject.empty())
                   CurrentDisplayObject();
        }

        int main (int argc, char **argv)
        {
                MyMain m_ref;
                CurrentDisplayObject = boost::bind ( &MyMain::display,
&m_ref );
                glutDisplayFunc (display);
        }

Let me know if that works out for you! I'd be interested to know. I
think that's a good idea, BTW.

Daniel
**********************************************************************************************
Disclaimer - This email and any files transmitted with it are proprietary and may contain privileged or copyright information. You must not present this message to another party without
gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify
us. If you have received this message in error, please notify the sender immediately, and delete this email from your system. We do not guarantee that this material is free from viruses or any
other defects although due care has been taken to minimize the risk. eSafe scanned this email for viruses, vandals and malicious contentAny views expressed in this message are those of
the individual sender, except where the sender specifically states them to be the views of LSI.
**********************************************************************************************


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