本文整理汇总了C++中TextLayout::glyph方法的典型用法代码示例。如果您正苦于以下问题:C++ TextLayout::glyph方法的具体用法?C++ TextLayout::glyph怎么用?C++ TextLayout::glyph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextLayout
的用法示例。
在下文中一共展示了TextLayout::glyph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _render
void BitmapTextComponentManager::_render(EntityRef entity, float interp, const OrthographicCamera& camera) {
if ( !entity.isEnabled() )
return;
BitmapTextComponent* comp = get(entity);
if(comp && comp->isEnabled()
&& comp->font() && comp->font()->get() && comp->font()->get()->isValid()) {
BitmapFontSP font = comp->font()->get();
Matrix4 wt = lerp(interp,
comp->_entity()->prevWorldTransform.matrix(),
comp->_entity()->worldTransform.matrix());
// FIXME: Find a way to get rid of this - we should not upload stuff here.
if(!comp->texture()) {
comp->_setTexture(_spriteRenderer->createTexture(font->image()));
_spriteRenderer->renderer()->uploadPendingTextures();
}
TextureSP tex = comp->texture()->_get();
int width = (comp->size()(0) > 0)? comp->size()(0): 999999;
TextLayout layout = font->layoutText(comp->text(), width);
unsigned index = _spriteRenderer->indexCount();
for(unsigned i = 0; i < layout.nGlyphs(); ++i) {
unsigned cp = layout.glyph(i).codepoint;
Vector2 pos = layout.glyph(i).pos;
const BitmapFont::Glyph& glyph = font->glyph(cp);
Vector2 size = glyph.size;
pos(0) += glyph.offset(0);
pos(1) += font->height() - size(1) - glyph.offset(1)
+ layout.box().sizes()(1);
pos -= layout.box().sizes().cwiseProduct(comp->anchor());
Box2 coords(pos, pos + size);
_spriteRenderer->addSprite(wt, coords, comp->color(), glyph.region);
}
unsigned count = _spriteRenderer->indexCount() - index;
if(count) {
_states.texture = tex;
const ShaderParameter* params = _spriteRenderer->addShaderParameters(
_spriteRenderer->shader(), camera.transform(), 0, Vector4i(1, 1, 65536, 65536));
float depth = 1.f - normalize(wt(2, 3), camera.viewBox().min()(2),
camera.viewBox().max()(2));
_renderPass->addDrawCall(_states, params, depth, index, count);
}
}
EntityRef child = entity.firstChild();
while(child.isValid()) {
render(child, interp, camera);
child = child.nextSibling();
}
}