Merge pull request #4518 from ricardoquesada/renderer_with_love

Cleanup RenderCommand code
This commit is contained in:
Ricardo Quesada 2013-12-17 18:03:07 -08:00
commit a62b56fc46
8 changed files with 40 additions and 28 deletions

View File

@ -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)

View File

@ -70,7 +70,7 @@ GroupCommand::GroupCommand()
, _viewport(0)
, _depth(0)
{
_type = GROUP_COMMAND;
_type = RenderCommand::Type::GROUP_COMMAND;
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
}

View File

@ -18,7 +18,7 @@ QuadCommand::QuadCommand()
,_quadCount(0)
,_capacity(0)
{
_type = QUAD_COMMAND;
_type = RenderCommand::Type::QUAD_COMMAND;
_shader = nullptr;
_quad = nullptr;
}

View File

@ -10,7 +10,7 @@ NS_CC_BEGIN
RenderCommand::RenderCommand()
{
_id = 0;
_type = UNKNOWN_COMMAND;
_type = RenderCommand::Type::UNKNOWN_COMMAND;
}
RenderCommand::~RenderCommand()

View File

@ -14,7 +14,12 @@
NS_CC_BEGIN
enum RenderCommandType
//TODO make RenderCommand inherent from Object
class RenderCommand
{
public:
enum class Type
{
QUAD_COMMAND,
CUSTOM_COMMAND,
@ -22,29 +27,23 @@ enum RenderCommandType
UNKNOWN_COMMAND,
};
//TODO make RenderCommand inherent from Object
class RenderCommand
{
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

View File

@ -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<QuadCommand*>(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<CustomCommand*>(command);
cmd->execute();
}
else if(command->getType() == GROUP_COMMAND)
else if(command->getType() == RenderCommand::Type::GROUP_COMMAND)
{
flush();
GroupCommand* cmd = static_cast<GroupCommand*>(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<QuadCommand*>(command);
if(_lastMaterialID != cmd->getMaterialID())

View File

@ -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";
}

View File

@ -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();