mirror of https://github.com/axmolengine/axmol.git
1. add assert condition of rendering when adding command
2. fix bug: renderTexture->SpriteRenderTextureBug
This commit is contained in:
parent
588d825691
commit
51289e8a4c
|
@ -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 add command while rendering");
|
||||
_commandGroupStack.push(renderQueueID);
|
||||
}
|
||||
|
||||
void Renderer::popGroup()
|
||||
{
|
||||
CCASSERT(!_isRendering, "Cannot add command 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()
|
||||
|
|
|
@ -148,6 +148,8 @@ protected:
|
|||
// stats
|
||||
ssize_t _drawnBatches;
|
||||
ssize_t _drawnVertices;
|
||||
//flags to indicate 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