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


C++ CL_GraphicContext::set_pen方法代码示例

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


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

示例1: draw

void Label::draw(CL_GraphicContext &p_gc)
{
	assert(isLoaded());

	float ax, ay;
	const CL_Size s = size(p_gc);

	calculateAttachPoint(s.width, s.height, ax, ay);

	const float x = m_pos.x - ax;
	const float y = m_pos.y - ay - m_fontMetrics.get_descent();

	m_clFont->draw_text(p_gc, x, y, m_text, m_color);

#if !defined(NDEBUG) && defined(DRAW_LABEL_BOUNDS)
	// draw label frame debug code
	CL_Pen newPen;
	newPen.set_line_width(1.0f);

	const CL_Pen oldPen = p_gc.get_pen();
	p_gc.set_pen(newPen);

	const float y2 = y + m_fontMetrics.get_descent();
	CL_Draw::box(p_gc, x, y2 - s.height, x + s.width, y2, CL_Colorf::red);

	p_gc.set_pen(oldPen);
#endif // !NDEBUG && DRAW_LABEL_BOUNDS
}
开发者ID:bercik,项目名称:gear,代码行数:28,代码来源:Label.cpp

示例2: drawPoint

	void EditorPoint::drawPoint(int p_index, bool &p_isSelected, bool &p_isLight, CL_GraphicContext &p_gc)
	{
		CL_Colorf color = (p_isSelected || p_isLight) ? m_impl->m_selectedPointColor : m_impl->m_pointColor;

		if (p_isSelected)
		{
			if (isFirstKey(CL_KEY_SHIFT) && m_impl->m_selectedIndex != -1)
			{
				CL_Pen pen;

				pen.set_line_width(PAINT_LINE_WIDTH);
				p_gc.set_pen(pen);

				int x1, y1, x2, y2;
				getShiftRect(p_index, &x1, &y1, &x2, &y2);

				CL_Draw::line(p_gc, x1, y1, x2, y2, m_impl->m_shiftLineColor);

				pen.set_line_width(1.0f);
				p_gc.set_pen(pen);

				CL_Draw::fill(p_gc, getPointRect(m_impl->m_minShiftPoint), m_impl->m_minAndMaxShiftRectColor);
				CL_Draw::fill(p_gc, getPointRect(m_impl->m_maxShiftPoint), m_impl->m_minAndMaxShiftRectColor);
			}
		}

		CL_Draw::fill(p_gc, getPointRect(p_index), color);

		if (p_isSelected)
		{
			CL_Draw::box(p_gc, getPointRect(p_index), m_impl->m_selectedPointFrameColor);
		}
	}
开发者ID:bercik,项目名称:gear,代码行数:33,代码来源:EditorPoint.cpp

示例3: draw

void LabelImpl::draw(CL_GraphicContext &p_gc)
{
	G_ASSERT(m_parent->isLoaded());

	float ax, ay;
	const CL_Size s = m_parent->size(p_gc);

	calculateAttachPoint(s.width, s.height, ax, ay);

	CL_Pointf position;
	position.x = m_pos.x - ax;
	position.y = m_pos.y - ay - m_fontMetrics.get_descent();

	if (m_shadowVisible) {
		drawShadow(p_gc, position);
	}

	m_clFont->draw_text(p_gc, position.x, position.y, m_text, m_color);

#if !defined(NDEBUG) && defined(DRAW_LABEL_BOUNDS)
	// draw label frame debug code
	CL_Pen newPen;
	newPen.set_line_width(1.0f);

	const CL_Pen oldPen = p_gc.get_pen();
	p_gc.set_pen(newPen);

	const float y2 = y + m_fontMetrics.get_descent();
	CL_Draw::box(p_gc, x, y2 - s.height, x + s.width, y2, CL_Colorf::red);

	p_gc.set_pen(oldPen);
#endif // !NDEBUG && DRAW_LABEL_BOUNDS
}
开发者ID:genail,项目名称:gear,代码行数:33,代码来源:Label.cpp

示例4: draw

