Adds new ParticleTest for auto-batching

This commit is contained in:
Ricardo Quesada 2014-02-28 22:03:36 -08:00
parent 3bacd45240
commit b50a787f6d
4 changed files with 47 additions and 4 deletions

View File

@ -532,7 +532,8 @@ void ProgressTimer::onDraw()
if(_type == Type::RADIAL)
{
glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount);
}
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_vertexDataCount);
}
else if (_type == Type::BAR)
{
if (!_reverseDirection)

View File

@ -958,8 +958,6 @@ enum
static int sceneIdx = -1;
#define MAX_LAYER 45
Layer* createParticleLayer(int nIndex)
{
switch(nIndex)
@ -1010,12 +1008,14 @@ Layer* createParticleLayer(int nIndex)
case 42: return new PremultipliedAlphaTest();
case 43: return new PremultipliedAlphaTest2();
case 44: return new Issue3990();
case 45: return new ParticleAutoBatching();
default:
break;
}
return NULL;
}
#define MAX_LAYER 46
Layer* nextParticleAction()
@ -1922,6 +1922,40 @@ std::string Issue3990::subtitle() const
return "Show '998' or '999' at bottom right side";
}
//
// ParticleAutoBatching
//
void ParticleAutoBatching::onEnter()
{
ParticleDemo::onEnter();
_color->setColor(Color3B::BLACK);
this->removeChild(_background, true);
_background = NULL;
Size s = Director::getInstance()->getWinSize();
for(int i=0; i<10; i++) {
auto particle = ParticleSystemQuad::create("Particles/SmallSun.plist");
particle->setTotalParticles(100);
particle->setPosition(Point(i*s.width/11, s.height/2));
this->addChild(particle ,10);
}
}
std::string ParticleAutoBatching::title() const
{
return "AutoBatching";
}
std::string ParticleAutoBatching::subtitle() const
{
return "All 10 particles should be drawin in one batch";
}
//
// main
//
void ParticleTestScene::runThisTest()
{

View File

@ -309,4 +309,12 @@ public:
virtual std::string subtitle() const override;
};
class ParticleAutoBatching : public ParticleDemo
{
public:
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
#endif

View File

@ -212,8 +212,8 @@ void ShaderSprite::onDraw()
diff = offsetof( V3F_C4B_T2F, colors);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4);
}
class NormalSprite : public ShaderSprite, public ShaderSpriteCreator<NormalSprite>