Renderer uses a float as a key

Instead of using a 64-bit int key with viewport, opaque and depth,
it only uses a 32-bit float with only the depth.
Saves time in:
 - No need to convert the 32-bit float into 24-bit int
 - keys are shorter
This commit is contained in:
Ricardo Quesada 2014-01-17 16:08:29 -08:00
parent 24130b2fed
commit 8931d968c0
44 changed files with 100 additions and 238 deletions

View File

@ -19,6 +19,7 @@ cocos2d-x-3.0final ?.? ?
[FIX] Renderer: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster
[FIX] Renderer: Performance improved in Sprite and SpriteBatchNode (and subclasses) sprites in about 20%
[FIX] Renderer: When note using VAO, call glBufferData() instead of glBufferSubData().
[FIX] Renderer: Uses a float as key with only the depth. Viewport, opaque are not needed now
[FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well
[FIX] Tests: TestCpp works with CMake on Windows.
[FIX] Tests: Sprites Performance Test has 4 new tests

View File

@ -152,7 +152,7 @@ void AtlasNode::draw(void)
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
_quadCommand.init(0,
_quadCommand.init(
_vertexZ,
_textureAtlas->getTexture()->getName(),
shader,

View File

@ -210,12 +210,12 @@ void ClippingNode::visit()
Renderer* renderer = Director::getInstance()->getRenderer();
_groupCommand.init(0,_vertexZ);
_groupCommand.init(_vertexZ);
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
_beforeVisitCmd.init(0,_vertexZ);
_beforeVisitCmd.init(_vertexZ);
_beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
renderer->addCommand(&_beforeVisitCmd);
if (_alphaThreshold < 1)
@ -238,7 +238,7 @@ void ClippingNode::visit()
}
_stencil->visit();
_afterDrawStencilCmd.init(0,_vertexZ);
_afterDrawStencilCmd.init(_vertexZ);
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
renderer->addCommand(&_afterDrawStencilCmd);
@ -268,7 +268,7 @@ void ClippingNode::visit()
this->draw();
}
_afterVisitCmd.init(0,_vertexZ);
_afterVisitCmd.init(_vertexZ);
_afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
renderer->addCommand(&_afterVisitCmd);

View File

@ -241,7 +241,7 @@ void DrawNode::render()
void DrawNode::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -666,7 +666,7 @@ void Label::onDraw()
void Label::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -565,7 +565,7 @@ void LayerColor::updateColor()
void LayerColor::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);

View File

@ -359,7 +359,7 @@ void MotionStreak::draw()
if(_nuPoints <= 1)
return;
kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV);
_customCommand.init(0,_vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);

View File

@ -92,7 +92,7 @@ void NodeGrid::visit()
Renderer* renderer = Director::getInstance()->getRenderer();
_groupCommand.init(0,_vertexZ);
_groupCommand.init(_vertexZ);
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
@ -104,7 +104,7 @@ void NodeGrid::visit()
_nodeGrid->set2DProjection();
}
_gridBeginCommand.init(0,_vertexZ);
_gridBeginCommand.init(_vertexZ);
_gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
renderer->addCommand(&_gridBeginCommand);
@ -152,7 +152,7 @@ void NodeGrid::visit()
director->setProjection(beforeProjectionType);
}
_gridEndCommand.init(0,_vertexZ);
_gridEndCommand.init(_vertexZ);
_gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this);
renderer->addCommand(&_gridEndCommand);

View File

