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


C++ GraphicContext::reset_blend_state方法代码示例

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


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

示例1: flush

void RenderBatchTriangle::flush(GraphicContext &gc)
{
	if (position > 0)
	{
		gc.set_program_object(program_sprite);

		int gpu_index;
		VertexArrayVector<SpriteVertex> gpu_vertices(batch_buffer->get_vertex_buffer(gc, gpu_index));

		if (prim_array[gpu_index].is_null())
		{
			prim_array[gpu_index] = PrimitivesArray(gc);
			prim_array[gpu_index].set_attributes(0, gpu_vertices, cl_offsetof(SpriteVertex, position));
			prim_array[gpu_index].set_attributes(1, gpu_vertices, cl_offsetof(SpriteVertex, color));
			prim_array[gpu_index].set_attributes(2, gpu_vertices, cl_offsetof(SpriteVertex, texcoord));
			prim_array[gpu_index].set_attributes(3, gpu_vertices, cl_offsetof(SpriteVertex, texindex));

			if (glyph_blend.is_null())
			{
				BlendStateDescription blend_desc;
				blend_desc.set_blend_function(blend_constant_color, blend_one_minus_src_color, blend_zero, blend_one);
				glyph_blend = BlendState(gc, blend_desc);
			}
		}

		gpu_vertices.upload_data(gc, 0, vertices, position);

		for (int i = 0; i < num_current_textures; i++)
			gc.set_texture(i, current_textures[i]);

		if (use_glyph_program)
		{
			gc.set_blend_state(glyph_blend, constant_color);
			gc.draw_primitives(type_triangles, position, prim_array[gpu_index]);
			gc.reset_blend_state();
		}
		else
		{
			gc.draw_primitives(type_triangles, position, prim_array[gpu_index]);
		}

		for (int i = 0; i < num_current_textures; i++)
			gc.reset_texture(i);

		gc.reset_program_object();

		position = 0;
		for (int i = 0; i < num_current_textures; i++)
			current_textures[i] = Texture2D();
		num_current_textures = 0;

	}
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:53,代码来源:render_batch_triangle.cpp

示例2: draw

void ShaderEffect::draw(GraphicContext &gc)
{
	gc.set_program_object(impl->program);

	if (!impl->fb.is_null())
		gc.set_frame_buffer(impl->fb);

	if (!impl->rasterizer_state.is_null())
		gc.set_rasterizer_state(impl->rasterizer_state);

	if (!impl->blend_state.is_null())
		gc.set_blend_state(impl->blend_state);

	if (!impl->depth_stencil_state.is_null())
		gc.set_depth_stencil_state(impl->depth_stencil_state);

	for (auto & elem : impl->uniform_bindings)
	{
		gc.set_uniform_buffer(elem.first, elem.second);
	}

	for (auto & elem : impl->storage_bindings)
	{
		gc.set_storage_buffer(elem.first, elem.second);
	}

	for (auto & elem : impl->image_bindings)
	{
		gc.set_image_texture(elem.first, elem.second);
	}

	for (auto & elem : impl->texture_bindings)
	{
		gc.set_texture(elem.first, elem.second);
	}

	if (!impl->elements.is_null())
	{
		gc.set_primitives_elements(impl->elements);
		gc.set_primitives_array(impl->prim_array);
		gc.draw_primitives_elements(type_triangles, impl->num_vertices, impl->elements_type);
		gc.reset_primitives_array();
		gc.reset_primitives_elements();
	}
	else
	{
		gc.set_primitives_array(impl->prim_array);
		gc.draw_primitives_array(type_triangles, 0, impl->num_vertices);
		gc.reset_primitives_array();
	}

	for (auto & elem : impl->uniform_bindings)
	{
		gc.reset_uniform_buffer(elem.first);
	}

	for (auto & elem : impl->storage_bindings)
	{
		gc.reset_storage_buffer(elem.first);
	}

	for (auto & elem : impl->image_bindings)
	{
		gc.reset_image_texture(elem.first);
	}

	for (auto & elem : impl->texture_bindings)
	{
		gc.reset_texture(elem.first);
	}

	if (!impl->rasterizer_state.is_null())
		gc.reset_rasterizer_state();

	if (!impl->blend_state.is_null())
		gc.reset_blend_state();

	if (!impl->depth_stencil_state.is_null())
		gc.reset_depth_stencil_state();

	if (!impl->fb.is_null())
		gc.reset_frame_buffer();

	gc.reset_program_object();
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:85,代码来源:shader_effect.cpp


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