mirror of https://github.com/axmolengine/axmol.git
Adds new ParticleTest for auto-batching
This commit is contained in:
parent
3bacd45240
commit
b50a787f6d
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue