-1

我的文件结构为

  • 显示列表.hpp
  • 显示列表.cpp
  • 文件1.cpp

现在我想使用 file1.cpp 中的显示列表之一。

我的display_list.hpp样子

extern GLuint index;
void genDisplayList();

然后display_list.cpp看起来像

GLuint index = glGenLists(1);
void genDisplayList(){
    glNewList(index, GL_COMPILE);
    glBegin(GL_POLYGON);
    /*..vertex for polygon...*/
    glEnd();
    glEndList();
}

但是当我尝试在glCallList(index)我的 file1.cpp 中使用时,我没有在屏幕上绘制任何内容。

4

1 回答 1

1

a) 你不应该使用显示列表。显示列表已被 OpenGL-2 弃用(OpenGL-2 的初稿完全删除了它们),并已从 OpenGL-3 及更高版本中删除。

b) 要创建显示列表,需要在当前线程上激活有效的 OpenGL 上下文。我假设您是genDisplayLists在 OpenGL 上下文之前调用的,例如,如果它们是由全局范围对象实例的构造函数调用的。

于 2014-10-03T12:11:19.717 回答