Label:support auto batch with bitmap font or char map.

This commit is contained in:
WenhaiLin 2015-08-04 21:49:14 +08:00
parent 744fa0b565
commit 2363622a67
2 changed files with 15 additions and 3 deletions

View File

@ -1208,10 +1208,20 @@ 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))
{
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);
}
}
}

View File

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