mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop
This commit is contained in:
commit
b3bc69fccc
|
@ -40,7 +40,7 @@ void AppDelegate::applicationDidEnterBackground() {
|
|||
Director::getInstance()->stopAnimation();
|
||||
|
||||
// if you use SimpleAudioEngine, it must be pause
|
||||
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
// SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
||||
}
|
||||
|
||||
// this function will be called when the app is active again
|
||||
|
@ -48,5 +48,5 @@ void AppDelegate::applicationWillEnterForeground() {
|
|||
Director::getInstance()->startAnimation();
|
||||
|
||||
// if you use SimpleAudioEngine, it must resume here
|
||||
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
// SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
||||
}
|
||||
|
|
|
@ -591,6 +591,11 @@ void RawStencilBufferTest::setup()
|
|||
sprite->setAnchorPoint( Point(0.5, 0) );
|
||||
sprite->setScale( 2.5f );
|
||||
_sprites.pushBack(sprite);
|
||||
|
||||
Sprite* sprite2 = Sprite::create(s_pathGrossini);
|
||||
sprite2->setAnchorPoint( Point(0.5, 0) );
|
||||
sprite2->setScale( 2.5f );
|
||||
_spritesStencil.pushBack(sprite2);
|
||||
}
|
||||
|
||||
Director::getInstance()->setAlphaBlending(true);
|
||||
|
@ -624,7 +629,8 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo
|
|||
spritePoint.x += planeSize.x / 2;
|
||||
spritePoint.y = 0;
|
||||
_sprites.at(i)->setPosition( spritePoint );
|
||||
|
||||
_spritesStencil.at(i)->setPosition( spritePoint );
|
||||
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint);
|
||||
renderer->addCommand(&(*iter));
|
||||
|
@ -632,7 +638,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo
|
|||
|
||||
kmGLPushMatrix();
|
||||
_modelViewTransform = this->transform(transform);
|
||||
_sprites.at(i)->visit(renderer, _modelViewTransform, transformUpdated);
|
||||
_spritesStencil.at(i)->visit(renderer, _modelViewTransform, transformUpdated);
|
||||
kmGLPopMatrix();
|
||||
|
||||
iter->init(_globalZOrder);
|
||||
|
@ -736,6 +742,15 @@ void RawStencilBufferTest3::setupStencilForDrawingOnPlane(GLint plane)
|
|||
RawStencilBufferTest::setupStencilForDrawingOnPlane(plane);
|
||||
}
|
||||
|
||||
void RawStencilBufferTestAlphaTest::setup()
|
||||
{
|
||||
RawStencilBufferTest::setup();
|
||||
auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV);
|
||||
for(int i = 0; i < _planeCount; ++i)
|
||||
{
|
||||
_spritesStencil.at(i)->setShaderProgram(program );
|
||||
}
|
||||
}
|
||||
//@implementation RawStencilBufferTest4
|
||||
|
||||
std::string RawStencilBufferTest4::subtitle() const
|
||||
|
@ -752,14 +767,10 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane)
|
|||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
||||
#else
|
||||
auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||
program->use();
|
||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
||||
for(int i = 0; i < _planeCount; ++i)
|
||||
{
|
||||
_sprites.at(i)->setShaderProgram(program );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -789,13 +800,10 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane)
|
|||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
||||
#else
|
||||
auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||
program->use();
|
||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
||||
for(int i = 0; i < _planeCount; ++i)
|
||||
{
|
||||
_sprites.at(i)->setShaderProgram(program );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -818,6 +826,7 @@ std::string RawStencilBufferTest6::subtitle() const
|
|||
|
||||
void RawStencilBufferTest6::setup()
|
||||
{
|
||||
RawStencilBufferTestAlphaTest::setup();
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
auto winPoint = Point(Director::getInstance()->getWinSize());
|
||||
//by default, glReadPixels will pack data with 4 bytes allignment
|
||||
|
@ -840,7 +849,6 @@ void RawStencilBufferTest6::setup()
|
|||
this->addChild(clearToMaskLabel);
|
||||
#endif
|
||||
glStencilMask(~0);
|
||||
RawStencilBufferTest::setup();
|
||||
}
|
||||
|
||||
void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane)
|
||||
|
@ -858,13 +866,10 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane)
|
|||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
||||
#else
|
||||
auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||
program->use();
|
||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
||||
for(int i = 0; i < _planeCount; ++i)
|
||||
{
|
||||
_sprites.at(i)->setShaderProgram(program );
|
||||
}
|
||||
#endif
|
||||
glFlush();
|
||||
}
|
||||
|
|
|
@ -166,6 +166,7 @@ protected:
|
|||
void onBeforeDrawSprite(int planeIndex, const Point& pt);
|
||||
protected:
|
||||
Vector<Sprite*> _sprites;
|
||||
Vector<Sprite*> _spritesStencil;
|
||||
};
|
||||
|
||||
class RawStencilBufferTest2 : public RawStencilBufferTest
|
||||
|
@ -188,7 +189,13 @@ public:
|
|||
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
||||
};
|
||||
|
||||
class RawStencilBufferTest4 : public RawStencilBufferTest
|
||||
class RawStencilBufferTestAlphaTest : public RawStencilBufferTest
|
||||
{
|
||||
public:
|
||||
virtual void setup() override;
|
||||
};
|
||||
|
||||
class RawStencilBufferTest4 : public RawStencilBufferTestAlphaTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(RawStencilBufferTest4);
|
||||
|
@ -198,7 +205,7 @@ public:
|
|||
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
||||
};
|
||||
|
||||
class RawStencilBufferTest5 : public RawStencilBufferTest
|
||||
class RawStencilBufferTest5 : public RawStencilBufferTestAlphaTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(RawStencilBufferTest5);
|
||||
|
@ -208,13 +215,12 @@ public:
|
|||
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
||||
};
|
||||
|
||||
class RawStencilBufferTest6 : public RawStencilBufferTest
|
||||
class RawStencilBufferTest6 : public RawStencilBufferTestAlphaTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(RawStencilBufferTest6);
|
||||
|
||||
virtual void setup() override;
|
||||
virtual std::string subtitle() const override;
|
||||
virtual void setup();
|
||||
virtual void setupStencilForClippingOnPlane(GLint plane);
|
||||
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
1f20f88e2a2985963fc6a2d89ea07be41e8e74d0
|
||||
cd9c6d873768d211ba6ec6fe6d405f0bb1e2a135
|
|
@ -27,7 +27,7 @@ Sprite1.__index = Sprite1
|
|||
function Sprite1.addNewSpriteWithCoords(layer, point)
|
||||
local idx = math.floor(math.random() * 1400 / 100)
|
||||
local x = math.floor(math.mod(idx,5) * 85)
|
||||
local y = math.floor(idx / 5 * 121)
|
||||
local y = math.floor(idx / 5) * 121
|
||||
|
||||
local sprite = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(x,y,85,121) )
|
||||
layer:addChild( sprite )
|
||||
|
@ -88,7 +88,7 @@ function SpriteBatchNode1.addNewSpriteWithCoords(layer, point)
|
|||
local BatchNode = layer:getChildByTag( kTagSpriteBatchNode )
|
||||
local idx = math.floor(math.random() * 1400 / 100)
|
||||
local x = math.floor(math.mod(idx,5) * 85)
|
||||
local y = math.floor(idx / 5 * 121)
|
||||
local y = math.floor(idx / 5) * 121
|
||||
|
||||
local sprite = cc.Sprite:createWithTexture(BatchNode:getTexture(), cc.rect(x,y,85,121) )
|
||||
layer:addChild( sprite )
|
||||
|
|
Loading…
Reference in New Issue