【发布时间】:2013-05-22 20:05:48
【问题描述】:
你能告诉我这段代码是用什么版本的opengl编写的吗?
//The triangles to the highest and deepest vertices:
for (j = 0; j< (PointsPerRow-1); j++)
{
IndexVect.push_back(j);
IndexVect.push_back(j+1);
IndexVect.push_back((PointRows-2)*PointsPerRow);
}
IndexVect.push_back(j);
IndexVect.push_back(0);
IndexVect.push_back((PointRows-2)*PointsPerRow);
for (j = 0; j< (PointsPerRow-1); j++)
{
IndexVect.push_back((PointRows-3)*PointsPerRow+j);
IndexVect.push_back((PointRows-3)*PointsPerRow+j+1);
IndexVect.push_back((PointRows-2)*PointsPerRow+1);
}
IndexVect.push_back((PointRows-3)*PointsPerRow+j);
IndexVect.push_back((PointRows-3)*PointsPerRow);
IndexVect.push_back((PointRows-2)*PointsPerRow+1);
Indices = new GLuint[IndexVect.size()]; //allocate the required memory
for (i = 0; i < IndexVect.size(); i++)
{
Indices[i] = IndexVect[i];
}
NumIndices = IndexVect.size();
IndexVect.clear(); //no longer needed, takes only memory
}
这是一个顶点数组核心,告诉我它是用哪个版本写的?
【问题讨论】:
-
我在这里看不到 OpenGL 特定的代码....我的猜测是 4.x,因为他们似乎在为 IBO 使用索引向量?
-
根据您发布的代码,首先很难将其识别为 OpenGL,更不用说为其提供特定版本了。您可以尝试使用最新的 OpenGL 库构建它,看看它是否有效?
-
GLuint 在 OpenGL 中很常见。如果您正在尝试检索您的代码正在运行的版本,您可以尝试:glGetString(GL_VERSION);这将告诉您正在运行哪个版本的 OpenGL。如果你想知道运行这段代码需要哪个版本,答案是我所知道的所有 OpenGL 版本都可以做到这一点。
-
抱歉,push_back 是 C++ 方法,不是 opengl 方法 cplusplus.com/reference/stl/vector/push_back
-
这看起来像 OpenGL 2.1,可能是因为使用了
glLoadIdentity()和glTranslatef(),但它可能是任何版本,因为这些功能已被弃用,但几乎任何版本仍然支持。