Further work on support for ThreadPerCamera, and improved the efficiency of SingleThraeded

This commit is contained in:
Robert Osfield
2007-02-06 11:03:13 +00:00
parent cfe737c552
commit bad2a4cc7c
2 changed files with 275 additions and 103 deletions

View File

@@ -133,6 +133,12 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
typedef std::vector<osg::Camera*> Cameras;
void getCameras(Cameras& cameras, bool onlyActive=true);
typedef std::vector<OpenThreads::Thread*> Threads;
void getAllThreads(Threads& threads, bool onlyActive=true);
typedef std::vector<osg::OperationsThread*> OperationsThreads;
void getOperationsThreads(OperationsThreads& threads, bool onlyActive=true);
/** Set the graphics operation to call on realization of the viewers graphics windows.*/
void setRealizeOperation(osg::Operation* op) { _realizeOperation = op; }
@@ -145,6 +151,8 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
/** Start any threads required by the viewer, as per viewers ThreadingModel.*/
void startThreading();
/** Set up the Operations to render the various viewer cameras on the viewers graphics windows.*/
void setUpRenderingSupport();
@@ -152,6 +160,24 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
void checkWindowStatus();
inline void makeCurrent(osg::GraphicsContext* gc)
{
if (_currentContext==gc) return;
releaseContext();
if (gc && gc->makeCurrent()) _currentContext = gc;
}
inline void releaseContext()
{
if (_currentContext.valid())
{
_currentContext->releaseContext();
_currentContext = 0;
}
}
bool _firstFrame;
bool _done;
@@ -183,6 +209,8 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
osg::ref_ptr<osg::Operation> _realizeOperation;
osg::observer_ptr<osg::GraphicsContext> _currentContext;
};