Commit e4210c68 authored by Robert Menzel's avatar Robert Menzel
Browse files

added getSize to the bufferobject

parent f96584a2
...@@ -58,6 +58,15 @@ public: ...@@ -58,6 +58,15 @@ public:
glDeleteBuffers(1, &mObjectName); glDeleteBuffers(1, &mObjectName);
} }
GLuint mObjectName; GLuint mObjectName;
//! has the side effect of binding this buffer.
//! returned value is in bytes
GLsizei getSize( GLenum _asTarget ) {
glBindBuffer( _asTarget, mObjectName );
GLint value;
glGetBufferParameteriv( _asTarget, GL_BUFFER_SIZE, &value );
return value;
}
}; };
typedef ptr::shared_ptr<BufferObject> SharedBufferObject; typedef ptr::shared_ptr<BufferObject> SharedBufferObject;
...@@ -94,10 +103,11 @@ public: ...@@ -94,10 +103,11 @@ public:
* In this case no GL wrapper calls should ever get called until one gets set! * In this case no GL wrapper calls should ever get called until one gets set!
*/ */
Buffer( SharedBufferObject _pBuffer, GLenum _target ) Buffer( SharedBufferObject _pBuffer, GLenum _target )
: mSize(0), : mBuffer( _pBuffer ),
mBuffer( _pBuffer ),
mTarget(_target) mTarget(_target)
{} {
mSize = mBuffer->getSize( _target );
}
virtual ~Buffer(){} virtual ~Buffer(){}
...@@ -114,7 +124,7 @@ public: ...@@ -114,7 +124,7 @@ public:
// ==================================================================================================== \/ // ==================================================================================================== \/
//! the GL buffer can get changed at any time //! the GL buffer can get changed at any time
void setBufferObject( SharedBufferObject _pBuffer ) { mBuffer = _pBuffer; } void setBufferObject( SharedBufferObject _pBuffer ) { mBuffer = _pBuffer; mSize = mBuffer->getSize( mTarget ); }
// ===================================================================================================== \/ // ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/ // ============================================================================================ WRAPPERS \/
......
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