From dac86dabb599ee8afb1e681487078e1cdbc3def1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 18 Apr 2003 08:17:18 +0000 Subject: [PATCH] Added a realize callback for setting up the pbuffer so that it definately has a valid graphics context. --- examples/osgpbuffer/osgpbuffer.cpp | 52 ++++++++++++------------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/examples/osgpbuffer/osgpbuffer.cpp b/examples/osgpbuffer/osgpbuffer.cpp index 95f10346e..79e06a550 100644 --- a/examples/osgpbuffer/osgpbuffer.cpp +++ b/examples/osgpbuffer/osgpbuffer.cpp @@ -548,36 +548,24 @@ texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP); return parent; } -void write_usage(std::ostream& out,const std::string& name) +class InitializePbufferCallback : public osgProducer::OsgCameraGroup::RealizeCallback { - out << std::endl; - out <<"usage:"<< std::endl; - out <<" "<initialize(); + } + + // now safe to continue + sh.init(); + } + +}; int main( int argc, char **argv ) { @@ -647,12 +635,12 @@ int main( int argc, char **argv ) // set the scene to render viewer.setSceneData(rootNode); + // use a realize callback to create and initialize the PBuffer to ensure it has a valid graphics context. + viewer.setRealizeCallback(new InitializePbufferCallback()); + // create the windows and run the threads. viewer.realize(); - g_pPixelBuffer = new PBuffer(512,512); - g_pPixelBuffer->initialize(); - while( !viewer.done() ) { // wait for all cull and draw threads to complete.