From e1e7db47588af9c4f36ce3a97a340c72134aa89c Mon Sep 17 00:00:00 2001 From: Colby Klein Date: Sun, 27 Feb 2011 20:30:44 -0800 Subject: [PATCH] Draw strings in batches. This results in glDrawArrays calls being dramatically reduced, although it's still not perfect. Note: This breaks drawing strings which use multiple maps. --- src/BitmapText.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index 22085add32..dfa9a892c1 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -328,6 +328,9 @@ void BitmapText::DrawChars( bool bUseStrokeTexture ) } } + vector vertices; + int iNumVertsToDraw = 0; + for( int start = iStartGlyph; start < iEndGlyph; ) { int end = start; @@ -348,14 +351,15 @@ void BitmapText::DrawChars( bool bUseStrokeTexture ) * the texture wrapping state. If setting the wrapping state is found to be slow, * there should probably be a "don't care" texture wrapping mode set in Actor. -Chris */ Actor::SetTextureRenderStates(); - + RageSpriteVertex &start_vertex = m_aVertices[start*4]; - int iNumVertsToDraw = (end-start)*4; - DISPLAY->DrawQuads( &start_vertex, iNumVertsToDraw ); + vertices.push_back(&start_vertex); + iNumVertsToDraw += (end-start)*4; } start = end; } + DISPLAY->DrawQuads( vertices[0], iNumVertsToDraw ); } /* sText is UTF-8. If not all of the characters in sText are available in the