本文整理汇总了C++中CL_GraphicContext::draw_primitives方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::draw_primitives方法的具体用法?C++ CL_GraphicContext::draw_primitives怎么用?C++ CL_GraphicContext::draw_primitives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::draw_primitives方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prim_array
void CL_RenderBatch3D::flush(CL_GraphicContext &gc)
{
if (position > 0)
{
gc.set_modelview(CL_Mat4f::identity());
gc.set_program_object(cl_program_sprite);
if (use_glyph_program)
{
CL_BlendMode old_blend_mode = gc.get_blend_mode();
CL_BlendMode blend_mode;
blend_mode.set_blend_color(constant_color);
blend_mode.set_blend_function(cl_blend_constant_color, cl_blend_one_minus_src_color, cl_blend_zero, cl_blend_one);
gc.set_blend_mode(blend_mode);
for (int i = 0; i < num_current_textures; i++)
gc.set_texture(i, current_textures[i]);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
gc.draw_primitives(cl_triangles, position, prim_array);
for (int i = 0; i < num_current_textures; i++)
gc.reset_texture(i);
gc.set_blend_mode(old_blend_mode);
}
else
{
for (int i = 0; i < num_current_textures; i++)
gc.set_texture(i, current_textures[i]);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
gc.draw_primitives(cl_triangles, position, prim_array);
for (int i = 0; i < num_current_textures; i++)
gc.reset_texture(i);
}
gc.reset_program_object();
gc.set_modelview(modelview);
position = 0;
for (int i = 0; i < num_current_textures; i++)
current_textures[i] = CL_Texture();
num_current_textures = 0;
}
}
示例2: draw_texture
void App::draw_texture(CL_GraphicContext &gc, const CL_Rectf &rect, const CL_Colorf &color, const CL_Rectf &texture_unit1_coords)
{
CL_Vec2f positions[6] =
{
CL_Vec2f(rect.left, rect.top),
CL_Vec2f(rect.right, rect.top),
CL_Vec2f(rect.left, rect.bottom),
CL_Vec2f(rect.right, rect.top),
CL_Vec2f(rect.left, rect.bottom),
CL_Vec2f(rect.right, rect.bottom)
};
CL_Vec2f tex1_coords[6] =
{
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.bottom)
};
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, positions);
prim_array.set_attribute(1, color);
prim_array.set_attributes(2, tex1_coords);
gc.draw_primitives(cl_triangles, 6, prim_array);
}
示例3: gradient_fill
void CL_Draw::gradient_fill(CL_GraphicContext &gc, float x1, float y1, float x2, float y2, const CL_Gradient &gradient)
{
CL_Vec2f positions[6] =
{
CL_Vec2f(x1, y1),
CL_Vec2f(x2, y1),
CL_Vec2f(x1, y2),
CL_Vec2f(x2, y1),
CL_Vec2f(x1, y2),
CL_Vec2f(x2, y2)
};
#define cl_color_to_color4d(c) c.get_red(), c.get_green(), c.get_blue(), c.get_alpha()
CL_Vec4f colors[6] =
{
CL_Vec4f(cl_color_to_color4d(gradient.top_left)),
CL_Vec4f(cl_color_to_color4d(gradient.top_right)),
CL_Vec4f(cl_color_to_color4d(gradient.bottom_left)),
CL_Vec4f(cl_color_to_color4d(gradient.top_right)),
CL_Vec4f(cl_color_to_color4d(gradient.bottom_left)),
CL_Vec4f(cl_color_to_color4d(gradient.bottom_right))
};
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, positions);
prim_array.set_attributes(1, colors);
gc.set_program_object(cl_program_color_only);
gc.draw_primitives(cl_triangles, 6, prim_array);
gc.reset_program_object();
}
示例4: draw
/**
* Draws the polygon on the graphics context.
*
* @param gc Graphics context to draw the polygon on.
*/
void Polygon::draw(CL_GraphicContext gc)
{
//Only draw if more than one point exists.
if(_points.size() > 1)
{
//CL_Vec4f green_color(1.0f, 1.0f, 1.0f, 1.0f);
CL_Vec2i points_array[_points.size()];
std::list<CL_Pointf>::iterator it_point;
int n = 0;
for(it_point = _points.begin(); it_point != _points.end(); ++it_point)
{
points_array[n] = static_cast<CL_Vec2i>(*(it_point));
n++;
}
CL_PrimitivesArray poly(gc);
poly.set_attributes(0, points_array);
poly.set_attribute(1, _line_color);
//scene->get_world()->get_gc()->get_polygon_rasterizer().set_face_fill_mode_front(cl_fill_polygon);
gc.set_program_object(cl_program_color_only);
gc.draw_primitives(cl_line_loop,n,poly);
gc.reset_program_object();
}
}
示例5: Draw
void Model_Impl::Draw(CL_GraphicContext &gc, GraphicStore *gs, const CL_Mat4f &modelview_matrix)
{
gc.set_modelview(modelview_matrix);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, vbo_positions, 3, cl_type_float, (void *) 0);
prim_array.set_attributes(1, vbo_normals, 3, cl_type_float, (void *) 0);
if (!vbo_texcoords.is_null())
{
prim_array.set_attributes(2, vbo_texcoords, 2, cl_type_float, (void *) 0);
gc.set_texture(0, gs->texture_underwater);
gc.set_texture(1, gs->texture_background);
gs->shader_texture.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
gs->shader_texture.Use(gc);
}
else
{
throw CL_Exception("What! no texure coordinates?");
}
gc.draw_primitives(cl_triangles, vbo_size, prim_array);
gc.reset_texture(0);
gc.reset_texture(0);
}
示例6: point
void CL_Draw::point(CL_GraphicContext &gc, float x1, float y1, const CL_Colorf &color)
{
CL_Vec2f positions[1] =
{
CL_Vec2f(x1, y1)
};
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, positions);
prim_array.set_attribute(1, color);
gc.set_program_object(cl_program_color_only);
gc.draw_primitives(cl_points, 1, prim_array);
gc.reset_program_object();
}
示例7: Draw
void Model_Impl::Draw(CL_GraphicContext &gc, GraphicStore *gs, const CL_Mat4f &modelview_matrix, bool is_draw_shadow)
{
gc.set_modelview(modelview_matrix);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, vbo_positions, 3, cl_type_float, (void *) 0);
prim_array.set_attributes(1, vbo_normals, 3, cl_type_float, (void *) 0);
if (is_draw_shadow)
{
gs->shader_depth.Use(gc);
gc.draw_primitives(cl_triangles, vbo_size, prim_array);
}
else
{
if (!vbo_texcoords.is_null())
{
prim_array.set_attributes(2, vbo_texcoords, 2, cl_type_float, (void *) 0);
gs->shader_texture.SetShadowMatrix(gs->shadow_matrix);
gc.set_texture(0, gs->texture_brick);
gc.set_texture(1, gs->texture_shadow);
gs->shader_texture.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
gs->shader_texture.Use(gc);
}
else
{
gs->shader_color.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
gs->shader_color.Use(gc);
}
gc.draw_primitives(cl_triangles, vbo_size, prim_array);
gc.reset_texture(0);
gc.reset_texture(1);
}
}
示例8: Draw
void Model_Impl::Draw(CL_GraphicContext &gc, GraphicStore *gs, const CL_Mat4f &modelview_matrix)
{
gc.set_modelview(modelview_matrix);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, vbo_positions, 3, cl_type_float, (void *) 0);
prim_array.set_attributes(1, vbo_normals, 3, cl_type_float, (void *) 0);
gs->shader_color.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
gs->shader_color.Use(gc);
gc.draw_primitives(cl_triangles, vbo_size, prim_array);
}
示例9: triangle
void CL_Draw::triangle(CL_GraphicContext &gc, const CL_Pointf &a, const CL_Pointf &b, const CL_Pointf &c, const CL_Colorf &color)
{
CL_Vec2f positions[3] =
{
CL_Vec2f(a.x, a.y),
CL_Vec2f(b.x, b.y),
CL_Vec2f(c.x, c.y)
};
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, positions);
prim_array.set_attribute(1, color);
gc.set_program_object(cl_program_color_only);
gc.draw_primitives(cl_triangles, 3, prim_array);
gc.reset_program_object();
}
示例10: box
void CL_Draw::box(CL_GraphicContext &gc, float x1, float y1, float x2, float y2, const CL_Colorf &color)
{
CL_Vec2f positions[4] =
{
CL_Vec2f(x1, y1),
CL_Vec2f(x2, y1),
CL_Vec2f(x2, y2),
CL_Vec2f(x1, y2)
};
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, positions);
prim_array.set_attribute(1, color);
gc.set_program_object(cl_program_color_only);
gc.draw_primitives(cl_line_loop, 4, prim_array);
gc.reset_program_object();
}
示例11: render
void Skybox::render(CL_GraphicContext &gc, const Camera &camera)
{
Camera cam = camera;
cam.get_position().set_position(0,0,0);
cam.setup_gc(gc, 0.1f, 10.0f);
gc.set_texture(0, skybox_texture);
gc.set_program_object(program_object);
program_object.set_uniform1i(("texture1"), 0);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, positions);
gc.draw_primitives(cl_triangles, 6*6, prim_array);
gc.reset_program_object();
gc.reset_texture(0);
}
示例12: flush
void HSVSpriteBatch::flush(CL_GraphicContext &gc)
{
if (fill_position > 0)
{
CL_PrimitivesArray primarray(gc);
primarray.set_attributes(0, positions);
primarray.set_attributes(1, hue_offsets);
primarray.set_attributes(2, tex1_coords);
gc.set_texture(0, current_texture);
gc.set_program_object(program, cl_program_matrix_modelview_projection);
gc.draw_primitives(cl_triangles, fill_position, primarray);
gc.reset_program_object();
gc.reset_texture(0);
fill_position = 0;
current_texture = CL_Texture();
}
}
示例13: end
void ShaderImpl::end(CL_GraphicContext &p_gc)
{
G_ASSERT(m_initialized);
G_ASSERT(m_began);
// detach frame buffer
p_gc.reset_frame_buffer();
m_frameBuffer.detach_color_buffer(0, m_texture);
// prepare shader
m_program.set_uniform1i("tex", 0);
m_program.set_uniform1i("textureWidth", m_drawRect.get_width());
m_program.set_uniform1i("textureHeight", m_drawRect.get_height());
m_parent->setUniforms(m_program);
// draw texture using shader
p_gc.set_modelview(CL_Mat4f::identity());
p_gc.mult_translate(m_drawRect.left, m_drawRect.top);
p_gc.mult_scale(m_drawRect.get_width(), m_drawRect.get_height());
p_gc.set_texture(0, m_texture);
p_gc.set_program_object(m_program);
p_gc.draw_primitives(cl_quads, 4, m_quad);
p_gc.reset_program_object();
p_gc.reset_texture(0);
#if defined(DRAW_WIREFRAME)
CL_Draw::line(p_gc, 0, 0, 1, 0, CL_Colorf::red);
CL_Draw::line(p_gc, 1, 0, 1, 1, CL_Colorf::red);
CL_Draw::line(p_gc, 1, 1, 0, 1, CL_Colorf::red);
CL_Draw::line(p_gc, 0, 1, 0, 0, CL_Colorf::red);
#endif // DRAW_WIREFRAME
// reset modelview matrix
p_gc.pop_modelview();
m_began = false;
}
示例14: texture
void CL_Draw::texture(
CL_GraphicContext &gc,
const CL_Texture &texture,
const CL_Quadf &quad,
const CL_Colorf &color,
const CL_Rectf &texture_unit1_coords)
{
CL_Vec2f positions[6] =
{
CL_Vec2f(quad.p),
CL_Vec2f(quad.q),
CL_Vec2f(quad.s),
CL_Vec2f(quad.q),
CL_Vec2f(quad.s),
CL_Vec2f(quad.r)
};
CL_Vec2f tex1_coords[6] =
{
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.bottom)
};
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, positions);
prim_array.set_attribute(1, color);
prim_array.set_attributes(2, tex1_coords);
gc.set_texture(0, texture);
gc.set_program_object(cl_program_single_texture);
gc.draw_primitives(cl_triangles, 6, prim_array);
gc.reset_program_object();
gc.reset_texture(0);
}
示例15: render_texture
void HSV::render_texture(CL_GraphicContext &gc, CL_ProgramObject &program, CL_Texture &texture, float hue_offset)
{
CL_Rectf rect(0.0f, 0.0f, (float)gc.get_width(), (float)gc.get_height());
CL_Rectf texture_unit1_coords(0.0f, 0.0f, 1.0f, 1.0f);
CL_Vec2f positions[6] =
{
CL_Vec2f(rect.left, rect.top),
CL_Vec2f(rect.right, rect.top),
CL_Vec2f(rect.left, rect.bottom),
CL_Vec2f(rect.right, rect.top),
CL_Vec2f(rect.left, rect.bottom),
CL_Vec2f(rect.right, rect.bottom)
};
CL_Vec2f tex1_coords[6] =
{
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
CL_Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
CL_Vec2f(texture_unit1_coords.right, texture_unit1_coords.bottom)
};
CL_PrimitivesArray primarray(gc);
primarray.set_attributes(0, positions);
primarray.set_attribute(1, CL_Vec1f(hue_offset));
primarray.set_attributes(2, tex1_coords);
gc.set_texture(0, texture);
gc.set_program_object(program, cl_program_matrix_modelview_projection);
gc.draw_primitives(cl_triangles, 6, primarray);
gc.reset_program_object();
gc.reset_texture(0);
}