From 706d0e185a577eb80c4eb22eb59be521558619a0 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 26 Dec 2013 16:11:06 +0800 Subject: [PATCH] fix LabelTestNew --- .../Classes/LabelTest/LabelTestNew.cpp | 31 +++++++++++++++++++ .../TestCpp/Classes/LabelTest/LabelTestNew.h | 4 +++ 2 files changed, 35 insertions(+) diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp index 66455e0ab2..a37038bbe6 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp @@ -1,5 +1,7 @@ #include "LabelTestNew.h" #include "../testResource.h" +#include "renderer/CCRenderer.h" +#include "renderer/CCCustomCommand.h" enum { kTagTileMap = 1, @@ -300,9 +302,24 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() void LabelFNTSpriteActions::draw() { + CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(cmd); + +} + +void LabelFNTSpriteActions::onDraw() +{ + kmMat4 oldMat; + kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat); + kmGLLoadMatrix(&_modelViewTransform); + 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); } void LabelFNTSpriteActions::step(float dt) @@ -897,6 +914,18 @@ std::string LabelFNTBounds::subtitle() const void LabelFNTBounds::draw() { + CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(cmd); +} + +void LabelFNTBounds::onDraw() +{ + kmMat4 oldMat; + kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat); + kmGLLoadMatrix(&_modelViewTransform); + auto labelSize = label1->getContentSize(); auto origin = Director::getInstance()->getWinSize(); @@ -911,6 +940,8 @@ void LabelFNTBounds::draw() Point(origin.width, labelSize.height + origin.height) }; DrawPrimitives::drawPoly(vertices, 4, true); + + kmGLLoadMatrix(&oldMat); } LabelTTFLongLineWrapping::LabelTTFLongLineWrapping() diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.h b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.h index 378964f0ae..c1040bb270 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.h +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.h @@ -60,6 +60,8 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; +protected: + void onDraw(); }; class LabelFNTPadding : public AtlasDemoNew @@ -223,6 +225,8 @@ public: virtual std::string subtitle() const override; private: Label *label1; +protected: + void onDraw(); }; class LabelTTFLongLineWrapping : public AtlasDemoNew