diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 51208939b0..fefbdd3f69 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -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); diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index a399d2f964..870da5ba5b 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -326,21 +326,17 @@ void Renderer::visitRenderQueue(const RenderQueue& queue) { flush2D(); auto cmd = static_cast(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