void CL_CollisionOutline::draw(
	float x,
	float y,
	const CL_Colorf &color,
	CL_GraphicContext &gc)
{
	// Draw collision outline (Contours are assumed as closed polygons, hence we use line-loop)
	for(unsigned int i = 0; i < impl->contours.size(); i++)
	{
		// Draw the contour
		unsigned int numpoints = impl->contours[i].get_points().size();
		for(unsigned int s = 0; s < numpoints; s++)
		{
			const CL_Pointf &p1 = impl->contours[i].get_points()[s];
			const CL_Pointf &p2 = impl->contours[i].get_points()[(s+1) % numpoints];
			CL_Draw::line(gc, x + p1.x + 0.5f, y + p1.y + 0.5f, x + p2.x + 0.5f, y + p2.y + 0.5f, color);
		}

		// Add points (as opposite color)
		CL_Colorf colorinv(1.0f-color.get_red(),1.0f-color.get_green(),1.0f-color.get_blue());

		CL_Pen pen;
		pen.set_point_size(2.0);
		gc.set_pen(pen);

		for(unsigned int s1 = 0; s1 < numpoints; s1++)
		{
			const CL_Pointf &p1 = impl->contours[i].get_points()[s1];
			CL_Draw::point(gc, x + p1.x + 0.5f, y + p1.y + 0.5f, colorinv);
		}

		gc.reset_pen();
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:34,代码来源:collision_outline.cpp

示例5: draw

void TireTrack::draw(CL_GraphicContext &p_gc)
{
	CL_Pen pen;
	pen.set_line_width(3);
	p_gc.set_pen(pen);

	// TODO: how to make blend?
	CL_Draw::line(p_gc, m_fromPoint, m_toPoint, CL_Colorf(0.0f, 0.0f, 0.0f, m_fromAlpha));
}
开发者ID:ryba616,项目名称:ryba.racer,代码行数:9,代码来源:TireTrack.cpp

示例6: start


//.........这里部分代码省略.........
	{
		throw CL_Exception(cl_format("Unable to compile vertex shader object: %1", vertex_shader.get_info_log()));
	}

	CL_ShaderObject fragment_shader(gc, cl_shadertype_fragment, text_shader_fragment);
	if(!fragment_shader.compile())
	{
		throw CL_Exception(cl_format("Unable to compile fragment shader object: %1", fragment_shader.get_info_log()));
	}

	CL_ProgramObject program_object(gc);
	program_object.attach(vertex_shader);
	program_object.attach(fragment_shader);
	program_object.bind_attribute_location(0, "InPosition");
	program_object.bind_attribute_location(1, "InColor");
	if (!program_object.link())
	{
		throw CL_Exception(cl_format("Unable to link program object: %1", program_object.get_info_log()));
	}

	options->request_repaint();

	unsigned int time_last = CL_System::get_time();

	while (!quit)
	{
		unsigned int time_now = CL_System::get_time();
		float time_diff = (float) (time_now - time_last);
		time_last = time_now;

		wm.process();
		wm.draw_windows(gc);

		int num_particles = options->num_particles;
		if (num_particles > max_particles)
			num_particles = max_particles;

		move_particles(time_diff, num_particles);

		const float grid_xpos = 10.0f;
		const float grid_ypos = 10.0f;

		// Draw the grid
		image_grid.draw(gc, grid_xpos, grid_ypos);

		if (num_particles > 0)
		{
			std::vector<CL_Vec2f> positions;
			std::vector<CL_Vec4f> colors;
			positions.resize(num_particles);
			colors.resize(num_particles);

			for (int cnt=0; cnt<num_particles; cnt++)
			{
				positions[cnt] = CL_Vec2f(grid_xpos + particles[cnt].xpos, grid_ypos + particles[cnt].ypos);
				switch (cnt % 3)
				{
					case 0:
						colors[cnt] = CL_Vec4f(1.0f, 0.0f, 0.0f, 1.0f);
						break;
					case 1:
						colors[cnt] = CL_Vec4f(0.0f, 1.0f, 0.0f, 1.0f);
						break;
					case 2:
						colors[cnt] = CL_Vec4f(0.0f, 0.0f, 1.0f, 1.0f);
						break;
				}
			};

			CL_BlendMode blend;
			blend.enable_blending(true);
			blend.set_blend_function(cl_blend_src_alpha, cl_blend_one, cl_blend_src_alpha, cl_blend_one);
			gc.set_blend_mode(blend);
			CL_Pen pen;
			pen.enable_point_sprite(true);
			pen.set_point_size(options->point_size);
			pen.set_point_sprite_origin(cl_point_sprite_origin_upper_left);
			gc.set_pen(pen);

			program_object.set_uniform1i("Texture0", 0);

			gc.set_texture(0, texture_particle);
			CL_PrimitivesArray prim_array(gc);
			prim_array.set_attributes(0, &positions[0]);
			prim_array.set_attributes(1, &colors[0]);
			gc.set_program_object(program_object);
			gc.draw_primitives(cl_points, num_particles, prim_array);
			gc.reset_program_object();
			gc.reset_texture(0);
			gc.reset_blend_mode();

			gc.reset_pen();
		}

		window.flip(1);

		CL_KeepAlive::process();
	}
	return 0;
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:101,代码来源:app.cpp


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