Test clipping node with alpha

This commit is contained in:
Nite Luo 2013-11-18 15:52:47 -08:00
parent c288e5ef9c
commit abb011f0ef
2 changed files with 9 additions and 4 deletions

View File

@ -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]);

View File

@ -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);