mirror of https://github.com/axmolengine/axmol.git
batch sprite3D rendering
This commit is contained in:
parent
c03ac80700
commit
ace56df74d
|
@ -171,36 +171,13 @@ void MeshCommand::preDraw()
|
|||
GL::blendFunc(_blendType.src, _blendType.dst);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
|
||||
//
|
||||
_glProgramState->apply(_mv);
|
||||
//_glProgramState->apply(_mv);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
|
||||
}
|
||||
void MeshCommand::draw()
|
||||
{
|
||||
if (_matrixPalette)
|
||||
{
|
||||
CCLOG("skin");
|
||||
}
|
||||
auto glProgram = _glProgramState->getGLProgram();
|
||||
//glProgram->use();
|
||||
//glProgram->setUniformsForBuiltins(_mv);
|
||||
// auto uniform = glProgram->getUniform("u_color");
|
||||
// if (uniform)
|
||||
// {
|
||||
// glProgram->setUniformLocationWith4f(uniform->location, _displayColor.x, _displayColor.y, _displayColor.z, _displayColor.w);
|
||||
// }
|
||||
//
|
||||
// if (_matrixPaletteSize && _matrixPalette)
|
||||
// {
|
||||
// uniform = glProgram->getUniform("u_matrixPalette");
|
||||
// if (uniform)
|
||||
// glProgram->setUniformLocationWith4fv(uniform->location, (const float*)_matrixPalette, _matrixPaletteSize);
|
||||
// }
|
||||
//
|
||||
// // Draw
|
||||
// glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
|
||||
//
|
||||
// CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount);
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
|
||||
|
||||
_glProgramState->setUniformVec4("u_color", _displayColor);
|
||||
|
||||
if (_matrixPaletteSize && _matrixPalette)
|
||||
|
@ -209,9 +186,7 @@ void MeshCommand::draw()
|
|||
|
||||
}
|
||||
|
||||
//_glProgramState->apply(_mv);
|
||||
|
||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
|
||||
_glProgramState->apply(_mv);
|
||||
|
||||
// Draw
|
||||
glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
|
||||
|
|
|
@ -326,21 +326,17 @@ void Renderer::visitRenderQueue(const RenderQueue& queue)
|
|||
{
|
||||
flush2D();
|
||||
auto cmd = static_cast<MeshCommand*>(command);
|
||||
// cmd->preDraw();
|
||||
// cmd->draw();
|
||||
// cmd->postDraw();
|
||||
cmd->execute();
|
||||
// if (_lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
|
||||
// {
|
||||
// flush3D();
|
||||
// cmd->preDraw();
|
||||
// cmd->draw();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// cmd->draw();
|
||||
// }
|
||||
// _lastBatchedMeshCommand = cmd;
|
||||
if (_lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
|
||||
{
|
||||
flush3D();
|
||||
cmd->preDraw();
|
||||
cmd->draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->draw();
|
||||
}
|
||||
_lastBatchedMeshCommand = cmd;
|
||||
// cmd->execute();
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue