How to copy one displyList to another displayList?

glNewList(i,GL_COMPILE);
…do something
glEndList();

int j=glGenList();

copylist(i,j);//how to make this to copy i to j

glDeleteList(i);//must delete list i

glCallList(j);

You can’t. That would be useless functionality.

Display lists are immutable. So your copy would just do the exact same thing as the original display list. Copying it and destroying the old version is pure overhead with no conceivable benefit.

//how to make this to copy i to j
void copylist(GLuint i, GLuint j)
{
glNewList(j, GL_COMPILE);
glCallList(i);
glEndList();
}

Originally posted by chemdog:
//how to make this to copy i to j
void copylist(GLuint i, GLuint j)
{
glNewList(j, GL_COMPILE);
glCallList(i);
glEndList();
}

That won’t create a copy of i called j, it will create a display list called j which contains the display list i. The important difference is what happens when i is deleted; j will no longer work because i is gone.

[This message has been edited by Bob (edited 02-16-2004).]