@ -382,7 +382,7 @@ void ParticleBatchNode::draw(void)
return;
}
_batchCommand.init(0,
_batchCommand.init(
_vertexZ,
_textureAtlas->getTexture()->getName(),
_shaderProgram,

View File

@ -439,7 +439,7 @@ void ParticleSystemQuad::draw()
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
_quadCommand.init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
_quadCommand.init(_vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}

View File

@ -555,7 +555,7 @@ void ProgressTimer::draw()
if( ! _vertexData || ! _sprite)
return;
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -322,7 +322,7 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep
this->begin();
//clear screen
_beginWithClearCommand.init(0, _vertexZ);
_beginWithClearCommand.init(_vertexZ);
_beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand);
}
@ -340,7 +340,7 @@ void RenderTexture::clearDepth(float depthValue)
this->begin();
_clearDepthCommand.init(0, _vertexZ);
_clearDepthCommand.init(_vertexZ);
_clearDepthCommand.func = CC_CALLBACK_0(RenderTexture::onClearDepth, this);
Director::getInstance()->getRenderer()->addCommand(&_clearDepthCommand);
@ -605,7 +605,7 @@ void RenderTexture::draw()
begin();
//clear screen
_clearCommand.init(0, _vertexZ);
_clearCommand.init(_vertexZ);
_clearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
Director::getInstance()->getRenderer()->addCommand(&_clearCommand);
@ -648,13 +648,13 @@ void RenderTexture::begin()
(float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );
kmGLMultMatrix(&orthoMatrix);
_groupCommand.init(0, _vertexZ);
_groupCommand.init(_vertexZ);
Renderer *renderer = Director::getInstance()->getRenderer();
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
_beginCommand.init(0, _vertexZ);
_beginCommand.init(_vertexZ);
_beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this);
Director::getInstance()->getRenderer()->addCommand(&_beginCommand);
@ -662,7 +662,7 @@ void RenderTexture::begin()
void RenderTexture::end()
{
_endCommand.init(0, _vertexZ);
_endCommand.init(_vertexZ);
_endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this);
Renderer *renderer = Director::getInstance()->getRenderer();

View File

