Commit b8f40245 authored by Martin Schultz's avatar Martin Schultz

* VertexArrayObjectCreator is now capable of caching and loads also vao

* files
parent e5e22691
......@@ -50,6 +50,9 @@ public:
//! links to an external LocationMappings object
inline VertexArrayObjectCreator& externAttributeLocations(const SharedLocationMappings& _attributeLocations) { mAttributeLocations = _attributeLocations; return *this; }
//! sets the caching mode for this creator
inline VertexArrayObjectCreator& cached(bool _cacheMode) { mCaching = _cacheMode; return *this; }
private:
bool load(SharedVertexArrayObject& vao);
......@@ -65,6 +68,7 @@ public:
// =================================================================================================== \/
protected:
SharedLocationMappings mAttributeLocations;
bool mCaching;
};
} // OpenGL
......
......@@ -5,7 +5,7 @@
**********************************************************************/
#include <ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh>
#include <ACGL/OpenGL/Data/GeometryDataLoadStore.hh>
#include <ACGL/OpenGL/Data/VertexArrayObjectLoadStore.hh>
#ifdef ACGL_SUPPORT_VAO
......@@ -13,41 +13,21 @@ using namespace ACGL;
using namespace ACGL::OpenGL;
VertexArrayObjectCreator::VertexArrayObjectCreator(const std::string &_filename)
: Resource::SingleFileBasedCreator<VertexArrayObject>(_filename, Base::Settings::the()->getFullGeometryPath())
: Resource::SingleFileBasedCreator<VertexArrayObject>(_filename, Base::Settings::the()->getFullGeometryPath()),
mCaching(false)
{
}
VertexArrayObjectCreator::VertexArrayObjectCreator(const char *_filename)
: Resource::SingleFileBasedCreator<VertexArrayObject>(std::string(_filename), Base::Settings::the()->getFullGeometryPath())
: Resource::SingleFileBasedCreator<VertexArrayObject>(std::string(_filename), Base::Settings::the()->getFullGeometryPath()),
mCaching(false)
{
}
bool VertexArrayObjectCreator::load(SharedVertexArrayObject &_vao)
{
SharedGeometryData tempData = loadGeometryData( getFullFilePath() );
if(!tempData)
return false;
SharedArrayBuffer sab = SharedArrayBuffer( new ArrayBuffer() );
for ( uint_t i = 0; i < tempData->mAttributes.size(); ++i ) {
sab->defineAttribute( tempData->mAttributes[i] );
}
sab->setDataElements( tempData->getSize()/tempData->getStrideSize(), tempData->getData() );
_vao->detachAllAttributes();
_vao->attachAllAttributes(sab);
// merge the mappings of the new VAO into the linked LocationMappings object, if present
if(mAttributeLocations)
{
_vao->setAttributeLocations(mAttributeLocations);
SharedLocationMappings vaoAttributeLocations = _vao->getAttributeLocations();
mAttributeLocations->addLocations(vaoAttributeLocations);
_vao->setAttributeLocations(mAttributeLocations);
}
return true;
_vao = loadVertexArrayObject(getFullFilePath(), mCaching);
return _vao != nullptr;
}
SharedVertexArrayObject VertexArrayObjectCreator::create()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment