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


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

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


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

示例1: render

void LightsourceSimplePass::render(GraphicContext &gc, GPUTimer &timer)
{
	ScopeTimeFunction();

	//timer.begin_time(gc, "light(simple)");

	gc.set_frame_buffer(fb);

	gc.set_viewport(viewport->get_size());

	gc.set_depth_range(0.0f, 0.9f);

	gc.set_uniform_buffer(0, uniforms);
	gc.set_texture(0, light_instance_texture);
	gc.set_texture(1, normal_z_gbuffer.get());
	gc.set_texture(2, diffuse_color_gbuffer.get());
	gc.set_texture(3, specular_color_gbuffer.get());
	gc.set_texture(4, specular_level_gbuffer.get());
	gc.set_texture(5, shadow_maps.get());
	gc.set_texture(6, self_illumination_gbuffer.get());

	gc.set_blend_state(blend_state);

	gc.clear();

	// To do: use icosahedron for smaller lights and when the camera is not inside the light influence sphere
	// To do: combine multiple lights into the same rect pass to reduce overdraw penalty

	gc.set_depth_stencil_state(rect_depth_stencil_state);
	gc.set_rasterizer_state(rect_rasterizer_state);
	gc.set_program_object(rect_light_program);

	gc.set_primitives_array(rect_prim_array);
	gc.draw_primitives_array_instanced(type_triangles, 0, 6, std::max(lights.size(), (size_t)1));
	gc.reset_primitives_array();

/*
	gc.set_depth_stencil_state(icosahedron_depth_stencil_state);
	gc.set_rasterizer_state(icosahedron_rasterizer_state);
	gc.set_program_object(icosahedron_light_program);

	gc.set_primitives_array(icosahedron_prim_array);
	gc.draw_primitives_elements_instanced(type_triangles, icosahedron->num_elements, icosahedron->elements, 0, lights.size());
	gc.reset_primitives_array();
*/

	gc.set_depth_stencil_state(icosahedron_depth_stencil_state);
	gc.set_rasterizer_state(icosahedron_rasterizer_state);
	gc.set_program_object(icosahedron_light_program);

	gc.set_primitives_array(icosahedron_prim_array);
	gc.draw_primitives_elements_instanced(type_triangles, icosahedron->num_elements, icosahedron->elements, 0, lights.size());
	gc.reset_primitives_array();

	//timer.end_time(gc);
	//timer.begin_time(gc, "light(simple)");

	gc.reset_texture(6);
	gc.reset_texture(5);
	gc.reset_texture(4);
	gc.reset_texture(3);
	gc.reset_texture(2);
	gc.reset_texture(1);
	gc.reset_texture(0);
	gc.reset_uniform_buffer(0);

	//timer.end_time(gc);
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:68,代码来源:lightsource_simple_pass.cpp


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