Added ability to compile OpenGL objects via pbuffers in the DatabasePager/Viewer

This commit is contained in:
Robert Osfield
2007-06-22 14:48:18 +00:00
parent 1d78ea2983
commit 1b3468413d
4 changed files with 172 additions and 43 deletions

View File

@@ -219,12 +219,23 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
}
/** Add a graphics context that should be used to compile/delete OpenGL objects.*/
void addCompileGraphicsContext(osg::GraphicsContext* gc);
/** Removed a graphics context that should be used to compile/delete OpenGL objects.*/
void removeCompileGraphicsContext(osg::GraphicsContext* gc);
/** Turn the compilation of rendering objects for specfied graphics context on (true) or off(false). */
void setCompileGLObjectsForContextID(unsigned int contextID, bool on);
/** Get whether the compilation of rendering objects for specfied graphics context on (true) or off(false). */
bool getCompileGLObjectsForContextID(unsigned int contextID);
/** Rerturn true if an external draw thread should call compileGLObjects(..) or not.*/
bool requiresExternalCompileGLObjects(unsigned int contextID) const;
/** Return true if there are pending compile operations that are required.
* If requiresCompileGLObjects() return true the application should call compileGLObjects() .*/
bool requiresCompileGLObjects() const;
@@ -234,6 +245,11 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
* Note, must only be called from a valid graphics context. */
virtual void compileGLObjects(osg::State& state,double& availableTime);
/** Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph.
* note, should only be called from the draw thread.
* Note, must only be called from a valid graphics context. */
virtual void compileAllGLObjects(osg::State& state);
/** Report how many items are in the _fileRequestList queue */
unsigned int getFileRequestListSize() const { return _fileRequestList.size(); }
@@ -241,12 +257,13 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
unsigned int getDataToCompileListSize() const { return _dataToCompileList.size(); }
typedef std::list< osg::ref_ptr<osg::PagedLOD> > PagedLODList;
typedef std::set< osg::ref_ptr<osg::StateSet> > StateSetList;
typedef std::vector< osg::ref_ptr<osg::Drawable> > DrawableList;
typedef std::pair<StateSetList,DrawableList> DataToCompile;
typedef std::map< unsigned int, DataToCompile > DataToCompileMap;
typedef std::set<unsigned int> ActiveGraphicsContexts;
typedef std::list< osg::ref_ptr<osg::PagedLOD> > PagedLODList;
typedef std::set< osg::ref_ptr<osg::StateSet> > StateSetList;
typedef std::vector< osg::ref_ptr<osg::Drawable> > DrawableList;
typedef std::pair<StateSetList,DrawableList> DataToCompile;
typedef std::map< unsigned int, DataToCompile > DataToCompileMap;
typedef std::set<unsigned int> ActiveGraphicsContexts;
typedef std::vector< osg::observer_ptr<osg::GraphicsContext> > CompileGraphicsContexts;
protected:
@@ -358,11 +375,21 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
double _expiryDelay;
ActiveGraphicsContexts _activeGraphicsContexts;
CompileGraphicsContexts _compileGraphicsContexts;
bool _doPreCompile;
double _targetFrameRate;
double _minimumTimeAvailableForGLCompileAndDeletePerFrame;
unsigned int _maximumNumOfObjectsToCompilePerFrame;
struct CompileOperation : public osg::Operation
{
CompileOperation(DatabasePager* databasePager);
virtual void operator () (osg::Object* object);
osg::observer_ptr<DatabasePager> _databasePager;
};
};
}