change QuadCommand variable to class member.

This commit is contained in:
boyu0 2013-12-26 16:36:03 +08:00
parent 9bd609a8fb
commit 2fb0179293
16 changed files with 35 additions and 27 deletions

View File

@ -34,7 +34,7 @@ THE SOFTWARE.
#include "CCDirector.h"
#include "TransformUtils.h"
#include "CCRenderer.h"
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
// external
#include "kazmath/GL/matrix.h"
@ -151,8 +151,7 @@ void AtlasNode::draw(void)
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
QuadCommand* cmd = new QuadCommand();
cmd->init(0,
_quadCommand.init(0,
_vertexZ,
_textureAtlas->getTexture()->getName(),
shader,
@ -161,7 +160,7 @@ void AtlasNode::draw(void)
_textureAtlas->getTotalQuads(),
_modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(cmd);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}

View File

@ -30,6 +30,7 @@ THE SOFTWARE.
#include "CCNode.h"
#include "CCProtocols.h"
#include "ccTypes.h"
#include "renderer/CCQuadCommand.h"
NS_CC_BEGIN
@ -130,6 +131,8 @@ protected:
GLint _uniformColor;
// This varible is only used for LabelAtlas FPS display. So plz don't modify its value.
bool _ignoreContentScaleFactor;
// quad command
QuadCommand _quadCommand;
private:
CC_DISALLOW_COPY_AND_ASSIGN(AtlasNode);

View File

@ -42,7 +42,7 @@
#include "platform/CCFileUtils.h"
#include "kazmath/GL/matrix.h"
#include "CCProfiling.h"
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
#include "CCRenderer.h"
NS_CC_BEGIN
@ -392,8 +392,7 @@ void ParticleBatchNode::draw(void)
kmMat4 mv;
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
QuadCommand* cmd = new QuadCommand();
cmd->init(0,
_quadCommand.init(0,
_vertexZ,
_textureAtlas->getTexture()->getName(),
shader,
@ -401,7 +400,7 @@ void ParticleBatchNode::draw(void)
_textureAtlas->getQuads(),
_textureAtlas->getTotalQuads(),
mv);
Director::getInstance()->getRenderer()->addCommand(cmd);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
CC_PROFILER_STOP("CCParticleBatchNode - draw");
}

View File

@ -31,6 +31,7 @@
#include "CCNode.h"
#include "CCProtocols.h"
#include "renderer/CCQuadCommand.h"
NS_CC_BEGIN
@ -140,6 +141,8 @@ private:
private:
/** the blend function used for drawing the quads */
BlendFunc _blendFunc;
// quad command
QuadCommand _quadCommand;
};
// end of particle_nodes group

View File

@ -39,7 +39,7 @@ THE SOFTWARE.
#include "CCEventType.h"
#include "CCConfiguration.h"
#include "CCRenderer.h"
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
#include "CCCustomCommand.h"
// extern
@ -443,9 +443,8 @@ void ParticleSystemQuad::draw()
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
QuadCommand* cmd = new QuadCommand();
cmd->init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(cmd);
_quadCommand.init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}
}

View File

@ -28,6 +28,7 @@ THE SOFTWARE.
#define __CC_PARTICLE_SYSTEM_QUAD_H__
#include "CCParticleSystem.h"
#include "renderer/CCQuadCommand.h"
NS_CC_BEGIN
@ -151,6 +152,8 @@ protected:
GLuint _buffersVBO[2]; //0: vertex 1: indices
kmMat4 _transformMatrix;
QuadCommand _quadCommand; // quad command
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleSystemQuad);
};

View File

@ -45,7 +45,7 @@ THE SOFTWARE.
#include "TransformUtils.h"
#include "CCProfiling.h"
#include "CCRenderer.h"
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
#include "CCFrustum.h"
// external
@ -671,8 +671,7 @@ void Sprite::updateTransform(void)
void Sprite::draw(void)
{
//TODO implement z order
QuadCommand* renderCommand = new QuadCommand();
renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
_quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
// if(!culling())
// {
@ -680,7 +679,7 @@ void Sprite::draw(void)
// }
// else
{
Director::getInstance()->getRenderer()->addCommand(renderCommand);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}
}

View File

@ -37,6 +37,7 @@ THE SOFTWARE.
#include "CCGLBufferedNode.h"
#endif // EMSCRIPTEN
#include "CCPhysicsBody.h"
#include "renderer/CCQuadCommand.h"
#include "kazmath/kazmath.h"
NS_CC_BEGIN
@ -545,6 +546,7 @@ protected:
//
BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance
Texture2D* _texture; /// Texture2D object that is used to render the sprite
QuadCommand _quadCommand; /// quad command
//
// Shared data

View File

@ -43,7 +43,7 @@ THE SOFTWARE.
#include "CCLayer.h"
#include "CCScene.h"
#include "CCRenderer.h"
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
// external
#include "kazmath/GL/matrix.h"
@ -360,8 +360,7 @@ void SpriteBatchNode::draw()
kmMat4 mv;
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
QuadCommand* cmd = new QuadCommand();
cmd->init(0,
_quadCommand.init(0,
_vertexZ,
_textureAtlas->getTexture()->getName(),
shader,
@ -369,7 +368,7 @@ void SpriteBatchNode::draw()
_textureAtlas->getQuads(),
_textureAtlas->getTotalQuads(),
mv);
Director::getInstance()->getRenderer()->addCommand(cmd);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}
void SpriteBatchNode::increaseAtlasCapacity(void)

View File

@ -34,6 +34,7 @@ THE SOFTWARE.
#include "CCProtocols.h"
#include "CCTextureAtlas.h"
#include "ccMacros.h"
#include "renderer/CCQuadCommand.h"
NS_CC_BEGIN
@ -187,6 +188,7 @@ protected:
TextureAtlas *_textureAtlas;
BlendFunc _blendFunc;
QuadCommand _quadCommand; // quad command
// all descendants: children, grand children, etc...
// There is not need to retain/release these objects, since they are already retained by _children

View File

@ -23,7 +23,7 @@
****************************************************************************/
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
#include "ccGLStateCache.h"
NS_CC_BEGIN

View File

@ -108,7 +108,6 @@ public:
void pushBackCommand(QuadCommand* ptr)
{
delete ptr;
}
};

View File

@ -26,7 +26,7 @@
#include "CCShaderCache.h"
#include "ccGLStateCache.h"
#include "CCCustomCommand.h"
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
#include "CCGroupCommand.h"
#include "CCConfiguration.h"
#include "CCNotificationCenter.h"

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
#include "cocostudio/CCDataReaderHelper.h"
#include "cocostudio/CCDatas.h"
#include "cocostudio/CCSkin.h"
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
#include "CCRenderer.h"
#include "CCGroupCommand.h"

View File

@ -219,9 +219,8 @@ void Skin::draw()
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
//TODO implement z order
QuadCommand* renderCommand = new QuadCommand();
renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
Director::getInstance()->getRenderer()->addCommand(renderCommand);
_quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}
void Skin::setBone(Bone *bone)

View File

@ -27,6 +27,7 @@ THE SOFTWARE.
#include "cocostudio/CCArmatureDefine.h"
#include "cocostudio/CCBone.h"
#include "renderer/CCQuadCommand.h"
namespace cocostudio {
@ -74,6 +75,7 @@ protected:
Armature *_armature;
kmMat4 _skinTransform;
std::string _displayName;
cocos2d::QuadCommand _quadCommand; // quad command
};
}