Commit 23830adb authored by Robert Menzel's avatar Robert Menzel

don't dereference a NULL pointer...

parent ac88dd23
......@@ -106,7 +106,7 @@ public:
: mBuffer( _pBuffer ),
mTarget(_target)
{
mSize = mBuffer->getSize( _target );
mSize = (mBuffer == NULL)?0:mBuffer->getSize( mTarget );
}
virtual ~Buffer(){}
......@@ -124,7 +124,7 @@ public:
// ==================================================================================================== \/
//! the GL buffer can get changed at any time
void setBufferObject( SharedBufferObject _pBuffer ) { mBuffer = _pBuffer; mSize = mBuffer->getSize( mTarget ); }
void setBufferObject( SharedBufferObject _pBuffer ) { mBuffer = _pBuffer; mSize = (mBuffer == NULL)?0:mBuffer->getSize( mTarget ); }
// ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/
......
......@@ -92,11 +92,15 @@ private:
void bind() {}
void attachBufferToTexture() {
assert( Buffer::getSize() > 0 && "glTexBuffer will fail if the buffer is empty" );
bindTexture();
openGLCriticalErrorOccured();
glTexBuffer( GL_TEXTURE_BUFFER, mDataType, Buffer::getObjectName() );
if (mBuffer == NULL) {
// the buffer was in fact detached
bindTexture();
glTexBuffer( GL_TEXTURE_BUFFER, mDataType, 0 );
} else {
assert( Buffer::getSize() > 0 && "glTexBuffer will fail if the buffer is empty" );
bindTexture();
glTexBuffer( GL_TEXTURE_BUFFER, mDataType, Buffer::getObjectName() );
}
openGLCriticalErrorOccured();
}
......
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