@ -670,7 +670,7 @@ void Sprite::updateTransform(void)
void Sprite::draw(void)
{
//TODO implement z order
_quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
_quadCommand.init(_vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
// if(culling())
{

View File

@ -356,7 +356,7 @@ void SpriteBatchNode::draw()
for(const auto &child: _children)
child->updateTransform();
_batchCommand.init(0,
_batchCommand.init(
_vertexZ,
_textureAtlas->getTexture()->getName(),
_shaderProgram,

View File

@ -98,23 +98,23 @@ void TransitionPageTurn::draw()
if( _isInSceneOnTop ) {
_outSceneProxy->visit();
_enableOffsetCmd.init(0, _vertexZ);
_enableOffsetCmd.init(_vertexZ);
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
_inSceneProxy->visit();
_disableOffsetCmd.init(0, _vertexZ);
_disableOffsetCmd.init(_vertexZ);
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
} else {
_inSceneProxy->visit();
_enableOffsetCmd.init(0, _vertexZ);
_enableOffsetCmd.init(_vertexZ);
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
_outSceneProxy->visit();
_disableOffsetCmd.init(0, _vertexZ);
_disableOffsetCmd.init(_vertexZ);
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
}

View File

@ -30,9 +30,7 @@
NS_CC_BEGIN
BatchCommand::BatchCommand()
: _viewport(0)
, _depth(0)
, _textureID(0)
: _textureID(0)
, _blendType(BlendFunc::DISABLE)
, _textureAtlas(nullptr)
{
@ -40,9 +38,8 @@ BatchCommand::BatchCommand()
_shader = nullptr;
}
void BatchCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform)
void BatchCommand::init(float depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform)
{
_viewport = viewport;
_depth = depth;
_textureID = textureID;
_blendType = blendType;
@ -57,59 +54,6 @@ BatchCommand::~BatchCommand()
{
}
int64_t BatchCommand::generateID()
{
_id = 0;
//Generate Material ID
//TODO fix shader ID generation
CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10");
//TODO fix texture ID generation
CCASSERT(_textureID < pow(2,18), "TextureID is greater than 2^18");
//TODO fix blend id generation
int blendID = 0;
if(_blendType == BlendFunc::DISABLE)
{
blendID = 0;
}
else if(_blendType == BlendFunc::ALPHA_PREMULTIPLIED)
{
blendID = 1;
}
else if(_blendType == BlendFunc::ALPHA_NON_PREMULTIPLIED)
{
blendID = 2;
}
else if(_blendType == BlendFunc::ADDITIVE)
{
blendID = 3;
}
else
{
blendID = 4;
}
//TODO Material ID should be part of the ID
//
// Temporal hack (later, these 32-bits should be packed in 24-bits
//
// +---------------------+-------------------+----------------------+
// | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) |
// +---------------------+-------------------+----------------------+
_materialID = (int32_t)_shader->getProgram() << 22
| (int32_t)blendID << 18
| (int32_t)_textureID << 0;
//Generate RenderCommandID
_id = (int64_t)_viewport << 61
| (int64_t)1 << 60 //translucent
| (int64_t)_depth << 36;
return _id;
}
void BatchCommand::execute()
{
// Set material

View File

@ -43,26 +43,13 @@ public:
BatchCommand();
~BatchCommand();
void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform);
// +----------+----------+-----+-----------------------------------+
// | | | | | |
// | ViewPort | Transluc | | Depth | Material ID |
// | 3 bits | 1 bit | | 24 bits | 24 bit2 |
// +----------+----------+-----+----------------+------------------+
virtual int64_t generateID();
void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform);
void execute();
protected:
int32_t _materialID;
//Key Data
int _viewport; /// Which view port it belongs to
//TODO use material to determine if it's translucent
int32_t _depth;
//Maternal
GLuint _textureID;

View File

@ -28,15 +28,12 @@ NS_CC_BEGIN
CustomCommand::CustomCommand()
: func(nullptr)
, _viewport(0)
, _depth(0)
{
_type = RenderCommand::Type::CUSTOM_COMMAND;
}
void CustomCommand::init(int viewport, int32_t depth)
void CustomCommand::init(float depth)
{
_viewport = viewport;
_depth = depth;
}
@ -45,17 +42,6 @@ CustomCommand::~CustomCommand()
}
int64_t CustomCommand::generateID()
{
_id = 0;
_id = (int64_t)_viewport << 61
| (int64_t)1 << 60 // translucent
| (int64_t)_depth << 36;
return _id;
}
void CustomCommand::execute()
{
if(func)

View File

@ -39,14 +39,7 @@ public:
public:
void init(int viewport, int32_t depth);
// +----------+----------+-----+-----------------------------------+
// | | | | | |
// | ViewPort | Transluc | | Depth | |
// | 3 bits | 1 bit | | 24 bits | |
// +----------+----------+-----+----------------+------------------+
virtual int64_t generateID();
void init(float depth);
void execute();
@ -54,8 +47,6 @@ public:
std::function<void()> func;
protected:
int _viewport;
int32_t _depth;
};
NS_CC_END

View File

@ -86,16 +86,13 @@ void GroupCommandManager::releaseGroupID(int groupID)
}
GroupCommand::GroupCommand()
: _viewport(0)
, _depth(0)
{
_type = RenderCommand::Type::GROUP_COMMAND;
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
}
void GroupCommand::init(int viewport, int32_t depth)
void GroupCommand::init(float depth)
{
_viewport = viewport;
_depth = depth;
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
@ -106,15 +103,4 @@ GroupCommand::~GroupCommand()
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
}
int64_t GroupCommand::generateID()
{
_id = 0;
_id = (int64_t)_viewport << 61
| (int64_t)1 << 60 // translucent
| (int64_t)_depth << 36;
return _id;
}
NS_CC_END

View File

@ -58,21 +58,12 @@ public:
public:
void init(int viewport, int32_t depth);
// +----------+----------+-----+-----------------------------------+
// | | | | | |
// | ViewPort | Transluc | | Depth | |
// | 3 bits | 1 bit | | 24 bits | |
// +----------+----------+-----+----------------+------------------+
virtual int64_t generateID() override;
void init(float depth);
inline bool isTranslucent() {return true;}
inline int getRenderQueueID() {return _renderQueueID;}
protected:
int _viewport;
int32_t _depth;
int _renderQueueID;
};

View File

@ -29,9 +29,7 @@
NS_CC_BEGIN
QuadCommand::QuadCommand()
:_viewport(0)
,_depth(0)
,_textureID(0)
:_textureID(0)
,_blendType(BlendFunc::DISABLE)
,_quadsCount(0)
{
@ -40,9 +38,8 @@ QuadCommand::QuadCommand()
_quads = nullptr;
}
void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv)
void QuadCommand::init(float depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv)
{
_viewport = viewport;
_depth = depth;
_textureID = textureID;
_blendType = blendType;
@ -52,16 +49,16 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram*
_quads = quad;
_mv = mv;
generateMaterialID();
}
QuadCommand::~QuadCommand()
{
}
int64_t QuadCommand::generateID()
void QuadCommand::generateMaterialID()
{
_id = 0;
//Generate Material ID
//TODO fix shader ID generation
CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10");
@ -99,16 +96,9 @@ int64_t QuadCommand::generateID()
// | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) |
// +---------------------+-------------------+----------------------+
_materialID = (int32_t)_shader->getProgram() << 22
| (int32_t)blendID << 18
| (int32_t)_textureID << 0;
//Generate RenderCommandID
_id = (int64_t)_viewport << 61
| (int64_t)1 << 60 //translucent
| (int64_t)_depth << 36;
return _id;
_materialID = (uint32_t)_shader->getProgram() << 22
| (uint32_t)blendID << 18
| (uint32_t)_textureID << 0;
}
void QuadCommand::useMaterial()

