mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4518 from ricardoquesada/renderer_with_love
Cleanup RenderCommand code
This commit is contained in:
commit
a62b56fc46
|
@ -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)
|
||||
|
|
|
@ -70,7 +70,7 @@ GroupCommand::GroupCommand()
|
|||
, _viewport(0)
|
||||
, _depth(0)
|
||||
{
|
||||
_type = GROUP_COMMAND;
|
||||
_type = RenderCommand::Type::GROUP_COMMAND;
|
||||
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ QuadCommand::QuadCommand()
|
|||
,_quadCount(0)
|
||||
,_capacity(0)
|
||||
{
|
||||
_type = QUAD_COMMAND;
|
||||
_type = RenderCommand::Type::QUAD_COMMAND;
|
||||
_shader = nullptr;
|
||||
_quad = nullptr;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ NS_CC_BEGIN
|
|||
RenderCommand::RenderCommand()
|
||||
{
|
||||
_id = 0;
|
||||
_type = UNKNOWN_COMMAND;
|
||||
_type = RenderCommand::Type::UNKNOWN_COMMAND;
|
||||
}
|
||||
|
||||
RenderCommand::~RenderCommand()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue