зеркало из https://github.com/microsoft/cocos2d-x.git
Merge pull request #5572 from ricardoquesada/ondraw_updated
onDraw() updated
This commit is contained in:
Коммит
4fe827e46b
|
@ -205,8 +205,20 @@ bool DrawNode::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void DrawNode::render()
|
||||
void DrawNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void DrawNode::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
||||
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
|
||||
|
||||
if (_dirty)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
|
@ -220,40 +232,25 @@ void DrawNode::render()
|
|||
else
|
||||
{
|
||||
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
||||
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
// vertex
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
|
||||
|
||||
|
||||
// color
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
|
||||
|
||||
|
||||
// texcood
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
|
||||
}
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, _bufferCount);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
|
||||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCount);
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
}
|
||||
|
||||
void DrawNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void DrawNode::onDraw()
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
|
||||
|
||||
render();
|
||||
}
|
||||
|
||||
void DrawNode::drawDot(const Point &pos, float radius, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 2*3;
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
*/
|
||||
void setBlendFunc(const BlendFunc &blendFunc);
|
||||
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
|
@ -100,7 +100,6 @@ protected:
|
|||
virtual bool init();
|
||||
|
||||
void ensureCapacity(int count);
|
||||
void render();
|
||||
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
|
|
|
@ -723,7 +723,7 @@ void Label::setFontScale(float fontScale)
|
|||
Node::setScale(_fontScale);
|
||||
}
|
||||
|
||||
void Label::onDraw()
|
||||
void Label::onDraw(const kmMat4& transform, bool transformUpdated)
|
||||
{
|
||||
CC_PROFILER_START("Label - draw");
|
||||
|
||||
|
@ -751,7 +751,7 @@ void Label::onDraw()
|
|||
drawShadowWithoutBlur();
|
||||
}
|
||||
|
||||
_shaderProgram->setUniformsForBuiltins(_modelViewTransform);
|
||||
_shaderProgram->setUniformsForBuiltins(transform);
|
||||
|
||||
for(const auto &child: _children)
|
||||
{
|
||||
|
@ -809,7 +809,7 @@ void Label::drawShadowWithoutBlur()
|
|||
void Label::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,11 +154,12 @@ public:
|
|||
virtual std::string getDescription() const override;
|
||||
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
virtual void onDraw();
|
||||
|
||||
FontAtlas* getFontAtlas() const {return _fontAtlas;}
|
||||
|
||||
protected:
|
||||
void onDraw(const kmMat4& transform, bool transformUpdated);
|
||||
|
||||
struct LetterInfo
|
||||
{
|
||||
FontLetterDefinition def;
|
||||
|
|
|
@ -584,7 +584,7 @@ void LayerColor::updateColor()
|
|||
void LayerColor::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
|
||||
for(int i = 0; i < 4; ++i)
|
||||
|
@ -594,12 +594,12 @@ void LayerColor::draw(Renderer *renderer, const kmMat4 &transform, bool transfor
|
|||
kmVec3TransformCoord(&pos, &pos, &_modelViewTransform);
|
||||
_noMVPVertices[i] = Vertex3F(pos.x,pos.y,pos.z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LayerColor::onDraw()
|
||||
void LayerColor::onDraw(const kmMat4& transform, bool transformUpdated)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
||||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR );
|
||||
//
|
||||
|
|
|
@ -266,8 +266,7 @@ public:
|
|||
// Overrides
|
||||
//
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
virtual void onDraw();
|
||||
|
||||
|
||||
virtual void setContentSize(const Size & var) override;
|
||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||
/**
|
||||
|
@ -289,7 +288,8 @@ public:
|
|||
protected:
|
||||
LayerColor();
|
||||
virtual ~LayerColor();
|
||||
virtual bool init();
|
||||
void onDraw(const kmMat4& transform, bool transformUpdated);
|
||||
bool init();
|
||||
bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
|
||||
bool initWithColor(const Color4B& color);
|
||||
|
||||
|
|
|
@ -325,10 +325,10 @@ void MotionStreak::reset()
|
|||
_nuPoints = 0;
|
||||
}
|
||||
|
||||
void MotionStreak::onDraw()
|
||||
void MotionStreak::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(_modelViewTransform);
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
||||
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
|
||||
|
@ -360,9 +360,8 @@ void MotionStreak::draw(Renderer *renderer, const kmMat4 &transform, bool transf
|
|||
if(_nuPoints <= 1)
|
||||
return;
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
|
||||
protected:
|
||||
//renderer callback
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
MotionStreak();
|
||||
virtual ~MotionStreak();
|
||||
|
||||
|
|
|
@ -501,10 +501,11 @@ Point ProgressTimer::boundaryTexCoord(char index)
|
|||
return Point::ZERO;
|
||||
}
|
||||
|
||||
void ProgressTimer::onDraw()
|
||||
void ProgressTimer::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
|
||||
CC_NODE_DRAW_SETUP();
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
||||
GL::blendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst );
|
||||
|
||||
|
@ -557,7 +558,7 @@ void ProgressTimer::draw(Renderer *renderer, const kmMat4 &transform, bool trans
|
|||
return;
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,8 +131,7 @@ protected:
|
|||
|
||||
/** Initializes a progress timer with the sprite as the shape the timer goes through */
|
||||
bool initWithSprite(Sprite* sp);
|
||||
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
Tex2F textureCoordFromAlphaPoint(Point alpha);
|
||||
Vertex2F vertexFromAlphaPoint(Point alpha);
|
||||
|
|
|
@ -381,7 +381,7 @@ void Armature::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool t
|
|||
{
|
||||
if (_parentBone == nullptr && _batchNode == nullptr)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
// CC_NODE_DRAW_SETUP();
|
||||
}
|
||||
|
||||
|
||||
|
@ -418,7 +418,7 @@ void Armature::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool t
|
|||
default:
|
||||
{
|
||||
node->visit(renderer, transform, transformUpdated);
|
||||
CC_NODE_DRAW_SETUP();
|
||||
// CC_NODE_DRAW_SETUP();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ void Armature::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool t
|
|||
else if(Node *node = dynamic_cast<Node *>(object))
|
||||
{
|
||||
node->visit(renderer, transform, transformUpdated);
|
||||
CC_NODE_DRAW_SETUP();
|
||||
// CC_NODE_DRAW_SETUP();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ void BatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transform
|
|||
return;
|
||||
}
|
||||
|
||||
CC_NODE_DRAW_SETUP();
|
||||
// CC_NODE_DRAW_SETUP();
|
||||
|
||||
bool pushed = false;
|
||||
for(auto object : _children)
|
||||
|
|
|
@ -129,13 +129,14 @@ void Skeleton::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool t
|
|||
{
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void Skeleton::onDraw ()
|
||||
void Skeleton::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
||||
GL::blendFunc(blendFunc.src, blendFunc.dst);
|
||||
Color3B color = getColor();
|
||||
|
@ -193,7 +194,7 @@ void Skeleton::onDraw ()
|
|||
|
||||
if(debugBones || debugSlots) {
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
if (debugSlots) {
|
||||
// Slots.
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
virtual void update (float deltaTime) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
virtual cocos2d::Rect getBoundingBox () const override;
|
||||
|
|
|
@ -1345,13 +1345,16 @@ void ActionFollow::onEnter()
|
|||
void ActionFollow::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this, transform, transformUpdated);
|
||||
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void ActionFollow::onDraw()
|
||||
void ActionFollow::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto winSize = Director::getInstance()->getWinSize();
|
||||
|
||||
float x = winSize.width*2 - 100;
|
||||
|
@ -1359,6 +1362,8 @@ void ActionFollow::onDraw()
|
|||
|
||||
Point vertices[] = { Point(5,5), Point(x-5,5), Point(x-5,y-5), Point(5,y-5) };
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
std::string ActionFollow::subtitle() const
|
||||
|
@ -1661,11 +1666,11 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const kmMat4 &transform,
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void ActionCatmullRomStacked::onDraw()
|
||||
void ActionCatmullRomStacked::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
|
@ -1776,11 +1781,11 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transfo
|
|||
kmGLPopMatrix();
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void ActionCardinalSplineStacked::onDraw()
|
||||
void ActionCardinalSplineStacked::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
|
@ -2138,12 +2143,12 @@ void ActionCatmullRom::draw(Renderer *renderer, const kmMat4 &transform, bool tr
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
|
||||
void ActionCatmullRom::onDraw()
|
||||
void ActionCatmullRom::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
|
@ -2238,11 +2243,11 @@ void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, boo
|
|||
kmGLPopMatrix();
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void ActionCardinalSpline::onDraw()
|
||||
void ActionCardinalSpline::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
|
|
|
@ -379,9 +379,8 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
|
||||
private:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
CustomCommand _customCommand;
|
||||
};
|
||||
|
||||
|
@ -455,12 +454,13 @@ public:
|
|||
virtual void onEnter() override;
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
//cached data and callback
|
||||
kmMat4 _modelViewMV1;
|
||||
kmMat4 _modelViewMV2;
|
||||
void onDraw();
|
||||
private:
|
||||
PointArray* _array1;
|
||||
PointArray* _array2;
|
||||
CustomCommand _customCommand;
|
||||
|
@ -476,13 +476,14 @@ public:
|
|||
virtual void onEnter() override;
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
private:
|
||||
PointArray* _array;
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
kmMat4 _modelViewMV1;
|
||||
kmMat4 _modelViewMV2;
|
||||
CustomCommand _customCommand;
|
||||
PointArray* _array;
|
||||
};
|
||||
|
||||
class Issue1305 : public ActionsDemo
|
||||
|
@ -570,14 +571,15 @@ public:
|
|||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
virtual std::string subtitle() const override;
|
||||
virtual std::string title() const override;
|
||||
private:
|
||||
PointArray *_array1;
|
||||
PointArray *_array2;
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
kmMat4 _modelViewMV1;
|
||||
kmMat4 _modelViewMV2;
|
||||
CustomCommand _customCommand;
|
||||
PointArray *_array1;
|
||||
PointArray *_array2;
|
||||
};
|
||||
|
||||
class ActionCardinalSpline : public ActionsDemo
|
||||
|
@ -591,10 +593,11 @@ public:
|
|||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
virtual std::string subtitle() const override;
|
||||
virtual std::string title() const override;
|
||||
private:
|
||||
PointArray *_array;
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
PointArray *_array;
|
||||
kmMat4 _modelViewMV1;
|
||||
kmMat4 _modelViewMV2;
|
||||
CustomCommand _customCommand;
|
||||
|
|
|
@ -205,21 +205,21 @@ void Box2DView::draw(Renderer *renderer, const kmMat4 &transform, bool transform
|
|||
Layer::draw(renderer, transform, transformUpdated);
|
||||
|
||||
_customCmd.init(_globalZOrder);
|
||||
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this);
|
||||
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCmd);
|
||||
}
|
||||
|
||||
void Box2DView::onDraw()
|
||||
void Box2DView::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||
m_test->Step(&settings);
|
||||
m_test->m_world->DrawDebugData();
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
Box2DView::~Box2DView()
|
||||
|
|
|
@ -51,8 +51,9 @@ public:
|
|||
|
||||
static Box2DView* viewWithEntryID(int entryId);
|
||||
protected:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
CustomCommand _customCmd;
|
||||
void onDraw();
|
||||
};
|
||||
|
||||
class Box2dTestBedScene : public TestScene
|
||||
|
|
|
@ -117,15 +117,14 @@ DrawPrimitivesTest::DrawPrimitivesTest()
|
|||
void DrawPrimitivesTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void DrawPrimitivesTest::onDraw()
|
||||
void DrawPrimitivesTest::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
//draw
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
@ -236,7 +235,7 @@ void DrawPrimitivesTest::onDraw()
|
|||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
//end draw
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
string DrawPrimitivesTest::title() const
|
||||
|
|
|
@ -28,9 +28,9 @@ public:
|
|||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
protected:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
CustomCommand _customCommand;
|
||||
};
|
||||
|
||||
|
|
|
@ -1068,21 +1068,19 @@ void TestColliderDetector::update(float delta)
|
|||
void TestColliderDetector::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void TestColliderDetector::onDraw()
|
||||
void TestColliderDetector::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
armature2->drawContour();
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1109,15 +1107,15 @@ std::string TestBoundingBox::title() const
|
|||
void TestBoundingBox::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
|
||||
}
|
||||
|
||||
void TestBoundingBox::onDraw()
|
||||
void TestBoundingBox::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(_modelViewTransform);
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
||||
rect = armature->getBoundingBox();
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ public:
|
|||
virtual std::string title() const override;
|
||||
virtual void update(float delta);
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
|
||||
|
||||
|
@ -297,9 +297,10 @@ public:
|
|||
|
||||
cocostudio::Armature *armature;
|
||||
Rect rect;
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
protected:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
CustomCommand _customCommand;
|
||||
};
|
||||
|
||||
|
|
|
@ -208,19 +208,15 @@ Atlas1::~Atlas1()
|
|||
|
||||
void Atlas1::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
// GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// GL_TEXTURE_2D
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
|
||||
// [textureAtlas drawNumberOfQuads:3];
|
||||
|
||||
}
|
||||
|
||||
void Atlas1::onDraw()
|
||||
void Atlas1::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
_textureAtlas->drawQuads();
|
||||
}
|
||||
|
||||
|
@ -532,15 +528,20 @@ Atlas4::Atlas4()
|
|||
void Atlas4::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void Atlas4::onDraw()
|
||||
void Atlas4::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) );
|
||||
DrawPrimitives::drawLine( Point(s.width/2, 0), Point(s.width/2, s.height) );
|
||||
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
void Atlas4::step(float dt)
|
||||
|
@ -1618,12 +1619,15 @@ std::string LabelBMFontBounds::subtitle() const
|
|||
void LabelBMFontBounds::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void LabelBMFontBounds::onDraw()
|
||||
void LabelBMFontBounds::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto labelSize = label1->getContentSize();
|
||||
auto origin = Director::getInstance()->getWinSize();
|
||||
|
||||
|
@ -1638,6 +1642,8 @@ void LabelBMFontBounds::onDraw()
|
|||
Point(origin.width, labelSize.height + origin.height)
|
||||
};
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
// LabelBMFontCrashTest
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
protected:
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
protected:
|
||||
CustomCommand _customCommand;
|
||||
};
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
protected:
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
protected:
|
||||
CustomCommand _customCommand;
|
||||
};
|
||||
|
@ -381,7 +381,7 @@ public:
|
|||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
protected:
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
private:
|
||||
LabelBMFont *label1;
|
||||
CustomCommand _customCommand;
|
||||
|
|
|
@ -315,22 +315,21 @@ LabelFNTSpriteActions::LabelFNTSpriteActions()
|
|||
void LabelFNTSpriteActions::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
|
||||
}
|
||||
|
||||
void LabelFNTSpriteActions::onDraw()
|
||||
void LabelFNTSpriteActions::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) );
|
||||
DrawPrimitives::drawLine( Point(s.width/2, 0), Point(s.width/2, s.height) );
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
void LabelFNTSpriteActions::step(float dt)
|
||||
|
@ -932,15 +931,14 @@ std::string LabelFNTBounds::subtitle() const
|
|||
void LabelFNTBounds::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
}
|
||||
|
||||
void LabelFNTBounds::onDraw()
|
||||
void LabelFNTBounds::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto labelSize = label1->getContentSize();
|
||||
auto origin = Director::getInstance()->getWinSize();
|
||||
|
@ -957,7 +955,7 @@ void LabelFNTBounds::onDraw()
|
|||
};
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
LabelTTFLongLineWrapping::LabelTTFLongLineWrapping()
|
||||
|
@ -1554,12 +1552,11 @@ LabelTTFOldNew::LabelTTFOldNew()
|
|||
label2->setPosition(Point(s.width/2, delta * 2));
|
||||
}
|
||||
|
||||
void LabelTTFOldNew::onDraw()
|
||||
void LabelTTFOldNew::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto label1 = (Label*)getChildByTag(kTagBitmapAtlas1);
|
||||
auto labelSize = label1->getContentSize();
|
||||
auto origin = Director::getInstance()->getWinSize();
|
||||
|
@ -1594,13 +1591,13 @@ void LabelTTFOldNew::onDraw()
|
|||
DrawPrimitives::setDrawColor4B(Color4B::WHITE.r,Color4B::WHITE.g,Color4B::WHITE.b,Color4B::WHITE.a);
|
||||
DrawPrimitives::drawPoly(vertices2, 4, true);
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
void LabelTTFOldNew::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,10 @@ public:
|
|||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
};
|
||||
|
||||
class LabelFNTPadding : public AtlasDemoNew
|
||||
|
@ -226,11 +227,11 @@ public:
|
|||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
private:
|
||||
Label *label1;
|
||||
|
||||
protected:
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
Label *label1;
|
||||
};
|
||||
|
||||
class LabelTTFLongLineWrapping : public AtlasDemoNew
|
||||
|
@ -432,9 +433,10 @@ public:
|
|||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
};
|
||||
|
||||
class LabelTTFLargeText : public AtlasDemoNew
|
||||
|
|
|
@ -975,7 +975,7 @@ public:
|
|||
return sprite;
|
||||
}
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
protected:
|
||||
CustomCommand _customCommand;
|
||||
|
@ -985,13 +985,14 @@ protected:
|
|||
void MySprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void MySprite::onDraw()
|
||||
void MySprite::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
||||
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
|
||||
|
||||
|
@ -1013,7 +1014,6 @@ void MySprite::onDraw()
|
|||
diff = offsetof( V3F_C4B_T2F, colors);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
|
||||
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
|
|
@ -194,28 +194,26 @@ void ShaderNode::setPosition(const Point &newPosition)
|
|||
void ShaderNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void ShaderNode::onDraw()
|
||||
void ShaderNode::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
float w = SIZE_X, h = SIZE_Y;
|
||||
GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h};
|
||||
|
||||
//
|
||||
// Uniforms
|
||||
//
|
||||
getShaderProgram()->setUniformLocationWith2f(_uniformCenter, _center.x, _center.y);
|
||||
getShaderProgram()->setUniformLocationWith2f(_uniformResolution, _resolution.x, _resolution.y);
|
||||
auto shader = getShaderProgram();
|
||||
shader->use();
|
||||
shader->setUniformsForBuiltins(transform);
|
||||
shader->setUniformLocationWith2f(_uniformCenter, _center.x, _center.y);
|
||||
shader->setUniformLocationWith2f(_uniformResolution, _resolution.x, _resolution.y);
|
||||
|
||||
// time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version
|
||||
glUniform1f(_uniformTime, _time);
|
||||
|
||||
GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
|
||||
float w = SIZE_X, h = SIZE_Y;
|
||||
GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h};
|
||||
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
@ -439,8 +437,8 @@ public:
|
|||
static SpriteBlur* create(const char *pszFileName);
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
private:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
int _blurRadius;
|
||||
Point _pixelSize;
|
||||
|
||||
|
@ -535,11 +533,11 @@ void SpriteBlur::initProgram()
|
|||
void SpriteBlur::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
|
||||
_customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void SpriteBlur::onDraw()
|
||||
void SpriteBlur::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
BlendFunc blend = getBlendFunc();
|
||||
|
@ -547,7 +545,7 @@ void SpriteBlur::onDraw()
|
|||
|
||||
auto program = getShaderProgram();
|
||||
program->use();
|
||||
program->setUniformsForBuiltins();
|
||||
program->setUniformsForBuiltins(transform);
|
||||
program->setUniformLocationWith2f(pixelSizeLocation, _pixelSize.x, _pixelSize.y);
|
||||
program->setUniformLocationWith4f(coefficientLocation, _samplingRadius, _scale,_cons,_weightSum);
|
||||
|
||||
|
|
|
@ -126,9 +126,7 @@ public:
|
|||
static ShaderNode* shaderNodeWithVertex(const char *vert, const char *frag);
|
||||
|
||||
protected:
|
||||
void onDraw();
|
||||
|
||||
private:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
Vertex2F _center;
|
||||
Vertex2F _resolution;
|
||||
|
|
|
@ -123,7 +123,7 @@ protected:
|
|||
|
||||
protected:
|
||||
CustomCommand _renderCommand;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
};
|
||||
|
||||
|
@ -179,15 +179,17 @@ void ShaderSprite::initShader()
|
|||
void ShaderSprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_renderCommand.init(_globalZOrder);
|
||||
_renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this);
|
||||
_renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCommand);
|
||||
|
||||
}
|
||||
|
||||
void ShaderSprite::onDraw()
|
||||
void ShaderSprite::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
auto shader = getShaderProgram();
|
||||
shader->use();
|
||||
shader->setUniformsForBuiltins(transform);
|
||||
|
||||
setCustomUniforms();
|
||||
|
||||
GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
|
|
|
@ -1796,22 +1796,22 @@ void TextureDrawAtPoint::draw(Renderer *renderer, const kmMat4 &transform, bool
|
|||
TextureDemo::draw(renderer, transform, transformUpdated);
|
||||
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
|
||||
}
|
||||
|
||||
void TextureDrawAtPoint::onDraw()
|
||||
void TextureDrawAtPoint::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
_tex1->drawAtPoint(Point(s.width/2-50, s.height/2 - 50));
|
||||
_Tex2F->drawAtPoint(Point(s.width/2+50, s.height/2 - 50));
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
// TextureDrawInRect
|
||||
|
@ -1837,15 +1837,14 @@ void TextureDrawInRect::draw(Renderer *renderer, const kmMat4 &transform, bool t
|
|||
TextureDemo::draw(renderer, transform, transformUpdated);
|
||||
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
}
|
||||
|
||||
void TextureDrawInRect::onDraw()
|
||||
void TextureDrawInRect::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
|
@ -1855,7 +1854,7 @@ void TextureDrawInRect::onDraw()
|
|||
_tex1->drawInRect(rect1);
|
||||
_Tex2F->drawInRect(rect2);
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
std::string TextureDrawInRect::title() const
|
||||
|
|
|
@ -468,9 +468,9 @@ public:
|
|||
virtual void onEnter() override;
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
protected:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
private:
|
||||
Texture2D* _tex1, *_Tex2F;
|
||||
};
|
||||
|
||||
|
@ -484,9 +484,9 @@ public:
|
|||
virtual void onEnter() override;
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
protected:
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
private:
|
||||
Texture2D* _tex1, *_Tex2F;
|
||||
};
|
||||
|
||||
|
|
|
@ -758,15 +758,14 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
|
|||
void TMXOrthoObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
}
|
||||
|
||||
void TMXOrthoObjectsTest::onDraw()
|
||||
void TMXOrthoObjectsTest::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto map = static_cast<TMXTiledMap*>( getChildByTag(kTagTileMap) );
|
||||
auto pos = map->getPosition();
|
||||
|
@ -793,7 +792,7 @@ void TMXOrthoObjectsTest::onDraw()
|
|||
glLineWidth(1);
|
||||
}
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
std::string TMXOrthoObjectsTest::title() const
|
||||
|
@ -832,16 +831,15 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
|
|||
void TMXIsoObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
}
|
||||
|
||||
void TMXIsoObjectsTest::onDraw()
|
||||
void TMXIsoObjectsTest::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto map = (TMXTiledMap*) getChildByTag(kTagTileMap);
|
||||
auto pos = map->getPosition();
|
||||
auto group = map->getObjectGroup("Object Group 1");
|
||||
|
@ -865,7 +863,7 @@ void TMXIsoObjectsTest::onDraw()
|
|||
glLineWidth(1);
|
||||
}
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
std::string TMXIsoObjectsTest::title() const
|
||||
|
@ -1516,16 +1514,15 @@ TMXGIDObjectsTest::TMXGIDObjectsTest()
|
|||
void TMXGIDObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_renderCmd);
|
||||
}
|
||||
|
||||
void TMXGIDObjectsTest::onDraw()
|
||||
void TMXGIDObjectsTest::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto map = (TMXTiledMap*)getChildByTag(kTagTileMap);
|
||||
auto pos = map->getPosition();
|
||||
auto group = map->getObjectGroup("Object Layer 1");
|
||||
|
@ -1550,7 +1547,7 @@ void TMXGIDObjectsTest::onDraw()
|
|||
glLineWidth(1);
|
||||
}
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
std::string TMXGIDObjectsTest::title() const
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
protected:
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
};
|
||||
|
||||
class TMXIsoObjectsTest : public TileDemo
|
||||
|
@ -151,7 +151,7 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
protected:
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
};
|
||||
|
||||
class TMXResizeTest : public TileDemo
|
||||
|
@ -296,7 +296,7 @@ public:
|
|||
|
||||
protected:
|
||||
CustomCommand _renderCmd;
|
||||
void onDraw();
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче