PDA

View Full Version : Display-lists (getting slightly mad :-)



Schleppi
05-20-2001, 01:05 PM
Hi,
i really would be happy, if someone could tell me, what i'm making wrong.
Everytime i want to work with lists, my screen stays blank, so i reduced my problem for a single triangle i can rotate. It works fine, when i have the code:

glBegin(GL_TRIANGLES);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mat_spe cular);
glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,mat_sh ininess);
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,mat_ambi ent);
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,mat_diff use);
glColor3f(1.0,1.0,0.0);
glVertex3f(-5000, -2887, 0);
glVertex3f(5000, -2887, 0);
glVertex3f(0, 5800, 0);
glEnd();

in my display-function.

But when i try to create a list for this object in my init-function like:

LIST_NR_LAND=glGenLists(1);

glNewList(LIST_NR_LAND,GL_COMPILE);
glBegin(GL_TRIANGLES);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mat_spe cular);
glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,mat_sh ininess);
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,mat_ambi ent);
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,mat_diff use);
glColor3f(1.0,1.0,0.0);
glVertex3f(-5000, -2887, 0);
glVertex3f(5000, -2887, 0);
glVertex3f(0, 5800, 0);
glEnd();
glEndList();

and change the code in my display-function to:

glCallList(LIST_NR_LAND);

nothing happens, i just get a blank-screen.

(LIST_NR_LAND is a global GLuint variable)

If anyone has a clue, why this could happen, please respond. I really changed nothing else in my code and it works fine, when i don't use a display-list. (But i want to display a fractal-landscape, when i'm finished, so i really need a list)

Bye,
Stefan

05-20-2001, 02:48 PM
do you create the list after creating the context. That is do you init glut or do whatever it is you need to do before creating the list?

Try this see if the number really is a list

glIsList(THE_VARIABLE_THAT_IS_A_LIST)

check to see if it really is a display list

zed
05-20-2001, 04:36 PM
youre only allowed to put certain opengl things between begin()..end() statements. i could be wrong but i believe glMaterial is not one of the things allowed. check the red book for further info

Schleppi
05-21-2001, 01:29 AM
Thanks, i've found my mistake now, i was creating the list befor i initialized all the GlutInit... lines.
Just moving the list-generating-code some lines below solved the problem.

Thanks,
Stefan