mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- moved calls to renderstate from buffer implementation into a subfunction so that it's easier to change if needed.
This commit is contained in:
parent
90982285ac
commit
f6d9592a45
1 changed files with 10 additions and 6 deletions
|
@ -34,6 +34,11 @@
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
static inline void InvalidateBufferState()
|
||||||
|
{
|
||||||
|
gl_RenderState.ResetVertexBuffer(); // force rebinding of buffers on next Apply call.
|
||||||
|
}
|
||||||
|
|
||||||
GLBuffer::GLBuffer(int usetype)
|
GLBuffer::GLBuffer(int usetype)
|
||||||
: mUseType(usetype)
|
: mUseType(usetype)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +53,6 @@ GLBuffer::~GLBuffer()
|
||||||
glUnmapBuffer(mUseType);
|
glUnmapBuffer(mUseType);
|
||||||
glBindBuffer(mUseType, 0);
|
glBindBuffer(mUseType, 0);
|
||||||
glDeleteBuffers(1, &mBufferId);
|
glDeleteBuffers(1, &mBufferId);
|
||||||
gl_RenderState.ResetVertexBuffer(); // force rebinding of buffers on next Apply call.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +86,7 @@ void GLBuffer::SetData(size_t size, void *data, bool staticdata)
|
||||||
if (!staticdata) nomap = false;
|
if (!staticdata) nomap = false;
|
||||||
}
|
}
|
||||||
buffersize = size;
|
buffersize = size;
|
||||||
gl_RenderState.ResetVertexBuffer(); // force rebinding of buffers on next Apply call.
|
InvalidateBufferState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLBuffer::Map()
|
void GLBuffer::Map()
|
||||||
|
@ -92,7 +96,7 @@ void GLBuffer::Map()
|
||||||
{
|
{
|
||||||
Bind();
|
Bind();
|
||||||
map = (FFlatVertex*)glMapBufferRange(mUseType, 0, buffersize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
|
map = (FFlatVertex*)glMapBufferRange(mUseType, 0, buffersize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
|
||||||
gl_RenderState.ResetVertexBuffer();
|
InvalidateBufferState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +107,7 @@ void GLBuffer::Unmap()
|
||||||
{
|
{
|
||||||
Bind();
|
Bind();
|
||||||
glUnmapBuffer(mUseType);
|
glUnmapBuffer(mUseType);
|
||||||
gl_RenderState.ResetVertexBuffer();
|
InvalidateBufferState();
|
||||||
map = nullptr;
|
map = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +123,7 @@ void GLBuffer::Unlock()
|
||||||
{
|
{
|
||||||
Bind();
|
Bind();
|
||||||
glUnmapBuffer(mUseType);
|
glUnmapBuffer(mUseType);
|
||||||
gl_RenderState.ResetVertexBuffer();
|
InvalidateBufferState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLBuffer::Resize(size_t newsize)
|
void GLBuffer::Resize(size_t newsize)
|
||||||
|
@ -143,7 +147,7 @@ void GLBuffer::Resize(size_t newsize)
|
||||||
glBindBuffer(GL_COPY_READ_BUFFER, 0);
|
glBindBuffer(GL_COPY_READ_BUFFER, 0);
|
||||||
glDeleteBuffers(1, &oldbuffer);
|
glDeleteBuffers(1, &oldbuffer);
|
||||||
buffersize = newsize;
|
buffersize = newsize;
|
||||||
gl_RenderState.ResetVertexBuffer();
|
InvalidateBufferState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue