According to the OpenGL Programming Guide V1.4 display lists should be able to handle modelling transformations and such. However I experience something very different, but probably there is just a stupid bug in my code.
I want to draw graphs, that is a heap of dots and lines, or to let it appear more nicely a heap of spheres and cylinders. So I have a variable number of spheres representing my vertices (of my graph not of an OpenGL thing) and cylinders for edges. For both sphere and cylinder I have a display list and then I simply do all the transformations so the spheres and cylinders appear in all the right places. So far so good.
However if I put all this, obviously together with the modelling transformations, into another display list, things get messed up. All I see is a single sphere (or probably more correct: n spheres all exactly on top of each other, and no cylinder as it is inside the sphere). Basically what I see is the same as if there would have been no modelling transformations.
Why is that?
Here’s my code:
function draw_cubes() {
GLint cubelist;
cubelist=glGenLists(1);
glNewList(cubelist,GL_COMPILE);
cube->opengl_draw_solid(); //draws one cube
glEndList();
delete cube;
for (pre_opengl_object<pre_opengl_vertex>* vertex=v.first(); vertex!=0; vertex=vertex->next) {
glPushMatrix();
glTranslated(vertex->item->x(),vertex->item->y(),vertex->item->z());
glCallList(cubelist);
glPopMatrix();
}
glDeleteLists(cubelist,1);
}
somesub() {
glNewList(x,GL_COMPILE)
draw_cubes();
glEndList();
}
someothersub() {
draw_cubes(); //works
glCallList(x); //doesn’t work