Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop

This commit is contained in:
zhangbin 2014-04-11 20:03:24 +08:00
commit d611cfb49f
7 changed files with 23 additions and 22 deletions

View File

@ -102,6 +102,7 @@ Renderer::Renderer()
:_lastMaterialID(0)
,_numQuads(0)
,_glViewAssigned(false)
,_isRendering(false)
#if CC_ENABLE_CACHE_TEXTURE_DATA
,_cacheTextureListener(nullptr)
#endif
@ -236,6 +237,7 @@ void Renderer::addCommand(RenderCommand* command)
void Renderer::addCommand(RenderCommand* command, int renderQueue)
{
CCASSERT(!_isRendering, "Cannot add command while rendering");
CCASSERT(renderQueue >=0, "Invalid render queue");
CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type");
_renderGroups[renderQueue].push_back(command);
@ -243,11 +245,13 @@ void Renderer::addCommand(RenderCommand* command, int renderQueue)
void Renderer::pushGroup(int renderQueueID)
{
CCASSERT(!_isRendering, "Cannot change render queue while rendering");
_commandGroupStack.push(renderQueueID);
}
void Renderer::popGroup()
{
CCASSERT(!_isRendering, "Cannot change render queue while rendering");
_commandGroupStack.pop();
}
@ -317,7 +321,8 @@ void Renderer::render()
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//TODO setup camera or MVP
_isRendering = true;
if (_glViewAssigned)
{
// cleanup
@ -333,6 +338,7 @@ void Renderer::render()
flush();
}
clean();
_isRendering = false;
}
void Renderer::clean()

View File

@ -148,6 +148,8 @@ protected:
// stats
ssize_t _drawnBatches;
ssize_t _drawnVertices;
//the flag for checking whether renderer is rendering
bool _isRendering;
#if CC_ENABLE_CACHE_TEXTURE_DATA
EventListenerCustom* _cacheTextureListener;

View File

@ -304,7 +304,7 @@ void ProtectedNode::visit(Renderer* renderer, const kmMat4 &parentTransform, boo
{
auto node = _children.at(i);
if ( node && node->getZOrder() < 0 )
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
else
break;
@ -314,7 +314,7 @@ void ProtectedNode::visit(Renderer* renderer, const kmMat4 &parentTransform, boo
{
auto node = _protectedChildren.at(j);
if ( node && node->getZOrder() < 0 )
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
else
break;

View File

@ -790,7 +790,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const kmMat4 &parentTransf
{
auto node = _children.at(i);
if ( node && node->getZOrder() < 0 )
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
else
break;
@ -800,7 +800,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const kmMat4 &parentTransf
{
auto node = _protectedChildren.at(j);
if ( node && node->getZOrder() < 0 )
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
else
break;

View File

@ -670,6 +670,10 @@ std::string RenderTextureTargetNode::subtitle() const
// SpriteRenderTextureBug
SpriteRenderTextureBug::SimpleSprite::SimpleSprite() : _rt(nullptr) {}
SpriteRenderTextureBug::SimpleSprite::~SimpleSprite()
{
CC_SAFE_RELEASE(_rt);
}
SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::create(const char* filename, const Rect &rect)
{
@ -687,16 +691,6 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea
}
void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this);
renderer->addCommand(&_customCommand);
Sprite::draw(renderer, transform, transformUpdated);
}
void SpriteRenderTextureBug::SimpleSprite::onBeforeDraw()
{
if (_rt == nullptr)
{
@ -706,6 +700,9 @@ void SpriteRenderTextureBug::SimpleSprite::onBeforeDraw()
}
_rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f);
_rt->end();
Sprite::draw(renderer, transform, transformUpdated);
}
SpriteRenderTextureBug::SpriteRenderTextureBug()

View File

@ -139,14 +139,10 @@ public:
public:
static SimpleSprite* create(const char* filename, const Rect &rect);
SimpleSprite();
~SimpleSprite();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated);
protected:
void onBeforeDraw();
public:
RenderTexture *_rt;
protected:
CustomCommand _customCommand;
};
public:

View File

@ -118,9 +118,9 @@ void TileDemo::onEnter()
BaseTest::onEnter();
}
void TileMapTestScene::onExit()
void TileDemo::onExit()
{
TileDemo::onExit();
BaseTest::onExit();
Director::getInstance()->setDepthTest(false);
}
void TileDemo::restartCallback(Ref* sender)