PDA

View Full Version : display list



Vlasko
05-12-2003, 10:59 AM
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]=='\n'));
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]=='/') &#0124; &#0124; (temp[0]=='\n'));
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);

mako
05-12-2003, 11:23 AM
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.

mako
05-12-2003, 11:29 AM
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.

mako
05-12-2003, 11:31 AM
"By the way, the line ... makes no sense" sorry for my bad English.

chowe6685
05-12-2003, 04:17 PM
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

Vlasko
05-13-2003, 06:29 AM
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

Vlasko
05-13-2003, 06:33 AM
Found it now working.I've expanded my function and forgot to move line list3=list2+1 before glNewList()Thanks all