Updates to osgProducer to bring it up to speed with changes in Producer

This commit is contained in:
Don BURNS 2006-03-29 23:32:51 +00:00
parent e7a4ad287b
commit a5d12c598a
5 changed files with 30 additions and 15 deletions

View File

@ -14,6 +14,8 @@
#include <osgProducer/Viewer>
#include <osg/CoordinateSystemNode>
#include <osgUtil/SceneView>
int main( int argc, char **argv )
{
@ -102,6 +104,16 @@ int main( int argc, char **argv )
// create the windows and run the threads.
viewer.realize();
{
osgProducer::OsgSceneHandler *sh = viewer.getSceneHandlerList().front().get();
osgUtil::SceneView *sv = sh->getSceneView();
osg::CullStack::CullingMode cullingMode = sv->getCullingMode();
cullingMode &= ~(osg::CullStack::SMALL_FEATURE_CULLING);
sv->setCullingMode( cullingMode );
}
while( !viewer.done() )
{
// wait for all cull and draw threads to complete.

View File

@ -36,7 +36,7 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
{
public :
typedef Producer::CameraGroup::ThreadingModel ThreadingModel;
typedef Producer::CameraGroup::ThreadModel ThreadingModel;
OsgCameraGroup();

View File

@ -22,6 +22,7 @@
#include <osgDB/FileUtils>
#include <osgProducer/OsgCameraGroup>
#include <Producer/CameraConfig>
#ifdef WIN32
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
@ -226,14 +227,14 @@ void OsgCameraGroup::_init()
if (_cfg.valid())
{
// By default select ThreadPerCamera when we have multiple cameras.
_thread_model = (_cfg->getNumberOfCameras()>1) ? ThreadPerCamera : SingleThreaded;
_threadModel = (_cfg->getNumberOfCameras()>1) ? ThreadPerCamera : SingleThreaded;
}
const char* str = getenv("OSG_CAMERA_THREADING");
if (str)
{
if (strcmp(str,"SingleThreaded")==0) _thread_model = SingleThreaded;
else if (strcmp(str,"ThreadPerCamera")==0) _thread_model = ThreadPerCamera;
if (strcmp(str,"SingleThreaded")==0) _threadModel = SingleThreaded;
else if (strcmp(str,"ThreadPerCamera")==0) _threadModel = ThreadPerCamera;
}
str = getenv("OSG_SHARE_GRAPHICS_CONTEXTS");
@ -243,7 +244,7 @@ void OsgCameraGroup::_init()
else if (strcmp(str,"OFF")==0) Producer::RenderSurface::shareAllGLContexts(false);
}
if (_thread_model==ThreadPerCamera && _cfg->getNumberOfCameras()>1)
if (_threadModel==ThreadPerCamera && _cfg->getNumberOfCameras()>1)
{
// switch on thread safe reference counting by default when running multi-threaded.
// osg::Referenced::setThreadSafeReferenceCounting(true);
@ -390,7 +391,7 @@ void OsgCameraGroup::advance()
bool OsgCameraGroup::realize( ThreadingModel thread_model )
{
if( _realized ) return _realized;
_thread_model = thread_model;
_threadModel = thread_model;
return realize();
}
@ -595,7 +596,7 @@ bool OsgCameraGroup::realize()
// if we are multi-threaded check to see if particle exists in the scene
// if so we need to disable multi-threading of cameras.
if (_thread_model == Producer::CameraGroup::ThreadPerCamera)
if (_threadModel == Producer::CameraGroup::ThreadPerCamera)
{
if (getTopMostSceneData())
{
@ -605,7 +606,7 @@ bool OsgCameraGroup::realize()
{
osg::notify(osg::INFO)<<"Warning: disabling multi-threading of cull and draw"<<std::endl;
osg::notify(osg::INFO)<<" to avoid threading problems in osgParticle."<<std::endl;
_thread_model = Producer::CameraGroup::SingleThreaded;
_threadModel = Producer::CameraGroup::SingleThreaded;
}
}
@ -614,7 +615,7 @@ bool OsgCameraGroup::realize()
// if we are still multi-thread check to make sure that no render surfaces
// are shared and don't use shared contexts, if they do we need to
// disable multi-threading of cameras.
if (_thread_model == Producer::CameraGroup::ThreadPerCamera)
if (_threadModel == Producer::CameraGroup::ThreadPerCamera)
{
std::set<RenderSurface*> renderSurfaceSet;
for( unsigned int i = 0; i < _cfg->getNumberOfCameras(); i++ )
@ -628,7 +629,7 @@ bool OsgCameraGroup::realize()
// running single threaded, to avoid OpenGL threading issues.
osg::notify(osg::INFO)<<"Warning: disabling multi-threading of cull and draw to avoid"<<std::endl;
osg::notify(osg::INFO)<<" threading problems when camera's share a RenderSurface."<<std::endl;
_thread_model = Producer::CameraGroup::SingleThreaded;
_threadModel = Producer::CameraGroup::SingleThreaded;
}
else if (renderSurfaceSet.size()>1 && RenderSurface::allGLContextsAreShared())
{
@ -636,18 +637,18 @@ bool OsgCameraGroup::realize()
// so need to disable multi-threading to prevent problems.
osg::notify(osg::INFO)<<"Warning: disabling multi-threading of cull and draw to avoid"<<std::endl;
osg::notify(osg::INFO)<<" threading problems when sharing graphics contexts within RenderSurface."<<std::endl;
_thread_model = Producer::CameraGroup::SingleThreaded;
_threadModel = Producer::CameraGroup::SingleThreaded;
}
}
if (_thread_model==Producer::CameraGroup::SingleThreaded)
if (_threadModel==Producer::CameraGroup::SingleThreaded)
{
osg::notify(osg::INFO)<<"OsgCameraGroup::realize() _thread_model==Producer::CameraGroup::SingleThreaded"<<std::endl;
osg::notify(osg::INFO)<<"OsgCameraGroup::realize() _threadModel==Producer::CameraGroup::SingleThreaded"<<std::endl;
}
else
{
osg::notify(osg::INFO)<<"OsgCameraGroup::realize() _thread_model==Producer::CameraGroup::ThreadPerCamera"<<std::endl;
osg::notify(osg::INFO)<<"OsgCameraGroup::realize() _threadModel==Producer::CameraGroup::ThreadPerCamera"<<std::endl;
}
_initialized = CameraGroup::realize();

View File

@ -16,6 +16,7 @@
#include <osgGA/UFOManipulator>
#include <osgGA/StateSetManipulator>
#include <Producer/CameraConfig>
#include <osgProducer/Viewer>
#include <osgProducer/ViewerEventHandler>
@ -498,7 +499,7 @@ void Viewer::setViewByMatrix( const Producer::Matrix & pm)
bool Viewer::realize( ThreadingModel thread_model )
{
if( _realized ) return _realized;
_thread_model = thread_model;
_threadModel = thread_model;
return realize();
}

View File

@ -1,3 +1,4 @@
#include <Producer/CameraConfig>
#include <osgProducer/ViewerEventHandler>
#include <osgGA/AnimationPathManipulator>
#include <osgDB/WriteFile>