Prevent redundant glBindBuffer calls.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-10-20 21:50:48 -03:00
parent 4c122e6581
commit d1c5edd792
14 changed files with 128 additions and 160 deletions
+2 -5
View File
@@ -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.