本文整理汇总了C++中CL_GraphicContext::reset_pen方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::reset_pen方法的具体用法?C++ CL_GraphicContext::reset_pen怎么用?C++ CL_GraphicContext::reset_pen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::reset_pen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: 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;
}