当前位置: 首页>>代码示例>>C++>>正文


C++ Font::GetFTFont方法代码示例

本文整理汇总了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;
			}
		}
	}
开发者ID:Aymore2,项目名称:Sparky,代码行数:65,代码来源:BatchRenderer2D.cpp


注:本文中的Font::GetFTFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。