本文整理汇总了C++中Renderable::index_data方法的典型用法代码示例。如果您正苦于以下问题:C++ Renderable::index_data方法的具体用法?C++ Renderable::index_data怎么用?C++ Renderable::index_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderable
的用法示例。
在下文中一共展示了Renderable::index_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void GenericRenderer::render(Renderable& buffer, CameraID camera, GPUProgram* program) {
if(!program) {
L_ERROR("No shader is bound, so nothing will be rendered");
return;
}
std::size_t index_count = buffer.index_data().count();
if(!index_count) {
return;
}
GLStateStash s2(GL_ELEMENT_ARRAY_BUFFER_BINDING);
GLStateStash s3(GL_ARRAY_BUFFER_BINDING);
buffer._update_vertex_array_object();
buffer._bind_vertex_array_object();
//Attributes don't change per-iteration of a pass
set_auto_attributes_on_shader(buffer);
set_auto_uniforms_on_shader(*program, camera, buffer);
//Render the mesh, once for each iteration of the pass
switch(buffer.arrangement()) {
case MESH_ARRANGEMENT_POINTS:
GLCheck(glDrawElements, GL_POINTS, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
break;
case MESH_ARRANGEMENT_LINES:
GLCheck(glDrawElements, GL_LINES, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
break;
case MESH_ARRANGEMENT_LINE_STRIP:
GLCheck(glDrawElements, GL_LINE_STRIP, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
break;
case MESH_ARRANGEMENT_TRIANGLES:
GLCheck(glDrawElements, GL_TRIANGLES, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
break;
case MESH_ARRANGEMENT_TRIANGLE_STRIP:
GLCheck(glDrawElements, GL_TRIANGLE_STRIP, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
break;
case MESH_ARRANGEMENT_TRIANGLE_FAN:
GLCheck(glDrawElements, GL_TRIANGLE_FAN, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
break;
default:
throw NotImplementedError(__FILE__, __LINE__);
}
}