void Label::onDraw(const kmMat4& transform, bool transformUpdated) { CC_PROFILER_START("Label - draw"); // Optimization: Fast Dispatch if( _batchNodes.size() == 1 && _textureAtlas->getTotalQuads() == 0 ) { return; } _shaderProgram->use(); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); bool trans = false; if (_currLabelEffect == LabelEffect::OUTLINE) { _shaderProgram->setUniformLocationWith4f(_uniformEffectColor, _outlineColor.r/255.0f,_outlineColor.g/255.0f,_outlineColor.b/255.0f,_outlineColor.a/255.0f); } else if (_currLabelEffect == LabelEffect::GLOW) { _shaderProgram->setUniformLocationWith3f(_uniformEffectColor, _effectColor.r/255.0f,_effectColor.g/255.0f,_effectColor.b/255.0f); } else if(_currLabelEffect == LabelEffect::SHADOW && _shadowBlurRadius <= 0) { trans = true; drawShadowWithoutBlur(); } _shaderProgram->setUniformsForBuiltins(transform); for(const auto &child: _children) { if(child->getTag() >= 0) child->updateTransform(); } for (const auto& batchNode:_batchNodes) { batchNode->getTextureAtlas()->drawQuads(); } if (trans) { kmGLPopMatrix(); } CC_PROFILER_STOP("Label - draw"); }
void Label::onDraw(const Mat4& transform, bool transformUpdated) { CC_PROFILER_START("Label - draw"); // Optimization: Fast Dispatch if( _batchNodes.size() == 1 && _textureAtlas->getTotalQuads() == 0 ) { return; } auto glprogram = getGLProgram(); glprogram->use(); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); if (_currentLabelType == LabelType::TTF) { glprogram->setUniformLocationWith4f(_uniformTextColor, _textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a); } if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW) { glprogram->setUniformLocationWith4f(_uniformEffectColor, _effectColorF.r,_effectColorF.g,_effectColorF.b,_effectColorF.a); } if(_shadowEnabled && _shadowBlurRadius <= 0) { drawShadowWithoutBlur(); } glprogram->setUniformsForBuiltins(transform); for(const auto &child: _children) { if(child->getTag() >= 0) child->updateTransform(); } for (const auto& batchNode:_batchNodes) { batchNode->getTextureAtlas()->drawQuads(); } CC_PROFILER_STOP("Label - draw"); }