如何仅在OpenGL中绘制顶点数组中的选定索引?OpenGL仅从顶点数组中绘制一些索引
举例来说,我画我的顶点,如点,一些变量m_pointCloud
包含我的点云的顶点(点):
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glPointSize(m_pointSize * point_scale);
glColorPointer(4, GL_UNSIGNED_BYTE,
static_cast<GLsizei>(sizeof(DensePoint)), &((*m_pointCloud)[0].r));
// glNormalPointer(GL_FLOAT,
// static_cast<GLsizei>(sizeof(DensePoint)), &((*m_pointCloud)[0].n_x));
glVertexPointer(3, GL_FLOAT,
static_cast<GLsizei>(sizeof(DensePoint)), &((*m_pointCloud)[0].x));
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(m_pointCloud->size()) - 1);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
但我有一些std::vector<size_t> indices
包含指数从m_pointCloud
,我要画。这是如何完成的?
使用索引缓冲区(GL_ELEMENT_ARRAY_BUFFER)和/或使用glDrawElement进行绘制。 – BDL
但是可以用'glVertexPointer'来完成吗?你能提供一些例子吗? – manatttta