View File

@ -41,21 +41,15 @@ public:
QuadCommand();
~QuadCommand();
void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount,
const kmMat4& mv);
// +----------+----------+-----+-----------------------------------+
// | | | | | |
// | ViewPort | Transluc | | Depth | Material ID |
// | 3 bits | 1 bit | | 24 bits | 24 bit2 |
// +----------+----------+-----+----------------+------------------+
virtual int64_t generateID();
void useMaterial();
//TODO use material to decide if it is translucent
inline bool isTranslucent() const { return true; }
void generateMaterialID();
inline uint32_t getMaterialID() const { return _materialID; }
inline GLuint getTextureID() const { return _textureID; }
@ -73,12 +67,6 @@ public:
protected:
uint32_t _materialID;
//Key Data
int _viewport; /// Which view port it belongs to
//TODO use material to determine if it's translucent
int32_t _depth;
//Maternal
GLuint _textureID;

View File

@ -28,9 +28,9 @@
NS_CC_BEGIN
RenderCommand::RenderCommand()
: _type(RenderCommand::Type::UNKNOWN_COMMAND)
, _depth(0)
{
_id = 0;
_type = RenderCommand::Type::UNKNOWN_COMMAND;
}
RenderCommand::~RenderCommand()
@ -57,9 +57,7 @@ void printBits(ssize_t const size, void const * const ptr)
void RenderCommand::printID()
{
printf("CommandID: ");
printBits(sizeof(_id), &_id);
printf("\n");
printf("Command Depth: %f\n", _depth);
}
NS_CC_END

View File

@ -33,7 +33,9 @@
NS_CC_BEGIN
//TODO make RenderCommand inherent from Object
/** Base class of the RenderCommand hierarchy.
The Renderer knows how to render RenderCommands.
*/
class RenderCommand
{
public:
@ -47,10 +49,8 @@ public:
GROUP_COMMAND,
};
virtual int64_t generateID() = 0;
/** Get Render Command Id */
inline int64_t getID() { return _id; }
inline float getDepth() { return _depth; }
/** Returns the Command type */
inline Type getType() { return _type; }
@ -61,9 +61,11 @@ protected:
void printID();
//Generated IDs
int64_t _id; /// used for sorting render commands
// Type used in order to avoid dynamic cast, faster
Type _type;
// commands are sort by depth
float _depth;
};
NS_CC_END

View File

@ -185,8 +185,6 @@ void Renderer::addCommand(RenderCommand* command, int renderQueue)
{
CCASSERT(renderQueue >=0, "Invalid render queue");
CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type");
command->generateID();
_renderGroups[renderQueue].push_back(command);
}
@ -209,7 +207,7 @@ int Renderer::createRenderQueue()
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
{
return a->getID() < b->getID();
return a->getDepth() < b->getDepth();
}
void Renderer::render()

View File

