本文整理汇总了C++中Patch::GetCIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Patch::GetCIndex方法的具体用法?C++ Patch::GetCIndex怎么用?C++ Patch::GetCIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patch
的用法示例。
在下文中一共展示了Patch::GetCIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void CRasterTerrainModel::Render() const
{
//glColor3f(1.0f, 0.0f, 0.0f);
if (glPrimitiveRestartIndex == nullptr) {
GLenum glew_err = glewInit();
if (glew_err != GLEW_NO_ERROR) {
std::cout << "failed to initialize opengl extension wrapper: " << (const char*)glewGetErrorString(glew_err) << std::endl;
return;
}
}
glEnable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(1.0, 1.0);
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(UINT_MAX);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
//reset number of rendered triangles
mNumberOfRenderedTriangles = 0;
std::vector<Patch*>::const_iterator itr, itre = mActivePatches.end();
for (itr = mActivePatches.begin(); itr != itre; ++itr) {
Patch* p = (*itr);
//compute id
uint hlv = p->neigbor[0] ? p->neigbor[0]->tessLevel : 0;
uint vlv = p->neigbor[1] ? p->neigbor[1]->tessLevel : 0;
uint cid = p->GetCIndex();
uint tessID = vlv + hlv*mTessLevels + cid*(mTessLevels*mTessLevels);
glBindBuffer(GL_ARRAY_BUFFER, p->glbuf);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mTessellationIBOs[tessID]);
glVertexPointer(3, GL_FLOAT, sizeof(CRasterTerrainModel::Vertex), 0);
glNormalPointer(GL_FLOAT, sizeof(CRasterTerrainModel::Vertex), (void*)12);
//glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>((*itr)->vbuf.size()));
glDrawElements(GL_TRIANGLE_STRIP, static_cast<GLsizei>(mTessellationIBufs[tessID].size()), GL_UNSIGNED_INT, 0);
//count number of rendered triangles
mNumberOfRenderedTriangles += static_cast<unsigned int>(mTessellationIBufs[tessID].size());
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableClientState(GL_NORMAL_ARRAY);
glDisable(GL_PRIMITIVE_RESTART);
glDisable(GL_POLYGON_OFFSET_LINE);
glDisable(GL_POLYGON_OFFSET_FILL);
}