mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Prevent redundant glBindBuffer calls.
--HG-- branch : minor
This commit is contained in:
@@ -58,13 +58,12 @@ void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t
|
||||
if (vbo != nullptr)
|
||||
newsize = std::max(size_t(vbo->getSize() * 1.5), newsize);
|
||||
|
||||
GLBuffer *new_vbo = new GLBuffer(newsize, nullptr, GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
|
||||
GLBuffer *new_vbo = new GLBuffer(newsize, nullptr, BUFFER_VERTEX, GL_DYNAMIC_DRAW);
|
||||
|
||||
if (vbo != nullptr)
|
||||
{
|
||||
try
|
||||
{
|
||||
GLBuffer::Bind bind(*vbo);
|
||||
vbodata = (uint8 *) vbo->map();
|
||||
}
|
||||
catch (love::Exception &)
|
||||
@@ -73,7 +72,6 @@ void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t
|
||||
throw;
|
||||
}
|
||||
|
||||
GLBuffer::Bind bind(*new_vbo);
|
||||
new_vbo->fill(0, vbo->getSize(), vbodata);
|
||||
}
|
||||
|
||||
@@ -83,7 +81,6 @@ void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t
|
||||
|
||||
if (vbo != nullptr && datasize > 0)
|
||||
{
|
||||
GLBuffer::Bind bind(*vbo);
|
||||
vbodata = (uint8 *) vbo->map();
|
||||
memcpy(vbodata + offset, &vertices[0], datasize);
|
||||
// We unmap when we draw, to avoid unnecessary full map()/unmap() calls.
|
||||
@@ -228,7 +225,7 @@ void Text::draw(const Matrix4 &m)
|
||||
transform.get() *= m;
|
||||
|
||||
{
|
||||
GLBuffer::Bind bind(*vbo);
|
||||
vbo->bind();
|
||||
vbo->unmap(); // Make sure all pending data is flushed to the GPU.
|
||||
|
||||
// Font::drawVertices expects AttribPointer calls to be done already.
|
||||
|
||||
Reference in New Issue
Block a user