diff --git a/cocos/2d/CCFastTMXLayer.cpp b/cocos/2d/CCFastTMXLayer.cpp index 56a0677115..344b859b7c 100644 --- a/cocos/2d/CCFastTMXLayer.cpp +++ b/cocos/2d/CCFastTMXLayer.cpp @@ -176,8 +176,9 @@ void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) if(iter.second->getCount() > 0) { auto& cmd = _renderCommands[index++]; - cmd.init(iter.first); - cmd.func = CC_CALLBACK_0(TMXLayer::onDraw, this, iter.second); + //cmd.init(iter.first); + //cmd.func = CC_CALLBACK_0(TMXLayer::onDraw, this, iter.second); + cmd.init(iter.first, _texture->getName(), getGLProgramState(), BlendFunc::ALPHA_NON_PREMULTIPLIED, iter.second, _modelViewTransform); renderer->addCommand(&cmd); } } diff --git a/cocos/2d/CCFastTMXLayer.h b/cocos/2d/CCFastTMXLayer.h index b76971338d..db1e0b7e3a 100644 --- a/cocos/2d/CCFastTMXLayer.h +++ b/cocos/2d/CCFastTMXLayer.h @@ -247,7 +247,7 @@ protected: std::vector _indices; std::map _indicesVertexZOffsets; std::unordered_map _indicesVertexZNumber; - std::vector _renderCommands; + std::vector _renderCommands; bool _dirty; VertexBuffer* _vertexBuffer; diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index b7c9b47e23..2eca2d9ead 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -30,6 +30,7 @@ #include "renderer/CCBatchCommand.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCGroupCommand.h" +#include "renderer/CCPrimitiveCommand.h" #include "renderer/CCGLProgramCache.h" #include "renderer/ccGLStateCache.h" #include "renderer/CCMeshCommand.h" @@ -321,6 +322,12 @@ void Renderer::visitRenderQueue(const RenderQueue& queue) auto cmd = static_cast(command); cmd->execute(); } + else if(RenderCommand::Type::PRIMITIVE_COMMAND == commandType) + { + flush(); + auto cmd = static_cast(command); + cmd->execute(); + } else if (RenderCommand::Type::MESH_COMMAND == commandType) { flush2D(); diff --git a/cocos/renderer/CCVertexIndexData.cpp b/cocos/renderer/CCVertexIndexData.cpp index 385a716deb..198287511e 100644 --- a/cocos/renderer/CCVertexIndexData.cpp +++ b/cocos/renderer/CCVertexIndexData.cpp @@ -152,9 +152,17 @@ GLint VertexData::getGLSemanticBinding(VertexSemantic semantic) void VertexData::use() { + uint32_t flags; for(auto& element : _vertexStreams) { - glEnableVertexAttribArray((GLint)element.second._stream._semantic); + flags = flags | (1 << element.second._stream._semantic); + } + + GL::enableVertexAttribs(flags); + + for(auto& element : _vertexStreams) + { + //glEnableVertexAttribArray((GLint)element.second._stream._semantic); glBindBuffer(GL_ARRAY_BUFFER, element.second._buffer->getVBO()); glVertexAttribPointer(GLint(element.second._stream._semantic),element.second._stream._size, element.second._stream._type,element.second._stream._normalize, element.second._buffer->getSizePerVertex(), (GLvoid*)element.second._stream._offset);