diff --git a/examples/osgcamera/osgcamera.cpp b/examples/osgcamera/osgcamera.cpp index bbfc13a54..208f95b38 100644 --- a/examples/osgcamera/osgcamera.cpp +++ b/examples/osgcamera/osgcamera.cpp @@ -172,7 +172,7 @@ int main( int argc, char **argv ) else viewer.setCameraManipulator( new osgGA::TrackballManipulator() ); viewer.getCamera()->setClearColor(osg::Vec4f(0.6f,0.6f,0.8f,1.0f)); -#if 1 +#if 0 // singleWindowMultipleCameras(viewer); @@ -187,7 +187,7 @@ int main( int argc, char **argv ) viewer.realize(); - bool limitNumberOfFrames = false; + bool limitNumberOfFrames = true; unsigned int numFrames = 0; unsigned int maxFrames = 10; diff --git a/include/osgViewer/GraphicsWindowX11 b/include/osgViewer/GraphicsWindowX11 index 64ed652cc..3eb3ee703 100644 --- a/include/osgViewer/GraphicsWindowX11 +++ b/include/osgViewer/GraphicsWindowX11 @@ -106,6 +106,8 @@ class GraphicsWindowX11 : public osgViewer::GraphicsWindow protected: + ~GraphicsWindowX11(); + bool createVisualInfo(); void init(); diff --git a/src/osg/GraphicsContext.cpp b/src/osg/GraphicsContext.cpp index be8638ad5..35abb480e 100644 --- a/src/osg/GraphicsContext.cpp +++ b/src/osg/GraphicsContext.cpp @@ -141,10 +141,6 @@ bool GraphicsContext::realize() { if (realizeImplementation()) { - if (_graphicsThread.valid() && !_graphicsThread->isRunning()) - { - _graphicsThread->startThread(); - } return true; } else @@ -255,12 +251,6 @@ void GraphicsContext::setGraphicsThread(GraphicsThread* gt) if (_graphicsThread.valid()) { _graphicsThread->_graphicsContext = this; -#if 0 - if (!_graphicsThread->isRunning()) - { - _graphicsThread->startThread(); - } -#endif } } diff --git a/src/osg/GraphicsThread.cpp b/src/osg/GraphicsThread.cpp index e50af3f01..c65972a58 100644 --- a/src/osg/GraphicsThread.cpp +++ b/src/osg/GraphicsThread.cpp @@ -86,9 +86,11 @@ GraphicsThread::GraphicsThread(): GraphicsThread::~GraphicsThread() { - osg::notify(osg::INFO)<<"Destructing graphics thread"<mouseWarped(x,y); } +int X11ErrorHandling(Display* display, XErrorEvent* event) +{ + osg::notify(osg::NOTICE)<<"Got an X11ErrorHandling call"<getDatabasePager()->cancel(); _scene->setDatabasePager(0); } -#endif + + //osg::notify(osg::NOTICE)<<"finish Viewer::~Viewer()"< 1 && _threadingModel>=ThreadPerContext; + bool affinity = true; if (multiThreaded) { bool firstContextAsMainThread = _threadingModel==ThreadPerContext; unsigned int numThreadsIncludingMainThread = firstContextAsMainThread ? contexts.size() : contexts.size()+1; - osg::notify(osg::NOTICE)<<"numThreadsIncludingMainThread=="< swapOp = new osg::SwapBuffersOperation(); citr = contexts.begin(); - if (firstContextAsMainThread) ++citr; + unsigned int processNum = 0; + if (firstContextAsMainThread) + { + if (affinity) OpenThreads::SetProcessorAffinityOfCurrentThread(processNum % numProcessors); + ++processNum; + ++citr; + } + for(; citr != contexts.end(); - ++citr) + ++citr, + ++processNum) { osg::GraphicsContext* gc = (*citr); // create the a graphics thread for this context gc->createGraphicsThread(); + if (affinity) gc->getGraphicsThread()->setProcessorAffinity(processNum % numProcessors); + gc->getGraphicsThread()->add(new CompileOperation(getSceneData())); // add the startRenderingBarrier @@ -264,6 +278,8 @@ void Viewer::realize() if (multiThreaded) { + //osg::notify(osg::NOTICE)<<"Ready to start threads"<getGraphicsThread() && !gc->getGraphicsThread()->isRunning()) { + //osg::notify(osg::NOTICE)<<" gc->getGraphicsThread()->startThread() "<getGraphicsThread()<getGraphicsThread()->startThread(); OpenThreads::Thread::YieldCurrentThread(); } } + + //osg::notify(osg::NOTICE)<<"Started threads"<