Bernard Leclerc (bleclerc++at++cae.ca)
Thu, 28 Nov 1996 09:49:11 -0500
> I'd like to have a C++ method as the callback function, set by
> pfChannel->setTravFunc().
Martin Reddy wrote:
> [...] 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 );
> };
>
> ....
> chan->setTravFunc( PFTRAV_DRAW, MyClass::DrawChannel );
> ....
Martin's suggestion should be extended a little more by deriving a new
class from pfChannel. In order to obtain a virtual draw function, I'm
using a class similar to this:
class myChannel: public pfChannel {
public:
myChannel(pfPipe*);
virtual void draw() { clear(); pfDraw(); }
private:
static void drawCallback(pfChannel*, void*);
};
myChannel::myChannel(pfPipe* p) : pfChannel(p)
{
setTravFunc( PFTRAV_DRAW, drawCallback );
}
void myChannel::drawCallback(pfChannel* chan, void*)
{
((myChannel*) chan)->draw();
}
With a class like this one, "new myChannel" will automatically create a
pfChannel and assign it a DRAW callback which, in fact, is a virtual C++
method. Remember to use chanData (or a pfCycleBuffer) to maintain frame
accurate data in all stages (APP, CULL and DRAW).
Is this what you were looking for Jan?
-- Bernard Leclerc CAE Electronics Ltd., 8585 Cote De Liesse Technical Leader Saint-Laurent, Quebec, Canada, H4L-4X4 3-D Graphics Applications tel: +1 514 341 2000 extension 2275 bleclerc++at++cae.ca fax: +1 514 340 5496======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:02 PDT