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);
|
GL::blendFunc(_blendType.src, _blendType.dst);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
|
||||||
//
|
//
|
||||||
_glProgramState->apply(_mv);
|
//_glProgramState->apply(_mv);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
|
||||||
}
|
}
|
||||||
void MeshCommand::draw()
|
void MeshCommand::draw()
|
||||||
{
|
{
|
||||||
if (_matrixPalette)
|
|
||||||
{
|
|
||||||
CCLOG("skin");
|
|
||||||
}
|
|
||||||
auto glProgram = _glProgramState->getGLProgram();
|
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);
|
_glProgramState->setUniformVec4("u_color", _displayColor);
|
||||||
|
|
||||||
if (_matrixPaletteSize && _matrixPalette)
|
if (_matrixPaletteSize && _matrixPalette)
|
||||||
|
@ -209,9 +186,7 @@ void MeshCommand::draw()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//_glProgramState->apply(_mv);
|
_glProgramState->apply(_mv);
|
||||||
|
|
||||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
|
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
|
glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
|
||||||
|
|
|
@ -326,21 +326,17 @@ void Renderer::visitRenderQueue(const RenderQueue& queue)
|
||||||
{
|
{
|
||||||
flush2D();
|
flush2D();
|
||||||
auto cmd = static_cast<MeshCommand*>(command);
|
auto cmd = static_cast<MeshCommand*>(command);
|
||||||
// cmd->preDraw();
|
if (_lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
|
||||||
// cmd->draw();
|
{
|
||||||
// cmd->postDraw();
|
flush3D();
|
||||||
cmd->execute();
|
cmd->preDraw();
|
||||||
// if (_lastBatchedMeshCommand == nullptr || _lastBatchedMeshCommand->getMaterialID() != cmd->getMaterialID())
|
cmd->draw();
|
||||||
// {
|
}
|
||||||
// flush3D();
|
else
|
||||||
// cmd->preDraw();
|
{
|
||||||
// cmd->draw();
|
cmd->draw();
|
||||||
// }
|
}
|
||||||
// else
|
_lastBatchedMeshCommand = cmd;
|
||||||
// {
|
|
||||||
// cmd->draw();
|
|
||||||
// }
|
|
||||||
// _lastBatchedMeshCommand = cmd;
|
|
||||||
// cmd->execute();
|
// cmd->execute();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue