【问题标题】:Can anyone tell me what version of opengl is this? [closed]谁能告诉我这是什么版本的opengl? [关闭]
【发布时间】: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(),但它可能是任何版本,因为这些功能已被弃用,但几乎任何版本仍然支持。

标签: c++ opengl


【解决方案1】:

第一段代码没有特定的 OpenGL 版本,除了 GLuint,一切都是标准 c++(IndexVect 看起来像 std::vector),而 GLuint 是基本数字类型(如 unsigned int、unsigned short、. ..) 在每个 OpenGL 版本中使用。

代码没有OpenGL调用的原因是它只在CPU上定义了一个对象的结构,它没有将数据复制到GPU,也没有渲染任何东西。

void Display(void) { 
       glClear(GL_COLOR_BUFFER_BIT); 
       glLoadIdentity();
       glTranslatef(0.0,0.0,-4.0);
       glRotatef(yRotated, 0.0, 1.0, 0.0);
       DrawSphere();
       glFlush();
       //Finish rendering
       glutSwapBuffers(); } 

即 OpenGL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    • 2013-05-29
    • 1970-01-01
    • 2016-03-14
    • 2015-12-28
    • 2020-08-09
    • 1970-01-01
    相关资源
    最近更新 更多