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:
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ class OSG_EXPORT GraphicsThread : public Referenced, public OpenThreads::Thread
|
||||
public:
|
||||
GraphicsThread();
|
||||
|
||||
/** Base class for implementing GraphicsThread operations.*/
|
||||
/** Base class for implementing graphics operations.*/
|
||||
struct OSG_EXPORT Operation : virtual public Referenced
|
||||
{
|
||||
Operation(const std::string& name, bool keep):
|
||||
@@ -109,7 +109,7 @@ class OSG_EXPORT GraphicsThread : public Referenced, public OpenThreads::Thread
|
||||
std::string _name;
|
||||
bool _keep;
|
||||
};
|
||||
|
||||
|
||||
/** Add operation to end of OperationQueue, this will be
|
||||
* executed by the graphics thread once this operation gets to the head of the queue.*/
|
||||
void add(Operation* operation, bool waitForCompletion=false);
|
||||
|
||||
@@ -32,27 +32,33 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
|
||||
/** set up windows and associated threads.*/
|
||||
void realize();
|
||||
|
||||
void setDone(bool done) { _done = done; }
|
||||
|
||||
bool done() { return _done; }
|
||||
|
||||
/** Render a complete new frame.
|
||||
* Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameCullTraversal() and frameDrawTraversal().
|
||||
* Note, no internal makeCurrent() is issued before, or swap buffers called after frame(), these operations are the responsibility of the calling code.*/
|
||||
* Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameRenderingTraversals(). */
|
||||
virtual void frame();
|
||||
|
||||
virtual void frameAdvance();
|
||||
|
||||
virtual void frameEventTraversal();
|
||||
|
||||
virtual void frameUpdateTraversal();
|
||||
virtual void frameCullTraversal();
|
||||
virtual void frameDrawTraversal();
|
||||
|
||||
virtual void frameRenderingTraversals();
|
||||
|
||||
/** Release all OpenGL objects associated with this viewer's scenegraph. Note, does not deleted the actual OpenGL objects, it just releases them to the pending GL object delete lists which will need flushing once a valid graphics context is obtained.*/
|
||||
virtual void releaseAllGLObjects();
|
||||
|
||||
/** Clean up all OpenGL objects associated with this viewer's scenegraph. Note, must only be called from the graphics context associated with this viewer.*/
|
||||
/** Clean up all OpenGL objects associated with this viewer's scenegraph.*/
|
||||
virtual void cleanup();
|
||||
|
||||
public:
|
||||
|
||||
void init();
|
||||
bool _firstFrame;
|
||||
bool _done;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user