I have file structure as
- display_list.hpp
- display_list.cpp
- file1.cpp
Now I want to use one of the display list in file1.cpp.
my display_list.hpp looks like
extern GLuint index;
void genDisplayList();
then display_list.cpp looks like
GLuint index = glGenLists(1);
void genDisplayList(){
glNewList(index, GL_COMPILE);
glBegin(GL_POLYGON);
/*..vertex for polygon...*/
glEnd();
glEndList();
}
But when I tried to use glCallList(index) into my file1.cpp, I got nothing drawn on screen.
a) You should not use display lists. Display Lists have been deprecated with OpenGL-2 (the first drafts for OpenGL-2 removed them completely) and have been removed from OpenGL-3 and later.
b) To create a display list a valid OpenGL context is required to be active on the current thread. I presume you're calling
genDisplayListsbefore there is a OpenGL context, for example if they're called by a constructor of a global scope object instance.