@ -156,7 +156,7 @@ void BatchNode::draw()
void BatchNode::generateGroupCommand()
{
Renderer* renderer = Director::getInstance()->getRenderer();
_groupCommand->init(0,_vertexZ);
_groupCommand->init(_vertexZ);
renderer->addCommand(_groupCommand);
renderer->pushGroup(_groupCommand->getRenderQueueID());

View File

@ -225,7 +225,7 @@ void Skin::draw()
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
//TODO implement z order
_quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
_quadCommand.init(_vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}

View File

@ -131,7 +131,7 @@ void Skeleton::draw()
kmGLMatrixMode(KM_GL_MODELVIEW);
kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix);
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -210,18 +210,18 @@ void Layout::stencilClippingVisit()
Renderer* renderer = Director::getInstance()->getRenderer();
_groupCommand.init(0,_vertexZ);
_groupCommand.init(_vertexZ);
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
_beforeVisitCmdStencil.init(0,_vertexZ);
_beforeVisitCmdStencil.init(_vertexZ);
_beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this);
renderer->addCommand(&_beforeVisitCmdStencil);
_clippingStencil->visit();
_afterDrawStencilCmd.init(0,_vertexZ);
_afterDrawStencilCmd.init(_vertexZ);
_afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this);
renderer->addCommand(&_afterDrawStencilCmd);
@ -251,7 +251,7 @@ void Layout::stencilClippingVisit()
this->draw();
}
_afterVisitCmdStencil.init(0,_vertexZ);
_afterVisitCmdStencil.init(_vertexZ);
_afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this);
renderer->addCommand(&_afterVisitCmdStencil);
@ -336,13 +336,13 @@ void Layout::scissorClippingVisit()
{
Renderer* renderer = Director::getInstance()->getRenderer();
_beforeVisitCmdScissor.init(0, _vertexZ);
_beforeVisitCmdScissor.init(_vertexZ);
_beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this);
renderer->addCommand(&_beforeVisitCmdScissor);
Node::visit();
_afterVisitCmdScissor.init(0, _vertexZ);
_afterVisitCmdScissor.init(_vertexZ);
_afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this);
renderer->addCommand(&_afterVisitCmdScissor);
}

View File

@ -494,7 +494,7 @@ void ScrollView::addChild(Node * child, int zOrder, int tag)
void ScrollView::beforeDraw()
{
_beforeDrawCommand.init(0, _vertexZ);
_beforeDrawCommand.init(_vertexZ);
_beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand);
}
@ -529,7 +529,7 @@ void ScrollView::onBeforeDraw()
void ScrollView::afterDraw()
{
_afterDrawCommand.init(0, _vertexZ);
_afterDrawCommand.init(_vertexZ);
_afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand);
}

View File

@ -1314,7 +1314,7 @@ void ActionFollow::onEnter()
void ActionFollow::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
@ -1630,7 +1630,7 @@ void ActionCatmullRomStacked::draw()
kmGLPopMatrix();
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
@ -1745,7 +1745,7 @@ void ActionCardinalSplineStacked::draw()
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
kmGLPopMatrix();
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
@ -2107,7 +2107,7 @@ void ActionCatmullRom::draw()
kmGLPopMatrix();
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
@ -2207,7 +2207,7 @@ void ActionCardinalSpline::draw()
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
kmGLPopMatrix();
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -211,7 +211,7 @@ void Box2DView::draw()
{
Layer::draw();
_customCmd.init(0, _vertexZ);
_customCmd.init(_vertexZ);
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCmd);
}

View File

@ -611,7 +611,7 @@ void RawStencilBufferTest::draw()
auto iter = _renderCmds.begin();
iter->init(0, _vertexZ);
iter->init(_vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this);
renderer->addCommand(&(*iter));
++iter;
@ -628,7 +628,7 @@ void RawStencilBufferTest::draw()
spritePoint.y = 0;
_sprites.at(i)->setPosition( spritePoint );
iter->init(0, _vertexZ);
iter->init(_vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint);
renderer->addCommand(&(*iter));
++iter;
@ -638,7 +638,7 @@ void RawStencilBufferTest::draw()
_sprites.at(i)->visit();
kmGLPopMatrix();
iter->init(0, _vertexZ);
iter->init(_vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint);
renderer->addCommand(&(*iter));
++iter;
@ -649,7 +649,7 @@ void RawStencilBufferTest::draw()
kmGLPopMatrix();
}
iter->init(0, _vertexZ);
iter->init(_vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this);
renderer->addCommand(&(*iter));

