2014-10-03 81 views
-1

我的文件结构宣布所有显示列表头文件的OpenGL

  • display_list.hpp
  • display_list.cpp
  • file1.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,我什么也没得到在屏幕上绘制。

回答

1

a)您不应该使用显示列表。显示列表已被OpenGL-2(OpenGL-2的第一批草稿完全删除)弃用,并且已从OpenGL-3及更高版本中删除。

b)要创建一个显示列表,有效的OpenGL上下文需要在当前线程上处于活动状态。我假设你在OpenGL上下文之前调用genDisplayLists,例如,如果它们是由全局作用域对象实例的构造函数调用的。

+0

我使用的是opengl 2.0,并且已经正确初始化上下文。 – Dheerendra 2014-10-03 12:35:58