本文整理汇总了C++中GraphicContext::draw_primitives方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicContext::draw_primitives方法的具体用法?C++ GraphicContext::draw_primitives怎么用?C++ GraphicContext::draw_primitives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicContext
的用法示例。
在下文中一共展示了GraphicContext::draw_primitives方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flush
void RenderBatchTriangle::flush(GraphicContext &gc)
{
if (position > 0)
{
gc.set_program_object(program_sprite);
int gpu_index;
VertexArrayVector<SpriteVertex> gpu_vertices(batch_buffer->get_vertex_buffer(gc, gpu_index));
if (prim_array[gpu_index].is_null())
{
prim_array[gpu_index] = PrimitivesArray(gc);
prim_array[gpu_index].set_attributes(0, gpu_vertices, cl_offsetof(SpriteVertex, position));
prim_array[gpu_index].set_attributes(1, gpu_vertices, cl_offsetof(SpriteVertex, color));
prim_array[gpu_index].set_attributes(2, gpu_vertices, cl_offsetof(SpriteVertex, texcoord));
prim_array[gpu_index].set_attributes(3, gpu_vertices, cl_offsetof(SpriteVertex, texindex));
if (glyph_blend.is_null())
{
BlendStateDescription blend_desc;
blend_desc.set_blend_function(blend_constant_color, blend_one_minus_src_color, blend_zero, blend_one);
glyph_blend = BlendState(gc, blend_desc);
}
}
gpu_vertices.upload_data(gc, 0, vertices, position);
for (int i = 0; i < num_current_textures; i++)
gc.set_texture(i, current_textures[i]);
if (use_glyph_program)
{
gc.set_blend_state(glyph_blend, constant_color);
gc.draw_primitives(type_triangles, position, prim_array[gpu_index]);
gc.reset_blend_state();
}
else
{
gc.draw_primitives(type_triangles, position, prim_array[gpu_index]);
}
for (int i = 0; i < num_current_textures; i++)
gc.reset_texture(i);
gc.reset_program_object();
position = 0;
for (int i = 0; i < num_current_textures; i++)
current_textures[i] = Texture2D();
num_current_textures = 0;
}
}
示例2: flush
void RenderBatchPoint::flush(GraphicContext &gc)
{
if (position > 0)
{
gc.set_program_object(program_color_only);
int gpu_index;
VertexArrayVector<PointVertex> gpu_vertices(batch_buffer->get_vertex_buffer(gc, gpu_index));
if (prim_array[gpu_index].is_null())
{
prim_array[gpu_index] = PrimitivesArray(gc);
prim_array[gpu_index].set_attributes(0, gpu_vertices, cl_offsetof(PointVertex, position));
prim_array[gpu_index].set_attributes(1, gpu_vertices, cl_offsetof(PointVertex, color));
}
gpu_vertices.upload_data(gc, 0, vertices, position);
gc.draw_primitives(type_points, position, prim_array[gpu_index]);
gc.reset_program_object();
position = 0;
}
}
示例3: Draw
void Model_Impl::Draw(GraphicContext &gc, GraphicStore *gs, const Mat4f &modelview_matrix)
{
Mat4f matrix_modelview_projection = gs->camera_projection * modelview_matrix;
Mat3f normal_matrix = Mat3f(modelview_matrix);
normal_matrix.inverse();
normal_matrix.transpose();
PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, vbo_positions, 3, type_float, 0);
prim_array.set_attributes(1, vbo_normals, 3, type_float, 0);
gs->shader_color.SetMaterial(material_shininess, material_emission, material_ambient, material_specular);
gs->shader_color.Use(gc, modelview_matrix, matrix_modelview_projection, Mat4f(normal_matrix));
gc.draw_primitives(type_triangles, vbo_size, prim_array);
}
示例4: Draw
void ParticleObject::Draw(GraphicContext &gc, GraphicStore *gs, const Mat4f &modelview_matrix)
{
Mat4f matrix_modelview_projection = gs->camera_projection * modelview_matrix;
PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, object_positions_vbo, 3, type_float, 0);
prim_array.set_attributes(1, object_colours_vbo, 4, type_float, 0);
gs->shader_color_geometry.Use(gc, matrix_modelview_projection);
gc.set_texture(0, gs->texture_ball);
gc.draw_primitives(type_points, num_points, prim_array);
gc.reset_texture(0);
}
示例5: render_texture
void HSV::render_texture(Canvas &canvas, ProgramObject &program, Texture &texture, float hue_offset)
{
GraphicContext gc = canvas.get_gc();
Rectf rect(0.0f, 0.0f, (float)gc.get_width(), (float)gc.get_height());
Rectf texture_unit1_coords(0.0f, 0.0f, 1.0f, 1.0f);
Vec2f positions[6] =
{
Vec2f(rect.left, rect.top),
Vec2f(rect.right, rect.top),
Vec2f(rect.left, rect.bottom),
Vec2f(rect.right, rect.top),
Vec2f(rect.left, rect.bottom),
Vec2f(rect.right, rect.bottom)
};
Vec2f tex1_coords[6] =
{
Vec2f(texture_unit1_coords.left, texture_unit1_coords.top),
Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
Vec2f(texture_unit1_coords.right, texture_unit1_coords.top),
Vec2f(texture_unit1_coords.left, texture_unit1_coords.bottom),
Vec2f(texture_unit1_coords.right, texture_unit1_coords.bottom)
};
PrimitivesArray primarray(gc);
VertexArrayVector<Vec2f> gpu_positions = VertexArrayVector<Vec2f>(gc, positions, 6);
VertexArrayVector<Vec2f> gpu_tex1_coords = VertexArrayVector<Vec2f>(gc, tex1_coords, 6);
primarray.set_attributes(0, gpu_positions);
primarray.set_attributes(1, gpu_tex1_coords);
ProgramUniforms buffer;
buffer.cl_ModelViewProjectionMatrix = canvas.get_projection() * canvas.get_modelview();
buffer.HueOffset0 = hue_offset;
UniformVector<ProgramUniforms> uniform_vector(gc, &buffer, 1);
gc.set_uniform_buffer(0, uniform_vector);
gc.set_texture(0, texture);
gc.set_program_object(program);
gc.draw_primitives(type_triangles, 6, primarray);
gc.reset_program_object();
gc.reset_texture(0);
}