diff --git a/cocos/2d/renderer/Renderer.cpp b/cocos/2d/renderer/Renderer.cpp index 85a231d5c4..7ee9486e2c 100644 --- a/cocos/2d/renderer/Renderer.cpp +++ b/cocos/2d/renderer/Renderer.cpp @@ -158,6 +158,7 @@ void Renderer::render() //Process RenderQueue for(size_t i = _renderStack.top().currentIndex; i < len; i++) { + _renderStack.top().currentIndex = _lastCommand = i; auto command = currRenderQueue[i]; if(command->getType() == QUAD_COMMAND) @@ -171,7 +172,7 @@ void Renderer::render() { memcpy(_quads + _numQuads, cmd->getQuad(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount()); _numQuads += cmd->getQuadCount(); - _lastCommand = i; + } else { @@ -202,8 +203,6 @@ void Renderer::render() { flush(); } - - _renderStack.top().currentIndex = i; } //Draw the batched quads @@ -232,14 +231,17 @@ void Renderer::render() void Renderer::drawBatchedQuads() { - //TODO we can improve the draw performance by inseart material switching command before hand. + //TODO we can improve the draw performance by insert material switching command before hand. int quadsToDraw = 0; int startQuad = 0; //Upload buffer to VBO if(_numQuads <= 0) + { + _firstCommand = _lastCommand; return; + } //Set VBO data glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); diff --git a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp index 33b503c56e..12b8a8077c 100644 --- a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp @@ -268,6 +268,7 @@ NewClippingNodeTest::NewClippingNodeTest() clipper->setContentSize( Size(200, 200) ); clipper->setAnchorPoint( Point(0.5, 0.5) ); clipper->setPosition( Point(s.width / 2, s.height / 2) ); + clipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); this->addChild(clipper); @@ -282,7 +283,9 @@ NewClippingNodeTest::NewClippingNodeTest() // stencil->drawPolygon(rectangle, 4, white, 1, white); // clipper->setStencil(stencil); + clipper->setAlphaThreshold(0.05f); auto stencil = NewSprite::create("Images/grossini.png"); + stencil->setScale(2.0f); stencil->setPosition(s.width/2, s.height/2); clipper->setStencil(stencil);