mirror of https://github.com/axmolengine/axmol.git
Merge pull request #13201 from WenhaiLin/v3.8-label-batch
Label:support auto batch with bitmap font or char map.
This commit is contained in:
commit
9b6e8621c6
|
@ -466,8 +466,10 @@ void Label::updateShaderProgram()
|
|||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL));
|
||||
else if (_useA8Shader)
|
||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_NORMAL));
|
||||
else
|
||||
else if (_shadowEnabled)
|
||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
else
|
||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
|
||||
|
||||
break;
|
||||
case cocos2d::LabelEffect::OUTLINE:
|
||||
|
@ -872,6 +874,18 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const
|
|||
_shadowColor4F.g = shadowColor.g / 255.0f;
|
||||
_shadowColor4F.b = shadowColor.b / 255.0f;
|
||||
_shadowColor4F.a = shadowColor.a / 255.0f;
|
||||
|
||||
if (_currentLabelType == LabelType::BMFONT || _currentLabelType == LabelType::CHARMAP)
|
||||
{
|
||||
if (_shadowEnabled)
|
||||
{
|
||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
}
|
||||
else
|
||||
{
|
||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Label::disableEffect()
|
||||
|
@ -1208,10 +1222,24 @@ void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
if (_insideBounds)
|
||||
#endif
|
||||
{
|
||||
_customCommand.init(_globalZOrder, transform, flags);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
|
||||
if (!_shadowEnabled && (_currentLabelType == LabelType::BMFONT || _currentLabelType == LabelType::CHARMAP))
|
||||
{
|
||||
for (auto&& it : _letters)
|
||||
{
|
||||
it.second->updateTransform();
|
||||
}
|
||||
auto textureAtlas = _batchNodes.at(0)->getTextureAtlas();
|
||||
_quadCommand.init(_globalZOrder, textureAtlas->getTexture()->getName(), getGLProgramState(),
|
||||
_blendFunc, textureAtlas->getQuads(), textureAtlas->getTotalQuads(), transform, flags);
|
||||
renderer->addCommand(&_quadCommand);
|
||||
}
|
||||
else
|
||||
{
|
||||
_customCommand.init(_globalZOrder, transform, flags);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
|
||||
|
||||
renderer->addCommand(&_customCommand);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "2d/CCNode.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
#include "renderer/CCQuadCommand.h"
|
||||
#include "2d/CCFontAtlas.h"
|
||||
#include "base/ccTypes.h"
|
||||
|
||||
|
@ -573,6 +574,7 @@ protected:
|
|||
Color4B _textColor;
|
||||
Color4F _textColorF;
|
||||
|
||||
QuadCommand _quadCommand;
|
||||
CustomCommand _customCommand;
|
||||
Mat4 _shadowTransform;
|
||||
GLuint _uniformEffectColor;
|
||||
|
|
Loading…
Reference in New Issue