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


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

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


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

示例1: render

void App::render(GraphicContext &gc)
{
	gc.clear(Colorf(0.0f, 0.0f, 0.0f, 1.0f));

	Rect viewport_rect(0, 0, Size(gc.get_width(), gc.get_height()));
	gc.set_viewport(viewport_rect);

	gc.clear_depth(1.0f);

	Mat4f modelview_matrix = scene.gs->camera_modelview;
	scene.Draw(modelview_matrix, gc);
	gc.reset_program_object();
}
开发者ID:Cemenyave,项目名称:ClanLib,代码行数:13,代码来源:example.cpp

示例2: 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

示例3: main

	virtual int main(const std::vector<std::string> &args)
	{

		DisplayWindowDescription desc;
		desc.set_size(Size(800,600), true);
		desc.set_title("Span Layout Test");
		DisplayWindow window(desc);

		Canvas canvas(window);
		GraphicContext gc = window.get_gc();

		FontDescription font_desc1;
		font_desc1.set_typeface_name("Verdana");
		font_desc1.set_height(-13);
		Font font1(canvas, font_desc1);

		Image smiley(canvas, "smiley.png");

		SpanLayout span;
		span.add_text(" This is a ", font1, Colorf::white, 1);
		span.add_text("red", font1, Colorf::red, 2);
		span.add_text(" text! ", font1, Colorf::white, 3);
		span.add_text("And this   complete   text   is   green with non-blocking space..", font1, Colorf::green, 4);
		span.add_image(smiley, 10, 5);
		span.add_text("This is a really long descriptive and interesting text. ", font1, Colorf::yellow, 6);
		span.add_text("[", font1, Colorf::black, 7);
		span.add_text("15:35", font1, Colorf::white, 8);
		span.add_text("]", font1, Colorf::black, 9);
		span.add_image(smiley, 0, 10);
		span.add_image(smiley, 2, 11);
		span.add_text("kthxbye!", font1, Colorf::blue, 12);

		span.layout(gc, 200);
		span.set_position(Point(10, 10));

		while (!window.get_ic().get_keyboard().get_keycode(keycode_escape))
		{
			gc.clear(Colorf::gray70);

			span.draw_layout(canvas);

			Point mouse_pos = window.get_ic().get_mouse().get_position();
			SpanLayout::HitTestResult result = span.hit_test(gc, mouse_pos);

			std::string type;
			switch(result.type)
			{
				case SpanLayout::HitTestResult::no_objects_available:
					type = "no_objects_available";
					break;
				case SpanLayout::HitTestResult::outside_top:
					type = "outside_top";
					break;
				case SpanLayout::HitTestResult::outside_left:
					type = "outside_left";
					break;
				case SpanLayout::HitTestResult::outside_right:
					type = "outside_right";
					break;
				case SpanLayout::HitTestResult::outside_bottom:
					type = "outside_bottom";
					break;
				case SpanLayout::HitTestResult::inside:
					type = "inside";
					break;
			}
			std::string result_text = string_format("HitTestResult: Type:%1 ID:%2 Offset:%3", type, result.object_id, result.offset);

			font1.draw_text(canvas, 10, 300, result_text);

			window.flip();
			KeepAlive::process();
			System::sleep(50);
		}

		return 0;
	}
开发者ID:lonelylife,项目名称:ClanLib,代码行数:77,代码来源:test.cpp


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