
A question about glNewList and speeding up the program...
Hy Guys (and girls, if there any)
!
i'm not very well with english, so i stucked with the help again, i'am not sure with something..
if i make a display list
and use a loop in it
and use "hard" calculations
will it be counted in rendering time?????
or will the full calculations, and for loops counted under translating the program?
or when exactly?
I explain it with a litle example, with only witing the inportant lines:
void GenObjects(void);
{
glNewList(box,GL_COMPILE);
for (a=0;a<152;a++)
{
glBegin(GL_QUADS);
glVertex3f( (1/256)*(0.012*a) , y , z );
glVertex3f(...
glVerte....
glV....
glEnd();
}
glEndList();
}
So... With drwaing one box, i dont care how long does it take to count the x coord under rendering, but if i want thousands of that, the (1/256)*(0.012*a) should be counted before rendering.
[ Is it faster if i store the values in an array like this?
glVertex3f( xc1[ a ] , y , z );
]
If you know anything about this, please let me know, thank you:
Robi-----
[edited by - Robesz on November 26, 2003 4:40:23 AM]

Robesz
If you have a function call like:
in a display list then openGL will only calculate (1/256)*(0.012*a) when the display list is compiled. During the display list compilation openGL stores the values passed by openGL commands. OpenGL may be able to combine commands to further speed up rendering, i.e. the display list:
may be converted to the equivalent of:
Note also that because OpenGL stores the values passed to openGL commands and not the expressions, this code:
will produce two vertices at (1, 1, 1), not one at (1, 1, 1) and one at (2, 2, 2);
Enigma
EDIT: forgot that source requires square brackets, not angle brackets!
[edited by - Enigma on November 26, 2003 6:53:57 AM]
glVertex3f( (1/256)*(0.012*a) , y , z );
in a display list then openGL will only calculate (1/256)*(0.012*a) when the display list is compiled. During the display list compilation openGL stores the values passed by openGL commands. OpenGL may be able to combine commands to further speed up rendering, i.e. the display list:
glNewList(list, GL_COMPILE);glTranslatef(1, 1, 1);glBegin(GL_POINTS);glVertex3f(2, 3, 4);glEnd();glEndList();
may be converted to the equivalent of:
glBegin(GL_POINTS);glVertex3f(3, 4, 5);glEnd();
Note also that because OpenGL stores the values passed to openGL commands and not the expressions, this code:
GLuint list;GLint* posPointer;GLuint posvoid buildList(){glNewList(list, GL_COMPILE);glBegin(GL_POINTS);glVertex3f(*posPointer, *posPointer, *posPointer);glEnd();glEndList();}void render(){pos = 1;glCallList(list);pos = 2;glCallList(list);}int main(int, char**){setupOpenGL();posPointer = &pospos = 1;buildList();render();}
will produce two vertices at (1, 1, 1), not one at (1, 1, 1) and one at (2, 2, 2);
Enigma
EDIT: forgot that source requires square brackets, not angle brackets!
[edited by - Enigma on November 26, 2003 6:53:57 AM]
Once the values are computed in the display list, they are not computed again everytime. Instead, the values are stored and then re-used.
This is very efficient, but the problem is that you have to rebuild the whole list if you want to change a single coordinate of a vertex in the list, or if you want to add or remove vertices for instance.
But granted that your list is fixed and never change in the lifetime of your application, then display lists is the way to go.
This is very efficient, but the problem is that you have to rebuild the whole list if you want to change a single coordinate of a vertex in the list, or if you want to add or remove vertices for instance.
But granted that your list is fixed and never change in the lifetime of your application, then display lists is the way to go.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement