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


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

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


在下文中一共展示了GraphicContext::draw_primitives方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: flush

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

		int gpu_index;
		VertexArrayVector<PointVertex> 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(PointVertex, position));
			prim_array[gpu_index].set_attributes(1, gpu_vertices, cl_offsetof(PointVertex, color));
		}

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

		gc.draw_primitives(type_points, position, prim_array[gpu_index]);

		gc.reset_program_object();

		position = 0;
	}
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:25,代码来源:render_batch_point.cpp

示例3: Draw

void Model_Impl::Draw(GraphicContext &gc, GraphicStore *gs, const Mat4f &modelview_matrix)
{
	Mat4f matrix_modelview_projection = gs->camera_projection *  modelview_matrix;
	Mat3f normal_matrix = Mat3f(modelview_matrix);
	normal_matrix.inverse();
	normal_matrix.transpose();

	PrimitivesArray prim_array(gc);
	
	prim_array.set_attributes(0, vbo_positions, 3, type_float, 0);
	prim_array.set_attributes(1, vbo_normals, 3, type_float, 0);
	gs->shader_color.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
	gs->shader_color.Use(gc, modelview_matrix, matrix_modelview_projection, Mat4f(normal_matrix));
	gc.draw_primitives(type_triangles, vbo_size, prim_array);
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:15,代码来源:model.cpp

示例4: Draw

void ParticleObject::Draw(GraphicContext &gc, GraphicStore *gs, const Mat4f &modelview_matrix)
{
	Mat4f matrix_modelview_projection = gs->camera_projection *  modelview_matrix;

	PrimitivesArray prim_array(gc);

	prim_array.set_attributes(0, object_positions_vbo, 3, type_float, 0);
	prim_array.set_attributes(1, object_colours_vbo, 4, type_float, 0);

	gs->shader_color_geometry.Use(gc, matrix_modelview_projection);

	gc.set_texture(0, gs->texture_ball);
	gc.draw_primitives(type_points, num_points, prim_array);
	gc.reset_texture(0);
}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:15,代码来源:particle_object.cpp

示例5: render_texture

void HSV::render_texture(Canvas &canvas, ProgramObject &program, Texture &texture, float hue_offset)
{
	GraphicContext gc = canvas.get_gc();

	Rectf rect(0.0f, 0.0f, (float)gc.get_width(), (float)gc.get_height());
	Rectf texture_unit1_coords(0.0f, 0.0f, 1.0f, 1.0f);

	Vec2f positions[6] =
	{
		Vec2f(rect.left, rect.top),
		Vec2f(rect.right, rect.top),
		Vec2f(rect.left, rect.bottom),
		Vec2f(rect.right, rect.top),
		Vec2f(rect.left, rect.bottom),
		Vec2f(rect.right, rect.bottom)
	};

	Vec2f tex1_coords[6] =
	{
		Vec2f(texture_unit1_coords.left, texture_unit1_coords.top),
		Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
		Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
		Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
		Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
		Vec2f(texture_unit1_coords.right, texture_unit1_coords.bottom)
	};

	PrimitivesArray primarray(gc);

	VertexArrayVector<Vec2f> gpu_positions = VertexArrayVector<Vec2f>(gc, positions, 6);
	VertexArrayVector<Vec2f> gpu_tex1_coords = VertexArrayVector<Vec2f>(gc, tex1_coords, 6);

	primarray.set_attributes(0, gpu_positions);
	primarray.set_attributes(1, gpu_tex1_coords);

	ProgramUniforms buffer;
	buffer.cl_ModelViewProjectionMatrix = canvas.get_projection() * canvas.get_modelview();
	buffer.HueOffset0 = hue_offset;
	UniformVector<ProgramUniforms> uniform_vector(gc, &buffer, 1);
	gc.set_uniform_buffer(0, uniform_vector);

	gc.set_texture(0, texture);
	gc.set_program_object(program);
	gc.draw_primitives(type_triangles, 6, primarray);
	gc.reset_program_object();
	gc.reset_texture(0);
}
开发者ID:Zenol,项目名称:clanLib-3,代码行数:47,代码来源:hsv.cpp


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