mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6240 from dabingnn/develop_add_rendererAssert
Trigger an assert if a command is added while render is rendering.
This commit is contained in:
commit
b40773f6d0
|
@ -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,6 +321,7 @@ void Renderer::render()
|
|||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//TODO setup camera or MVP
|
||||
_isRendering = true;
|
||||
|
||||
if (_glViewAssigned)
|
||||
{
|
||||
|
@ -333,6 +338,7 @@ void Renderer::render()
|
|||
flush();
|
||||
}
|
||||
clean();
|
||||
_isRendering = false;
|
||||
}
|
||||
|
||||
void Renderer::clean()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue