mirror of https://github.com/axmolengine/axmol.git
Adds new ParticleTest for auto-batching
This commit is contained in:
parent
3bacd45240
commit
b50a787f6d
|
@ -532,6 +532,7 @@ void ProgressTimer::onDraw()
|
||||||
if(_type == Type::RADIAL)
|
if(_type == Type::RADIAL)
|
||||||
{
|
{
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount);
|
glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount);
|
||||||
|
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_vertexDataCount);
|
||||||
}
|
}
|
||||||
else if (_type == Type::BAR)
|
else if (_type == Type::BAR)
|
||||||
{
|
{
|
||||||
|
|
|
@ -958,8 +958,6 @@ enum
|
||||||
|
|
||||||
static int sceneIdx = -1;
|
static int sceneIdx = -1;
|
||||||
|
|
||||||
#define MAX_LAYER 45
|
|
||||||
|
|
||||||
Layer* createParticleLayer(int nIndex)
|
Layer* createParticleLayer(int nIndex)
|
||||||
{
|
{
|
||||||
switch(nIndex)
|
switch(nIndex)
|
||||||
|
@ -1010,12 +1008,14 @@ Layer* createParticleLayer(int nIndex)
|
||||||
case 42: return new PremultipliedAlphaTest();
|
case 42: return new PremultipliedAlphaTest();
|
||||||
case 43: return new PremultipliedAlphaTest2();
|
case 43: return new PremultipliedAlphaTest2();
|
||||||
case 44: return new Issue3990();
|
case 44: return new Issue3990();
|
||||||
|
case 45: return new ParticleAutoBatching();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#define MAX_LAYER 46
|
||||||
|
|
||||||
|
|
||||||
Layer* nextParticleAction()
|
Layer* nextParticleAction()
|
||||||
|
@ -1922,6 +1922,40 @@ std::string Issue3990::subtitle() const
|
||||||
return "Show '998' or '999' at bottom right side";
|
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()
|
void ParticleTestScene::runThisTest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -309,4 +309,12 @@ public:
|
||||||
virtual std::string subtitle() const override;
|
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
|
#endif
|
||||||
|
|
|
@ -212,8 +212,8 @@ void ShaderSprite::onDraw()
|
||||||
diff = offsetof( V3F_C4B_T2F, colors);
|
diff = offsetof( V3F_C4B_T2F, colors);
|
||||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
|
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
|
||||||
|
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
class NormalSprite : public ShaderSprite, public ShaderSpriteCreator<NormalSprite>
|
class NormalSprite : public ShaderSprite, public ShaderSpriteCreator<NormalSprite>
|
||||||
|
|
Loading…
Reference in New Issue