Commit b5f08a3f authored by Janis Born's avatar Janis Born
Browse files

add ArrayBuffer::setGeometryData

parent 99fcc3aa
...@@ -65,6 +65,9 @@ ...@@ -65,6 +65,9 @@
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
class GeometryData;
ACGL_SMARTPOINTER_TYPEDEFS(GeometryData)
class ArrayBuffer : public Buffer class ArrayBuffer : public Buffer
{ {
// ==================================================================================================== \/ // ==================================================================================================== \/
...@@ -152,6 +155,9 @@ public: ...@@ -152,6 +155,9 @@ public:
//! Setting of the stride size explicitly is not needed if the attributes are defined correctly (with padding) //! Setting of the stride size explicitly is not needed if the attributes are defined correctly (with padding)
inline void setStride( GLsizei _stride ) { mStride = _stride; } inline void setStride( GLsizei _stride ) { mStride = _stride; }
//! Sets all data (attributes, stride, size) to those specified in _geometryData. All previous data are overwritten.
void setGeometryData( SharedGeometryData _geometryData );
//! removes all attributes //! removes all attributes
inline void removeAttributes(void) inline void removeAttributes(void)
{ {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
**********************************************************************/ **********************************************************************/
#include <ACGL/OpenGL/Objects/ArrayBuffer.hh> #include <ACGL/OpenGL/Objects/ArrayBuffer.hh>
#include <ACGL/OpenGL/Data/GeometryData.hh>
using namespace ACGL; using namespace ACGL;
using namespace ACGL::OpenGL; using namespace ACGL::OpenGL;
...@@ -114,3 +115,16 @@ int32_t ArrayBuffer::getAttributeIndexByName(const std::string& _nameInArray) co ...@@ -114,3 +115,16 @@ int32_t ArrayBuffer::getAttributeIndexByName(const std::string& _nameInArray) co
return (int32_t) i; return (int32_t) i;
return -1; return -1;
} }
void ArrayBuffer::setGeometryData(SharedGeometryData _geometryData)
{
removeAttributes();
for(ArrayBuffer::AttributeVec::const_iterator it = _geometryData->mAttributes.begin();
it != _geometryData->mAttributes.end();
++it)
{
defineAttribute(*it);
}
setStride(_geometryData->getStrideSize());
setData(_geometryData->getSize(), _geometryData->getData());
}
Supports Markdown
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