display list

I have a problem with display list everything is loaded correctly but it is not shown
code:
file=fopen(“level.bin”,“rt”);
glNewList(list3,GL_COMPILE);
do
{
do
{
fgets(maxtemp,2,file);
}while((maxtemp[0]==’/’) | | (maxtemp[0]==’
‘));
sscanf(maxtemp,"%d",&maxvertices);
list3=list2+1;
float vertextable[255][5];
for(i=0;i<maxvertices;i++)
{
do
{
fgets(temp,255,file);
}while((temp[0]==’/’) | | (temp[0]==’
'));
sscanf(temp,"%f %f %f %f %f",&vertextable[i][0],&vertextable[i][1],&vertextable[i][2],&vertextable[i][3],&vertextable[i][4]);
}
if((maxvertices%2)==0)
glBegin(GL_QUADS);
else
glBegin(GL_TRIANGLES);
for(i=0;i<maxvertices;i++)
{
glTexCoord2f(vertextable[i][0],vertextable[i][1]);
glVertex3f(vertextable[i][2],vertextable[i][3],vertextable[i][4]);
}
glEnd();
}while(!feof(file));
glEndList();
fclose(file);

You have created your display list, but it will not be executed. You must either create your new display list with GL_COMPILE_AND_EXECUTE instead of GL_COMPILE, or you must call your display list with glCallList(list3) after you have completed the creation of the list.

By the why, what the line list3 = list2 + 1 makes no sense. You mustn’t change the id of your display list. First, you create an id like list3 = glGenLists(1); Next, you create the new list with glNewList(list3, GL_COMPILE_AND_EXECUTE). The display list id list3 mustn’t be changed, or you will not be able to use your display list.

“By the way, the line … makes no sense” sorry for my bad English.

I recommend you avoid GL_COMPILE_AND_EXECUTE, and just compile the list, then execute it w/ glCallList. If I remember correctly GL_COMPILE_AND_EXECUTE is very broken in many cases

It’s because this is only a part of function that creates 3 display lists-but first 2 are show when i call them. I use the glCallList() function elsewhere in program

Found it now working.I’ve expanded my function and forgot to move line list3=list2+1 before glNewList()Thanks all