Support BufferData with size zero.

TRAC #12027

Signed-off-by: Shannon Woods
Signed-off-by: Daniel Koch

Author:    Andrew Lewycky

git-svn-id: https://angleproject.googlecode.com/svn/trunk@191 736b8ea6-26fd-11df-bfd4-992fa37f6226
This commit is contained in:
daniel@transgaming.com 2010-04-23 18:34:58 +00:00
Родитель c46c9c0773
Коммит c103b60cda
1 изменённых файлов: 15 добавлений и 5 удалений

Просмотреть файл

@ -37,7 +37,14 @@ GLenum Buffer::bufferData(const void* data, GLsizeiptr size, GLenum usage)
const GLubyte* newdata = static_cast<const GLubyte*>(data);
if (size != mContents.size())
if (size == 0)
{
mContents.clear();
delete mIdentityTranslation;
mIdentityTranslation = NULL;
}
else if (size != mContents.size())
{
// vector::resize only provides the basic exception guarantee, so use temporaries & swap to get the strong exception guarantee.
// We don't want to risk having mContents and mIdentityTranslation that have different contents or even different sizes.
@ -87,11 +94,14 @@ GLenum Buffer::copyToIdentityBuffer(GLintptr offset, GLsizeiptr length)
{
ASSERT(offset >= 0 && length >= 0);
// This is a stalling map. Not great for performance.
GLubyte *p = static_cast<GLubyte*>(mIdentityTranslation->map());
if (length > 0) // If length == 0 mIdentityTranslation might be NULL.
{
// This is a stalling map. Not great for performance.
GLubyte *p = static_cast<GLubyte*>(mIdentityTranslation->map());
memcpy(p + offset, &mContents[0] + offset, length);
mIdentityTranslation->unmap();
memcpy(p + offset, &mContents[0] + offset, length);
mIdentityTranslation->unmap();
}
return GL_NO_ERROR;
}