mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Prevent redundant calls to glEnable/DisableVertexAttribArray. This should hopefully fix a performance regression compared to 0.9.2 as well.
This commit is contained in:
@@ -564,25 +564,12 @@ void Font::printv(const Matrix &t, const std::vector<DrawCommand> &drawcommands,
|
||||
OpenGL::TempTransform transform(gl);
|
||||
transform.get() *= t;
|
||||
|
||||
glEnableVertexAttribArray(ATTRIB_POS);
|
||||
glEnableVertexAttribArray(ATTRIB_TEXCOORD);
|
||||
gl.useVertexAttribArrays(ATTRIBFLAG_POS | ATTRIBFLAG_TEXCOORD);
|
||||
|
||||
glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, sizeof(GlyphVertex), &vertices[0].x);
|
||||
glVertexAttribPointer(ATTRIB_TEXCOORD, 2, GL_FLOAT, GL_FALSE, sizeof(GlyphVertex), &vertices[0].s);
|
||||
|
||||
try
|
||||
{
|
||||
drawVertices(drawcommands);
|
||||
}
|
||||
catch (love::Exception &)
|
||||
{
|
||||
glDisableVertexAttribArray(ATTRIB_TEXCOORD);
|
||||
glDisableVertexAttribArray(ATTRIB_POS);
|
||||
throw;
|
||||
}
|
||||
|
||||
glDisableVertexAttribArray(ATTRIB_TEXCOORD);
|
||||
glDisableVertexAttribArray(ATTRIB_POS);
|
||||
drawVertices(drawcommands);
|
||||
}
|
||||
|
||||
void Font::print(const std::string &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
@@ -590,8 +577,7 @@ void Font::print(const std::string &text, float x, float y, float angle, float s
|
||||
std::vector<GlyphVertex> vertices;
|
||||
std::vector<DrawCommand> drawcommands = generateVertices(text, vertices);
|
||||
|
||||
Matrix t;
|
||||
t.setTransformation(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
printv(t, drawcommands, vertices);
|
||||
}
|
||||
@@ -601,8 +587,7 @@ void Font::printf(const std::string &text, float x, float y, float wrap, AlignMo
|
||||
std::vector<GlyphVertex> vertices;
|
||||
std::vector<DrawCommand> drawcommands = generateVerticesFormatted(text, wrap, align, vertices);
|
||||
|
||||
Matrix t;
|
||||
t.setTransformation(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
printv(t, drawcommands, vertices);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user