mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3 from dabingnn/newRendererCommandPool
New renderer command pool
This commit is contained in:
commit
3eea1d0ef3
|
@ -695,7 +695,8 @@ void LayerColor::updateColor()
|
|||
void LayerColor::draw()
|
||||
{
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
|
||||
CustomCommand* cmd = new CustomCommand(0, _vertexZ);
|
||||
CustomCommand* cmd = new CustomCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(LayerColor::onDraw, this);
|
||||
Renderer::getInstance()->addCommand(cmd);
|
||||
}
|
||||
|
|
|
@ -415,7 +415,8 @@ void ParticleSystemQuad::draw()
|
|||
CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad");
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
|
||||
|
||||
CustomCommand* cmd = new CustomCommand(0, _vertexZ);
|
||||
CustomCommand* cmd = new CustomCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(ParticleSystemQuad::onDraw, this);
|
||||
Renderer::getInstance()->addCommand(cmd);
|
||||
|
||||
|
|
|
@ -663,8 +663,8 @@ void Sprite::draw(void)
|
|||
{
|
||||
updateQuadVertices();
|
||||
//TODO implement z order
|
||||
QuadCommand* renderCommand = new QuadCommand(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1);
|
||||
|
||||
QuadCommand* renderCommand = new QuadCommand();
|
||||
renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1);
|
||||
Renderer::getInstance()->addCommand(renderCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ void NewDrawNode::draw()
|
|||
{
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
|
||||
|
||||
CustomCommand* cmd = new CustomCommand(0, _vertexZ);
|
||||
CustomCommand* cmd = new CustomCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(NewDrawNode::onDraw, this);
|
||||
Renderer::getInstance()->addCommand(cmd);
|
||||
}
|
||||
|
|
|
@ -142,7 +142,8 @@ void NewSprite::draw(void)
|
|||
}
|
||||
|
||||
//TODO implement z order
|
||||
QuadCommand* renderCommand = new QuadCommand(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1);
|
||||
QuadCommand* renderCommand = new QuadCommand();
|
||||
renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1);
|
||||
|
||||
Renderer::getInstance()->addCommand(renderCommand);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ void NewSpriteBatchNode::draw()
|
|||
|
||||
arrayMakeObjectsPerformSelector(_children, updateTransform, NewSprite*);
|
||||
|
||||
QuadCommand* cmd = new QuadCommand(0, _vertexZ, _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, _textureAtlas->getQuads(), _textureAtlas->getTotalQuads());
|
||||
QuadCommand* cmd = new QuadCommand();
|
||||
cmd->init(0, _vertexZ, _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, _textureAtlas->getQuads(), _textureAtlas->getTotalQuads());
|
||||
Renderer::getInstance()->addCommand(cmd);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,15 +7,21 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
CustomCommand::CustomCommand(int viewport, int32_t depth)
|
||||
CustomCommand::CustomCommand()
|
||||
:RenderCommand()
|
||||
, _viewport(viewport)
|
||||
, _depth(depth)
|
||||
, _viewport(0)
|
||||
, _depth(0)
|
||||
, func(nullptr)
|
||||
{
|
||||
_type = CUSTOM_COMMAND;
|
||||
}
|
||||
|
||||
void CustomCommand::init(int viewport, int32_t depth)
|
||||
{
|
||||
_viewport = viewport;
|
||||
_depth = depth;
|
||||
}
|
||||
|
||||
CustomCommand::~CustomCommand()
|
||||
{
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ using namespace std;
|
|||
class CustomCommand : public RenderCommand
|
||||
{
|
||||
public:
|
||||
CustomCommand(int viewport, int32_t depth);
|
||||
CustomCommand();
|
||||
void init(int viewport, int32_t depth);
|
||||
~CustomCommand();
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
|
|
|
@ -63,15 +63,23 @@ void GroupCommandManager::releaseGroupID(int groupID)
|
|||
_groupMapping[groupID] = false;
|
||||
}
|
||||
|
||||
GroupCommand::GroupCommand(int viewport, int32_t depth)
|
||||
GroupCommand::GroupCommand()
|
||||
:RenderCommand()
|
||||
, _viewport(viewport)
|
||||
, _depth(depth)
|
||||
, _viewport(0)
|
||||
, _depth(0)
|
||||
{
|
||||
_type = GROUP_COMMAND;
|
||||
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
|
||||
}
|
||||
|
||||
void GroupCommand::init(int viewport, int32_t depth)
|
||||
{
|
||||
_viewport = viewport;
|
||||
_depth = depth;
|
||||
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
|
||||
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
|
||||
}
|
||||
|
||||
GroupCommand::~GroupCommand()
|
||||
{
|
||||
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
|
||||
|
|
|
@ -35,7 +35,8 @@ class GroupCommand : public RenderCommand
|
|||
{
|
||||
|
||||
public:
|
||||
GroupCommand(int viewport, int32_t depth);
|
||||
GroupCommand();
|
||||
void init(int viewport, int32_t depth);
|
||||
~GroupCommand();
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
|
|
|
@ -85,24 +85,28 @@ void NewClippingNode::visit()
|
|||
|
||||
Renderer* renderer = Renderer::getInstance();
|
||||
|
||||
GroupCommand* groupCommand = new GroupCommand(0,_vertexZ);
|
||||
GroupCommand* groupCommand = new GroupCommand();
|
||||
groupCommand->init(0,_vertexZ);
|
||||
renderer->addCommand(groupCommand);
|
||||
|
||||
renderer->pushGroup(groupCommand->getRenderQueueID());
|
||||
|
||||
CustomCommand* beforeVisitCmd = new CustomCommand(0,_vertexZ);
|
||||
CustomCommand* beforeVisitCmd = new CustomCommand();
|
||||
beforeVisitCmd->init(0,_vertexZ);
|
||||
beforeVisitCmd->func = CC_CALLBACK_0(NewClippingNode::beforeVisit, this);
|
||||
renderer->addCommand(beforeVisitCmd, groupCommand->getRenderQueueID());
|
||||
|
||||
_stencil->visit();
|
||||
|
||||
CustomCommand* afterDrawStencilCmd = new CustomCommand(0,_vertexZ);
|
||||
CustomCommand* afterDrawStencilCmd = new CustomCommand();
|
||||
afterDrawStencilCmd->init(0,_vertexZ);
|
||||
afterDrawStencilCmd->func = CC_CALLBACK_0(NewClippingNode::afterDrawStencil, this);
|
||||
renderer->addCommand(afterDrawStencilCmd, groupCommand->getRenderQueueID());
|
||||
|
||||
Node::visit();
|
||||
|
||||
CustomCommand* afterVisitCmd = new CustomCommand(0,_vertexZ);
|
||||
CustomCommand* afterVisitCmd = new CustomCommand();
|
||||
afterVisitCmd->init(0,_vertexZ);
|
||||
afterVisitCmd->func = CC_CALLBACK_0(NewClippingNode::afterVisit, this);
|
||||
renderer->addCommand(afterVisitCmd, groupCommand->getRenderQueueID());
|
||||
|
||||
|
|
|
@ -8,16 +8,28 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
QuadCommand::QuadCommand(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, int quadCount)
|
||||
QuadCommand::QuadCommand()
|
||||
:RenderCommand()
|
||||
,_viewport(viewport)
|
||||
,_depth(depth)
|
||||
,_textureID(textureID)
|
||||
,_blendType(blendType)
|
||||
,_quadCount(quadCount)
|
||||
,_viewport(0)
|
||||
,_depth(0)
|
||||
,_textureID(0)
|
||||
,_blendType(BlendFunc::DISABLE)
|
||||
,_quadCount(0)
|
||||
{
|
||||
_type = QUAD_COMMAND;
|
||||
_shader = nullptr;
|
||||
_quad = nullptr;
|
||||
}
|
||||
|
||||
void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, int quadCount)
|
||||
{
|
||||
_viewport = viewport;
|
||||
_depth = depth;
|
||||
_textureID = textureID;
|
||||
_blendType = blendType;
|
||||
_quadCount = quadCount;
|
||||
_shader = shader;
|
||||
free(_quad);
|
||||
_quad = (V3F_C4B_T2F_Quad*)malloc(sizeof(V3F_C4B_T2F_Quad) * quadCount);
|
||||
memcpy(_quad, quad, sizeof(V3F_C4B_T2F_Quad) * quadCount);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ NS_CC_BEGIN
|
|||
class QuadCommand : public RenderCommand
|
||||
{
|
||||
public:
|
||||
QuadCommand(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, int quadCount);
|
||||
QuadCommand();
|
||||
void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, int quadCount);
|
||||
~QuadCommand();
|
||||
|
||||
// +----------+----------+-----+-----------------------------------+
|
||||
|
|
Loading…
Reference in New Issue