Moved rendering support into GraphisContext, osgViewer::Viewer/View, and

added frame stamp updating and update traversal to osgViewer::Scene/Viewer.

Updated osgcamera example to use new Viewer API calls instead of using local
rendering calls.
This commit is contained in:
Robert Osfield
2006-12-21 16:56:20 +00:00
parent 8f9d2eeb46
commit 4fc9af7ea0
10 changed files with 311 additions and 96 deletions

View File

@@ -136,6 +136,52 @@ class OSG_EXPORT GraphicsContext : public Referenced
/** Decrement the usage count associate with a contextID. Once the contextID goes to 0 the contextID is then free to be reused.*/
static void decrementContextIDUsageCount(unsigned int contextID);
public:
/** Base class for implementing graphics operations.*/
struct OSG_EXPORT Operation : virtual public Referenced
{
Operation(const std::string& name, bool keep):
_name(name),
_keep(keep) {}
/** Set the human readable name of the operation.*/
void setName(const std::string& name) { _name = name; }
/** Get the human readable name of the operation.*/
const std::string& getName() const { return _name; }
/** Set whether the operation should be kept once its been applied.*/
void setKeep(bool keep) { _keep = keep; }
/** Get whether the operation should be kept once its been applied.*/
bool getKeep() const { return _keep; }
/** if this operation is a barrier then release it.*/
virtual void release() {}
/** Do the actual task of this operation.*/
virtual void operator () (GraphicsContext*) {}
std::string _name;
bool _keep;
};
/** Add operation to end of OperationQueue.*/
void add(Operation* operation);
/** Remove operation from OperationQueue.*/
void remove(Operation* operation);
/** Remove named operation from OperationQueue.*/
void remove(const std::string& name);
/** Remove all operations from OperationQueue.*/
void removeAllOperations();
/** Run the operations. */
void runOperations();
public:
/** Get the traits of the GraphicsContext.*/
@@ -242,6 +288,12 @@ class OSG_EXPORT GraphicsContext : public Referenced
OpenThreads::Mutex _mutex;
OpenThreads::Thread* _threadOfLastMakeCurrent;
typedef std::list< ref_ptr<Operation> > OperationQueue;
OpenThreads::Mutex _operationsMutex;
osg::ref_ptr<osg::Block> _operationsBlock;
OperationQueue _operations;
osg::ref_ptr<Operation> _currentOperation;
ref_ptr<GraphicsThread> _graphicsThread;
};