display lists off their positions

Hi,

I create display lists first. And next time when I have a chance to render (i.e. the original rendering context becomes current), I call glCalllist. But the objects in the display lists are rendered off their right position. I am very new to display lists. Can someone give me any hit leading the possibility finding what I have missed? Your help is much appreciated.

JD

Reset the modelview matrix calling glLoadIdentity() to prevent the display list data from being affected by previous transformations.

Hi dletozeun,

Thanks for the reply. Should I call glLoadIdentity() right before calling glCallList() or right before calling glGenLists()? Your further help is much appreciated.

JD

Reset the modelview matrix before calling glCallList().
To preserve the matrix state before drawing the display list you can also use the glPush/glPop command and do something like:


glMatrixMode( GL_MODELVIEW );

// Save the current modelview matrix pushing it in the stack
glPushMatrix();
// Reset the transformation
glLoadIdentity();
// draw stuff
glCallList( list_name );
// Restore the last matrix state
glPopMatrix();

I am puzzled why we call glLoadIdentity for glCallList rather than for glNewList. I thought that we should have identity model view matrix during creating a list. Later, we can call the list for whatever the current model view matrix is. For example, we create a list for draw a basketball under an identity model view. And later, we can call the list and the ball will show up according to how we rotate and translate the model view. Any further help is much, much appreciated.

JD

If you already set the matrix in the display list, in that case it is probably not the problem.
As you said you can set the matrix transformation once and for all when creating the display list but that does not prevent from being affected by transformation set outside if you do not take some precautions.