Re: C++ Draw Callback?

New Message Reply Date view Thread view Subject view Author view

Martin Reddy (mxr++at++dcs.ed.ac.uk)
Thu, 28 Nov 1996 11:17:31 +0000 (GMT)


> I'd like to have a C++ method as the callback function, set by
> pfChannel->setTravFunc(). I've tried lots of different ways to
> code this, but the compiler always seems to have trouble with
> the function pointer (2nd argument) being an Object method.

You can either write a simple function wrapper that uses a global variable
to remember the object and call its member function, then use this wrapper
as the callback; or, perhaps more elegantly, your callback should be
defined as a static member function of the object, e.g.

class MyClass {
public:
  static void DrawChannel( pfChannel *chan, void *data );
};

void MyClass::DrawChannel( pfChannel *chan, void *data )
{
   // your Draw call back code here
}

....

    chan->setTravFunc( PFTRAV_DRAW, MyClass::DrawChannel );
....

Martin.

+============================================================================+
| Martin Reddy Dept. of Computer Science |
| University of Edinburgh |
| e-mail : M.Reddy++at++ed.ac.uk Mayfield Road, EH9 3JZ |
| http://www.dcs.ed.ac.uk/~mxr/ Tel : +44 131 650 5164 |
+============================================================================+

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:02 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.