Introduced new BufferObject design + implementation in preperation of implementing a pool system for buffer objects
This commit is contained in:
@@ -106,7 +106,7 @@ class UniformVarying : public osg::Uniform::Callback
|
||||
}
|
||||
};
|
||||
|
||||
osg::Node* createModel(const std::string& shader, const std::string& textureFileName, const std::string& terrainFileName, bool dynamic, bool vbo)
|
||||
osg::Node* createModel(const std::string& shader, const std::string& textureFileName, const std::string& terrainFileName, bool dynamic, bool useVBO)
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
|
||||
@@ -238,10 +238,10 @@ osg::Node* createModel(const std::string& shader, const std::string& textureFile
|
||||
|
||||
geom->setVertexArray(vertices);
|
||||
|
||||
osg::VertexBufferObject* vbObject = new osg::VertexBufferObject;
|
||||
vertices->setVertexBufferObject(vbObject);
|
||||
osg::VertexBufferObject* vbo = useVBO ? new osg::VertexBufferObject : 0;
|
||||
if (vbo) vertices->setVertexBufferObject(vbo);
|
||||
|
||||
osg::ElementBufferObject* ebo = new osg::ElementBufferObject;
|
||||
osg::ElementBufferObject* ebo = useVBO ? new osg::ElementBufferObject : 0;
|
||||
|
||||
for(iy=0; iy<num_y-1; ++iy)
|
||||
{
|
||||
@@ -255,7 +255,7 @@ osg::Node* createModel(const std::string& shader, const std::string& textureFile
|
||||
}
|
||||
geom->addPrimitiveSet(elements);
|
||||
|
||||
if (ebo) elements->setElementBufferObject(ebo);
|
||||
if (ebo) elements->setElementBufferObject(ebo);
|
||||
}
|
||||
|
||||
geom->setUseVertexBufferObjects(vbo);
|
||||
|
||||
@@ -137,7 +137,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback
|
||||
|
||||
void read()
|
||||
{
|
||||
osg::BufferObject::Extensions* ext = osg::BufferObject::getExtensions(_gc->getState()->getContextID(),true);
|
||||
osg::GLBufferObject::Extensions* ext = osg::GLBufferObject::getExtensions(_gc->getState()->getContextID(),true);
|
||||
|
||||
if (ext->isPBOSupported() && !_pboBuffer.empty())
|
||||
{
|
||||
@@ -158,9 +158,9 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback
|
||||
|
||||
void readPixels();
|
||||
|
||||
void singlePBO(osg::BufferObject::Extensions* ext);
|
||||
void singlePBO(osg::GLBufferObject::Extensions* ext);
|
||||
|
||||
void multiPBO(osg::BufferObject::Extensions* ext);
|
||||
void multiPBO(osg::GLBufferObject::Extensions* ext);
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
|
||||
typedef std::vector< GLuint > PBOBuffer;
|
||||
@@ -325,7 +325,7 @@ void WindowCaptureCallback::ContextData::readPixels()
|
||||
_currentPboIndex = nextPboIndex;
|
||||
}
|
||||
|
||||
void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions* ext)
|
||||
void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensions* ext)
|
||||
{
|
||||
// std::cout<<"singelPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
||||
|
||||
@@ -402,7 +402,7 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions
|
||||
_currentImageIndex = nextImageIndex;
|
||||
}
|
||||
|
||||
void WindowCaptureCallback::ContextData::multiPBO(osg::BufferObject::Extensions* ext)
|
||||
void WindowCaptureCallback::ContextData::multiPBO(osg::GLBufferObject::Extensions* ext)
|
||||
{
|
||||
// std::cout<<"multiPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
||||
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
||||
|
||||
Reference in New Issue
Block a user