From e8d57154dd86b9c9a2753f6e060dfa7ee8650be4 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 25 Dec 2013 14:52:49 +0800 Subject: [PATCH 1/3] fix Label->Atlas1 --- .../TestCpp/Classes/LabelTest/LabelTest.cpp | 18 ++++++++++++++---- .../Cpp/TestCpp/Classes/LabelTest/LabelTest.h | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index 003fe790ef..b4d94d3d85 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -1,5 +1,7 @@ - #include "LabelTest.h" +#include "LabelTest.h" #include "../testResource.h" +#include "renderer/CCRenderer.h" +#include "renderer/CCCustomCommand.h" enum { kTagTileMap = 1, @@ -206,13 +208,21 @@ void Atlas1::draw() { // GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // GL_TEXTURE_2D - - _textureAtlas->drawQuads(); - + + CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(Atlas1::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(cmd); + // [textureAtlas drawNumberOfQuads:3]; } +void Atlas1::onDraw() +{ + _textureAtlas->drawQuads(); +} + std::string Atlas1::title() const { return "CCTextureAtlas"; diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h index 1d27def081..f939278170 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h @@ -36,6 +36,8 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void draw(); +protected: + void onDraw(); }; class LabelAtlasTest : public AtlasDemo From 19522152d52936a60fd6d2cbde810f34ab8ed8ea Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 25 Dec 2013 15:05:49 +0800 Subject: [PATCH 2/3] fix Label->Atlas4 --- samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp | 8 ++++++++ samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index b4d94d3d85..57d5618a78 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -525,6 +525,14 @@ Atlas4::Atlas4() } void Atlas4::draw() +{ + CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(Atlas4::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(cmd); +} + +void Atlas4::onDraw() { auto s = Director::getInstance()->getWinSize(); DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) ); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h index f939278170..c532bef477 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h @@ -104,6 +104,8 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; +protected: + void onDraw(); }; class Atlas5 : public AtlasDemo From 7333a636c13302c52815fc970b80126f4248f5d0 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 25 Dec 2013 15:13:11 +0800 Subject: [PATCH 3/3] fix Label->LabelBMFontBounds --- samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp | 8 ++++++++ samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index 57d5618a78..09280e9b63 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -1612,6 +1612,14 @@ std::string LabelBMFontBounds::subtitle() const } void LabelBMFontBounds::draw() +{ + CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(cmd); +} + +void LabelBMFontBounds::onDraw() { auto labelSize = label1->getContentSize(); auto origin = Director::getInstance()->getWinSize(); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h index c532bef477..11c9934f93 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h @@ -376,6 +376,8 @@ public: virtual void draw(); virtual std::string title() const override; virtual std::string subtitle() const override; +protected: + void onDraw(); private: LabelBMFont *label1; };