diff --git a/include/osg/BufferObject b/include/osg/BufferObject index 37ae19a55..3e627cf95 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -152,6 +152,14 @@ class BufferObjectProfile class GLBufferObjectSet; class GLBufferObjectManager; +inline unsigned int computeBufferAlignment(unsigned int pos, unsigned int bufferAlignment) +{ + if (bufferAlignment<2) return pos; + if ((pos%bufferAlignment)==0) return pos; + return ((pos/bufferAlignment)+1)*bufferAlignment; +} + + class OSG_EXPORT GLBufferObject : public GraphicsObject { public: @@ -235,9 +243,7 @@ class OSG_EXPORT GLBufferObject : public GraphicsObject unsigned int computeBufferAlignment(unsigned int pos, unsigned int bufferAlignment) const { - if (bufferAlignment<2) return pos; - if ((pos%bufferAlignment)==0) return pos; - return ((pos/bufferAlignment)+1)*bufferAlignment; + return osg::computeBufferAlignment(pos, bufferAlignment); } unsigned int _contextID; diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index 46fa4e869..d098cfcf3 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -140,7 +140,7 @@ void GLBufferObject::compileBuffer() entry.dataSource != bd || entry.dataSize != bd->getTotalDataSize()) { - unsigned int previousEndOfBufferDataMarker = computeBufferAlignment(entry.offset + entry.dataSize, bufferAlignment); + unsigned int previousEndOfBufferDataMarker = osg::computeBufferAlignment(entry.offset + entry.dataSize, bufferAlignment); // OSG_NOTICE<<"GLBufferObject::compileBuffer(..) updating BufferEntry"<getTotalDataSize(); + if (bd) newTotalSize = osg::computeBufferAlignment(newTotalSize + bd->getTotalDataSize(), bufferAlignment); else { OSG_NOTICE<<"BufferObject::"<