PDA

View Full Version : Why display list doesn't work properly?



Asura
04-07-2006, 04:14 AM
Hi all:
I am trying to use display list to store a set of commands to execute later, but it doesn't work. The code is like the following:

int LIST_BASE;
int LIST_INDEX;

LIST_BASE = glGenLists(4);
LIST_LENGTH = 0;

glNewList(LIST_BASE+LIST_LENGTH, GL_COMPILE);
glBegin(GL_QUADS);
for (int i = 0; i < length; i++){
glVertex3f(...);
glVertex3f(...);
...
}
glEnd();
glEndList();
LIST_LENGTH++;Then in another procedure I call the display list like this:


for (int i = 0; i < LIST_LENGTH; i++){
glCallList(LIST_BASE+i);
}The LIST_BASE = glGenLists(4); always give the LIST_BASE a value 0. Why is this?
Could anybody help me please!!
Thanks very much!!!!

jide
04-07-2006, 04:48 AM
glGenLists returns 0 when it cannot generate the lists (for example if there are too much lists to generate). Did you try to generate a single list ? What does it return ?

Where do you call that part of code ?

RigidBody
04-07-2006, 04:59 AM
did you create a gl context and make it current before calling GenLists ?

Asura
04-07-2006, 10:14 AM
yeah, I found the problem, I called the function before the GL context. Thanks