Fix a bug with auto batching logic

This commit is contained in:
Nite Luo 2013-12-04 19:05:17 -08:00
parent e316ac779b
commit 9b0e0d2116
1 changed files with 5 additions and 4 deletions

View File

@ -237,10 +237,8 @@ void Renderer::render()
{
QuadCommand* cmd = static_cast<QuadCommand*>(command);
CCASSERT(cmd->getQuadCount()<VBO_SIZE, "VBO is not big enough for quad data, please break the quad data down or use customized render command");
//Batch quads
if(_numQuads + cmd->getQuadCount() < VBO_SIZE)
if(_numQuads + cmd->getQuadCount() <= VBO_SIZE)
{
memcpy(_quads + _numQuads, cmd->getQuad(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount());
_numQuads += cmd->getQuadCount();
@ -248,8 +246,11 @@ void Renderer::render()
}
else
{
CCASSERT(cmd->getQuadCount() < VBO_SIZE, "VBO is not big enough for quad data, please break the quad data down or use customized render command");
//Draw batched quads if VBO is full
drawBatchedQuads();
i--;
}
}
else if(command->getType() == CUSTOM_COMMAND)