mirror of https://github.com/axmolengine/axmol.git
add transparent flag to render command
This commit is contained in:
parent
35acdc2284
commit
25091ca849
|
@ -148,7 +148,8 @@ void BillBoard::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||||
//FIXME: frustum culling here
|
//FIXME: frustum culling here
|
||||||
{
|
{
|
||||||
_quadCommand.init(_zDepthInView, _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, _billboardTransform);
|
_quadCommand.init(_zDepthInView, _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, _billboardTransform);
|
||||||
renderer->addCommandToTransparentQueue(&_quadCommand);
|
_quadCommand.setTransparent(true);
|
||||||
|
renderer->addCommand(&_quadCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -521,10 +521,8 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||||
}
|
}
|
||||||
//support tint and fade
|
//support tint and fade
|
||||||
meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a));
|
meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a));
|
||||||
if (mesh->_isTransparent)
|
meshCommand.setTransparent(mesh->_isTransparent);
|
||||||
renderer->addCommandToTransparentQueue(&meshCommand);
|
renderer->addCommand(&meshCommand);
|
||||||
else
|
|
||||||
renderer->addCommand(&meshCommand);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ NS_CC_BEGIN
|
||||||
RenderCommand::RenderCommand()
|
RenderCommand::RenderCommand()
|
||||||
: _type(RenderCommand::Type::UNKNOWN_COMMAND)
|
: _type(RenderCommand::Type::UNKNOWN_COMMAND)
|
||||||
, _globalOrder(0)
|
, _globalOrder(0)
|
||||||
|
, _isTransparent(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,12 @@ public:
|
||||||
/** Returns the Command type */
|
/** Returns the Command type */
|
||||||
inline Type getType() const { return _type; }
|
inline Type getType() const { return _type; }
|
||||||
|
|
||||||
|
/** Retruns whether is transparent */
|
||||||
|
inline bool isTransparent() const { return _isTransparent; }
|
||||||
|
|
||||||
|
/** set transparent flag */
|
||||||
|
inline void setTransparent(bool isTransparent) { _isTransparent = isTransparent; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RenderCommand();
|
RenderCommand();
|
||||||
virtual ~RenderCommand();
|
virtual ~RenderCommand();
|
||||||
|
@ -70,6 +76,8 @@ protected:
|
||||||
|
|
||||||
// commands are sort by depth
|
// commands are sort by depth
|
||||||
float _globalOrder;
|
float _globalOrder;
|
||||||
|
|
||||||
|
bool _isTransparent;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -268,12 +268,10 @@ void Renderer::addCommand(RenderCommand* command, int renderQueue)
|
||||||
CCASSERT(!_isRendering, "Cannot add command while rendering");
|
CCASSERT(!_isRendering, "Cannot add command while rendering");
|
||||||
CCASSERT(renderQueue >=0, "Invalid render queue");
|
CCASSERT(renderQueue >=0, "Invalid render queue");
|
||||||
CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type");
|
CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type");
|
||||||
_renderGroups[renderQueue].push_back(command);
|
if (command->isTransparent())
|
||||||
}
|
_transparentRenderGroups.push_back(command);
|
||||||
|
else
|
||||||
void Renderer::addCommandToTransparentQueue(RenderCommand* command)
|
_renderGroups[renderQueue].push_back(command);
|
||||||
{
|
|
||||||
_transparentRenderGroups.push_back(command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::pushGroup(int renderQueueID)
|
void Renderer::pushGroup(int renderQueueID)
|
||||||
|
|
|
@ -109,9 +109,6 @@ public:
|
||||||
/** Adds a `RenderComamnd` into the renderer specifying a particular render queue ID */
|
/** Adds a `RenderComamnd` into the renderer specifying a particular render queue ID */
|
||||||
void addCommand(RenderCommand* command, int renderQueue);
|
void addCommand(RenderCommand* command, int renderQueue);
|
||||||
|
|
||||||
/** add transprent command */
|
|
||||||
void addCommandToTransparentQueue(RenderCommand* command);
|
|
||||||
|
|
||||||
/** Pushes a group into the render queue */
|
/** Pushes a group into the render queue */
|
||||||
void pushGroup(int renderQueueID);
|
void pushGroup(int renderQueueID);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue