Added a realize callback for setting up the pbuffer so that it definately
has a valid graphics context.
This commit is contained in:
parent
c269cc88b2
commit
dac86dabb5
@ -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 <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
|
||||
out << std::endl;
|
||||
out <<"options:"<< std::endl;
|
||||
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
|
||||
out <<" i.e. -l osgdb_pfb"<< std::endl;
|
||||
out <<" Useful for loading reader/writers which can load"<< std::endl;
|
||||
out <<" other file formats in addition to its extension."<< std::endl;
|
||||
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
|
||||
out <<" i.e. -e pfb"<< std::endl;
|
||||
out <<" Useful short hand for specifying full library name as"<< std::endl;
|
||||
out <<" done with -l above, as it automatically expands to"<< std::endl;
|
||||
out <<" the full library name appropriate for each platform."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
|
||||
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
|
||||
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
|
||||
out <<" further details on setting up accurate stereo "<< std::endl;
|
||||
out <<" for your system. "<< std::endl;
|
||||
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
|
||||
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
|
||||
out <<" also allows the depth complexity statistics mode"<< std::endl;
|
||||
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
|
||||
out << std::endl;
|
||||
}
|
||||
public:
|
||||
InitializePbufferCallback() {}
|
||||
|
||||
virtual void operator()( osgProducer::OsgCameraGroup&, osgProducer::OsgSceneHandler& sh, const Producer::RenderSurface& )
|
||||
{
|
||||
if (!g_pPixelBuffer)
|
||||
{
|
||||
g_pPixelBuffer = new PBuffer(512,512);
|
||||
g_pPixelBuffer->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.
|
||||
|
Loading…
Reference in New Issue
Block a user