diff --git a/cocos/2d/renderer/CustomCommand.cpp b/cocos/2d/renderer/CustomCommand.cpp index c24dec1619..ac2182266f 100644 --- a/cocos/2d/renderer/CustomCommand.cpp +++ b/cocos/2d/renderer/CustomCommand.cpp @@ -14,7 +14,7 @@ CustomCommand::CustomCommand() , _depth(0) , func(nullptr) { - _type = CUSTOM_COMMAND; + _type = RenderCommand::Type::CUSTOM_COMMAND; } void CustomCommand::init(int viewport, int32_t depth) diff --git a/cocos/2d/renderer/GroupCommand.cpp b/cocos/2d/renderer/GroupCommand.cpp index 977cf603f4..aaad2c60b6 100644 --- a/cocos/2d/renderer/GroupCommand.cpp +++ b/cocos/2d/renderer/GroupCommand.cpp @@ -70,7 +70,7 @@ GroupCommand::GroupCommand() , _viewport(0) , _depth(0) { - _type = GROUP_COMMAND; + _type = RenderCommand::Type::GROUP_COMMAND; _renderQueueID = GroupCommandManager::getInstance()->getGroupID(); } diff --git a/cocos/2d/renderer/QuadCommand.cpp b/cocos/2d/renderer/QuadCommand.cpp index 67adc7536b..4c1926c3f2 100644 --- a/cocos/2d/renderer/QuadCommand.cpp +++ b/cocos/2d/renderer/QuadCommand.cpp @@ -18,7 +18,7 @@ QuadCommand::QuadCommand() ,_quadCount(0) ,_capacity(0) { - _type = QUAD_COMMAND; + _type = RenderCommand::Type::QUAD_COMMAND; _shader = nullptr; _quad = nullptr; } diff --git a/cocos/2d/renderer/RenderCommand.cpp b/cocos/2d/renderer/RenderCommand.cpp index 6b94fd977d..df082e4f6f 100644 --- a/cocos/2d/renderer/RenderCommand.cpp +++ b/cocos/2d/renderer/RenderCommand.cpp @@ -10,7 +10,7 @@ NS_CC_BEGIN RenderCommand::RenderCommand() { _id = 0; - _type = UNKNOWN_COMMAND; + _type = RenderCommand::Type::UNKNOWN_COMMAND; } RenderCommand::~RenderCommand() diff --git a/cocos/2d/renderer/RenderCommand.h b/cocos/2d/renderer/RenderCommand.h index eb136ec520..de453ae49d 100644 --- a/cocos/2d/renderer/RenderCommand.h +++ b/cocos/2d/renderer/RenderCommand.h @@ -14,37 +14,36 @@ NS_CC_BEGIN -enum RenderCommandType -{ - QUAD_COMMAND, - CUSTOM_COMMAND, - GROUP_COMMAND, - UNKNOWN_COMMAND, -}; - //TODO make RenderCommand inherent from Object class RenderCommand { +public: + + enum class Type + { + QUAD_COMMAND, + CUSTOM_COMMAND, + GROUP_COMMAND, + UNKNOWN_COMMAND, + }; + + virtual int64_t generateID() = 0; + + /** Get Render Command Id */ + virtual inline int64_t getID() { return _id; } + + virtual inline Type getType() { return _type; } + virtual void releaseToCommandPool() =0; + protected: RenderCommand(); virtual ~RenderCommand(); -public: - virtual int64_t generateID() = 0; - virtual /** - * Get Render Command Id - */ - inline int64_t getID() { return _id; } - - virtual inline RenderCommandType getType() { return _type; } - virtual void releaseToCommandPool() =0; -protected: void printID(); -protected: //Generated IDs int64_t _id; /// used for sorting render commands - RenderCommandType _type; + Type _type; }; NS_CC_END diff --git a/cocos/2d/renderer/Renderer.cpp b/cocos/2d/renderer/Renderer.cpp index 484f017591..3873278362 100644 --- a/cocos/2d/renderer/Renderer.cpp +++ b/cocos/2d/renderer/Renderer.cpp @@ -215,7 +215,7 @@ void Renderer::render() _renderStack.top().currentIndex = _lastCommand = i; auto command = currRenderQueue[i]; - if(command->getType() == QUAD_COMMAND) + if(command->getType() == RenderCommand::Type::QUAD_COMMAND) { QuadCommand* cmd = static_cast(command); @@ -231,13 +231,13 @@ void Renderer::render() memcpy(_quads + _numQuads, cmd->getQuad(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount()); _numQuads += cmd->getQuadCount(); } - else if(command->getType() == CUSTOM_COMMAND) + else if(command->getType() == RenderCommand::Type::CUSTOM_COMMAND) { flush(); CustomCommand* cmd = static_cast(command); cmd->execute(); } - else if(command->getType() == GROUP_COMMAND) + else if(command->getType() == RenderCommand::Type::GROUP_COMMAND) { flush(); GroupCommand* cmd = static_cast(command); @@ -340,7 +340,7 @@ void Renderer::drawBatchedQuads() for(size_t i = _firstCommand; i <= _lastCommand; i++) { RenderCommand* command = _renderGroups[_renderStack.top().renderQueueID][i]; - if (command->getType() == QUAD_COMMAND) + if (command->getType() == RenderCommand::Type::QUAD_COMMAND) { QuadCommand* cmd = static_cast(command); if(_lastMaterialID != cmd->getMaterialID()) diff --git a/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp b/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp index a2e4ce76bd..b0182eed99 100644 --- a/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp @@ -153,6 +153,12 @@ std::string ConsoleTCP::title() return "Console TCP"; } +std::string ConsoleTCP::subtitle() +{ + return "telnet localhost 5678"; +} + + //------------------------------------------------------------------ // // ConsoleCustomCommand @@ -190,3 +196,8 @@ std::string ConsoleCustomCommand::title() { return "Console Custom Commands"; } + +std::string ConsoleCustomCommand::subtitle() +{ + return "telnet localhost 5678"; +} diff --git a/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.h b/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.h index e1c2801628..f0a8f41754 100644 --- a/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.h +++ b/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.h @@ -52,6 +52,7 @@ public: void onEnter() override; virtual std::string title() override; + virtual std::string subtitle() override; protected: ConsoleTCP(); @@ -70,6 +71,7 @@ public: void onEnter() override; virtual std::string title() override; + virtual std::string subtitle() override; protected: ConsoleCustomCommand();