2013-11-09 04:06:39 +08:00
|
|
|
//
|
|
|
|
// Created by NiTe Luo on 11/8/13.
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "CustomCommand.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
2013-12-03 14:08:47 +08:00
|
|
|
RenderCommandPool<CustomCommand> CustomCommand::_commandPool;
|
2013-11-09 04:06:39 +08:00
|
|
|
|
2013-12-03 11:17:21 +08:00
|
|
|
CustomCommand::CustomCommand()
|
2013-11-09 04:06:39 +08:00
|
|
|
:RenderCommand()
|
2013-12-03 11:17:21 +08:00
|
|
|
, _viewport(0)
|
|
|
|
, _depth(0)
|
2013-11-09 04:06:39 +08:00
|
|
|
, func(nullptr)
|
|
|
|
{
|
|
|
|
_type = CUSTOM_COMMAND;
|
|
|
|
}
|
|
|
|
|
2013-12-03 11:17:21 +08:00
|
|
|
void CustomCommand::init(int viewport, int32_t depth)
|
|
|
|
{
|
|
|
|
_viewport = viewport;
|
|
|
|
_depth = depth;
|
|
|
|
}
|
|
|
|
|
2013-11-09 04:06:39 +08:00
|
|
|
CustomCommand::~CustomCommand()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t CustomCommand::generateID()
|
|
|
|
{
|
|
|
|
_id = 0;
|
|
|
|
|
|
|
|
_id = (int64_t)_viewport << 61
|
|
|
|
| (int64_t)1 << 60 // translucent
|
2013-11-11 16:14:29 +08:00
|
|
|
| (int64_t)_depth << 36;
|
2013-11-09 04:06:39 +08:00
|
|
|
|
|
|
|
return _id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomCommand::execute()
|
|
|
|
{
|
|
|
|
if(func)
|
|
|
|
{
|
|
|
|
func();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-03 14:08:47 +08:00
|
|
|
void CustomCommand::releaseToCommandPool()
|
|
|
|
{
|
|
|
|
getCommandPool().pushBackCommand(this);
|
|
|
|
}
|
|
|
|
|
2013-11-09 04:06:39 +08:00
|
|
|
NS_CC_END
|