I am curious about how OpenGL assigns Multiple Display List IDs.
Currently I have:
void MyCreateList() {
MyListID = glGenLists(1);
glNewList(MyListID, GL_COMPILE);
//gluSphere(qobj, 1.0, 20, 20); //Sphere
//gluCylinder(qobj, 1.0, 0.0, 2.0, 20, 8); //Cylinder
gluDisk(qobj, 0.25, 1.0, 20, 3); //Disk
//gluPartialDisk(qobj, 0.5, 1.0, 26, 13, 0, 180); //PartialDisk
glEndList();
}
=> ID of One Display List.
void MyCreateList() {
GLuint listOne, listTwo, listThree, listFour;
listOne = glGenLists(4);
listTwo = listOne + 1;
listThree = listTwo + 1;
listFour = listThree + 1;
glNewList(listThree, GL_COMPILE);
gluSphere(qobj, 1.0, 20, 20); //Sphere
gluCylinder(qobj, 1.0, 0.0, 2.0, 20, 8); //Cylinder
gluDisk(qobj, 0.25, 1.0, 20, 3); //Disk
gluPartialDisk(qobj, 0.5, 1.0, 26, 13, 0, 180); //PartialDisk
glEndList();
}
=> ID of Multiple Display Lists.
Here's the desired result:
If you assign only one ID using the Display List, there is no problem, but if you assign more than one ID, it will not work.
Any ideas?

A display list groups a sequence of OpenGL commands and data, so that it can be executed repeatedly after its initial creation, in order to improve the program's performance (more information on display lists with various code examples can be found here).
Note that display lists have been deprecated in OpenGL 3.0 and removed in OpenGL 3.1, which was already discussed here: Why were display lists deprecated in opengl 3.1?
The four
glu*()calls in your second code snippet create graphics primitives, that are stored in only one of the four generated display lists, namely inlistThree. In that display list, the sphere, cylinder, disk and the partial disk are placed at the same position, and will therefore overlap. Also, the four display list ID variableslistOne, listTwo, listThree, listFourare local to the scope of the functionMyCreateList(), so they will not be accessible after the function call.If the program should generate the result from the posted screenshot, then only one shape (generated with
gluDisk()) and one display list is required. (Why should multiple display lists be used for that task?)If this is an educational exercise, I think it's about putting transforms into a display list, to generate the shown skewed scape, for example like this (disk stretched with
glScalef()and turned withglRotatef()):And, here a modified example, that illustrates the use of multiple display lists:
The documentation of all the used GL/GLU functions can be found there:
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/
The documentation of all the used GLUT functions can be found there:
https://www.opengl.org/resources/libraries/glut/spec3/spec3.html
More information on the topic of "Legacy OpenGL" can be found here.