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


C++ RenderBatchTriangle::draw_glyph_subpixel方法代码示例

本文整理汇总了C++中RenderBatchTriangle::draw_glyph_subpixel方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderBatchTriangle::draw_glyph_subpixel方法的具体用法?C++ RenderBatchTriangle::draw_glyph_subpixel怎么用?C++ RenderBatchTriangle::draw_glyph_subpixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderBatchTriangle的用法示例。


在下文中一共展示了RenderBatchTriangle::draw_glyph_subpixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw_text

void GlyphCache::draw_text(FontEngine *font_engine, Canvas &canvas, float xpos, float ypos, const std::string &text, const Colorf &color) 
{
	std::string::size_type string_length = text.length();
	if (string_length==0)
	{
		return;
	}

	RenderBatchTriangle *batcher = canvas.impl->batcher.get_triangle_batcher();
	GraphicContext &gc = canvas.get_gc();
	// Scan the string
	UTF8_Reader reader(text.data(), text.length());
	while(!reader.is_end())
	{
		unsigned int glyph = reader.get_char();
		reader.next();

		Font_TextureGlyph *gptr = get_glyph(font_engine, gc, glyph);
		if (gptr == NULL) continue;

		if (!gptr->texture.is_null())
		{
			float xp = xpos + gptr->offset.x;
			float yp = ypos + gptr->offset.y;

			Rectf dest_size(xp, yp, Sizef(gptr->geometry.get_size()));
			if (enable_subpixel)
			{
				batcher->draw_glyph_subpixel(canvas, gptr->geometry, dest_size, color, gptr->texture);
			}else
			{
				batcher->draw_image(canvas, gptr->geometry, dest_size, color, gptr->texture);
			}
		}
		xpos += gptr->increment.x;
		ypos += gptr->increment.y;
	}
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:38,代码来源:glyph_cache.cpp

示例2: draw_text

	void Font_DrawSubPixel::draw_text(Canvas &canvas, const Pointf &position, const std::string &text, const Colorf &color, float line_spacing)
	{
		float offset_x = 0;
		float offset_y = 0;
		UTF8_Reader reader(text.data(), text.length());
		RenderBatchTriangle *batcher = canvas.impl->batcher.get_triangle_batcher();

		while (!reader.is_end())
		{
			unsigned int glyph = reader.get_char();
			reader.next();

			if (glyph == '\n')
			{
				offset_x = 0;
				offset_y += line_spacing;
				continue;
			}

			Font_TextureGlyph *gptr = glyph_cache->get_glyph(canvas, font_engine, glyph);
			if (gptr)
			{
				if (!gptr->texture.is_null())
				{
					float xp = offset_x + position.x + gptr->offset.x;
					float yp = offset_y + position.y + gptr->offset.y;
					Pointf pos = canvas.grid_fit(Pointf(xp, yp));

					Rectf dest_size(pos, gptr->size);
					batcher->draw_glyph_subpixel(canvas, gptr->geometry, dest_size, color, gptr->texture);
				}
				offset_x += gptr->metrics.advance.width;
				offset_y += gptr->metrics.advance.height;
			}
		}
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:36,代码来源:font_draw_subpixel.cpp


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