mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
GLES: Fix data buffer resize
This commit is contained in:
parent
5939f1947f
commit
3ff27b4281
1 changed files with 18 additions and 19 deletions
|
@ -207,29 +207,28 @@ void GLBuffer::Unlock()
|
|||
}
|
||||
|
||||
void GLBuffer::Resize(size_t newsize)
|
||||
{
|
||||
assert(!nomap); // only mappable buffers can be resized.
|
||||
if (newsize > buffersize && !nomap)
|
||||
{
|
||||
if (newsize > buffersize)
|
||||
{
|
||||
/*
|
||||
// reallocate the buffer with twice the size
|
||||
unsigned int oldbuffer = mBufferId;
|
||||
if (isData)
|
||||
{
|
||||
// Create new bigger memory
|
||||
char* memoryNew = (char*)(new uint64_t[newsize / 8 + 16]);
|
||||
|
||||
// first unmap the old buffer
|
||||
Bind();
|
||||
glUnmapBuffer(mUseType);
|
||||
// Copy old data
|
||||
memcpy(memoryNew, memory, buffersize);
|
||||
|
||||
glGenBuffers(1, &mBufferId);
|
||||
SetData(newsize, nullptr, false);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, oldbuffer);
|
||||
// Delete old memory
|
||||
delete[] memory;
|
||||
|
||||
// copy contents and delete the old buffer.
|
||||
glCopyBufferSubData(GL_COPY_READ_BUFFER, mUseType, 0, 0, buffersize);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, 0);
|
||||
glDeleteBuffers(1, &oldbuffer);
|
||||
buffersize = newsize;
|
||||
InvalidateBufferState();
|
||||
*/
|
||||
memory = memoryNew;
|
||||
|
||||
buffersize = newsize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue