本文整理汇总了C++中Font::GetFTFont方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::GetFTFont方法的具体用法?C++ Font::GetFTFont怎么用?C++ Font::GetFTFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font::GetFTFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SubmitTexture
void BatchRenderer2D::DrawString(const std::string& text, const maths::vec3& position, const Font& font, unsigned int color)
{
using namespace ftgl;
float ts = 0.0f;
ts = SubmitTexture(font.GetID());
const maths::vec2& scale = font.GetScale();
float x = position.x;
texture_font_t* ftFont = font.GetFTFont();
for (uint i = 0; i < text.length(); i++)
{
char c = text[i];
texture_glyph_t* glyph = texture_font_get_glyph(ftFont, c);
if (glyph != NULL)
{
if (i > 0)
{
float kerning = texture_glyph_get_kerning(glyph, text[i - 1]);
x += kerning / scale.x;
}
float x0 = x + glyph->offset_x / scale.x;
float y0 = position.y + glyph->offset_y / scale.y;
float x1 = x0 + glyph->width / scale.x;
float y1 = y0 - glyph->height / scale.y;
float u0 = glyph->s0;
float v0 = glyph->t0;
float u1 = glyph->s1;
float v1 = glyph->t1;
m_Buffer->vertex = *m_TransformationBack * maths::vec3(x0, y0, 0);
m_Buffer->uv = maths::vec2(u0, v0);
m_Buffer->tid = ts;
m_Buffer->color = color;
m_Buffer++;
m_Buffer->vertex = *m_TransformationBack * maths::vec3(x0, y1, 0);
m_Buffer->uv = maths::vec2(u0, v1);
m_Buffer->tid = ts;
m_Buffer->color = color;
m_Buffer++;
m_Buffer->vertex = *m_TransformationBack * maths::vec3(x1, y1, 0);
m_Buffer->uv = maths::vec2(u1, v1);
m_Buffer->tid = ts;
m_Buffer->color = color;
m_Buffer++;
m_Buffer->vertex = *m_TransformationBack * maths::vec3(x1, y0, 0);
m_Buffer->uv = maths::vec2(u1, v0);
m_Buffer->tid = ts;
m_Buffer->color = color;
m_Buffer++;
m_IndexCount += 6;
x += glyph->advance_x / scale.x;
}
}
}