View File

@ -116,7 +116,7 @@ DrawPrimitivesTest::DrawPrimitivesTest()
void DrawPrimitivesTest::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -1067,7 +1067,7 @@ void TestColliderDetector::update(float delta)
}
void TestColliderDetector::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
@ -1108,7 +1108,7 @@ std::string TestBoundingBox::title() const
}
void TestBoundingBox::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);

View File

@ -210,7 +210,7 @@ void Atlas1::draw()
// GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// GL_TEXTURE_2D
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
@ -526,7 +526,7 @@ Atlas4::Atlas4()
void Atlas4::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
@ -1612,7 +1612,7 @@ std::string LabelBMFontBounds::subtitle() const
void LabelBMFontBounds::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -302,7 +302,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions()
void LabelFNTSpriteActions::draw()
{
_renderCmd.init(0, _vertexZ);
_renderCmd.init(_vertexZ);
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
@ -912,7 +912,7 @@ std::string LabelFNTBounds::subtitle() const
void LabelFNTBounds::draw()
{
_renderCmd.init(0, _vertexZ);
_renderCmd.init(_vertexZ);
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}

View File

@ -932,7 +932,7 @@ protected:
void MySprite::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -470,19 +470,19 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil()
void RenderTextureTestDepthStencil::draw()
{
_renderCmds[0].init(0, _vertexZ);
_renderCmds[0].init(_vertexZ);
_renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[0]);
_rend->beginWithClear(0, 0, 0, 0, 0, 0);
_renderCmds[1].init(0, _vertexZ);
_renderCmds[1].init(_vertexZ);
_renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[1]);
_spriteDS->visit();
_renderCmds[2].init(0, _vertexZ);
_renderCmds[2].init(_vertexZ);
_renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[2]);
@ -490,7 +490,7 @@ void RenderTextureTestDepthStencil::draw()
_rend->end();
_renderCmds[3].init(0, _vertexZ);
_renderCmds[3].init(_vertexZ);
_renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[3]);
@ -638,7 +638,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea
void SpriteRenderTextureBug::SimpleSprite::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);

View File

@ -193,7 +193,7 @@ void ShaderNode::setPosition(const Point &newPosition)
void ShaderNode::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
@ -526,7 +526,7 @@ void SpriteBlur::initProgram()
void SpriteBlur::draw()
{
_customCommand.init(0, _vertexZ);
_customCommand.init(_vertexZ);
_customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -178,7 +178,7 @@ void ShaderSprite::initShader()
void ShaderSprite::draw()
{
_renderCommand.init(0, _vertexZ);
_renderCommand.init(_vertexZ);
_renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCommand);

View File

@ -1794,7 +1794,7 @@ void TextureDrawAtPoint::draw()
{
TextureDemo::draw();
_renderCmd.init(0, _vertexZ);
_renderCmd.init(_vertexZ);
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
@ -1835,7 +1835,7 @@ void TextureDrawInRect::draw()
{
TextureDemo::draw();
_renderCmd.init(0, _vertexZ);
_renderCmd.init(_vertexZ);
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);

View File

@ -599,7 +599,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
void TMXOrthoObjectsTest::draw()
{
_renderCmd.init(0, _vertexZ);
_renderCmd.init(_vertexZ);
_renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
@ -672,7 +672,7 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
void TMXIsoObjectsTest::draw()
{
_renderCmd.init(0, _vertexZ);
_renderCmd.init(_vertexZ);
_renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
@ -1504,7 +1504,7 @@ TMXGIDObjectsTest::TMXGIDObjectsTest()
void TMXGIDObjectsTest::draw()
{
_renderCmd.init(0, _vertexZ);
_renderCmd.init(_vertexZ);
_renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}