c++openglobsoletedisplaylist

Does OpenGL display list bake glVertex data?


I've been using OpenGL in simple immediate mode for a while, and am trying to pass on to retained mode with display lists (which I sadly learned has been deprecated a while). What I would like to know, is when I type:

glNewList(list, GL_COMPILE);
glBegin(GL_TRIANGLE_FAN);
    glVertex2f(0.0f, 0.0f);
    for (int i = 0; i < 10; i++)
    {
        glVertex2f(radius * cos(i * 2.0f * PI / 9.0f), radius * sin(i * 2.0f * PI / 9.0f));
    }
glEnd();
glEndList();

does OpenGL precalculate all the 10 vertices in for loop and send them to graphics card baked, like:

glVertex2f(0.5f, 0.0f);
glVertex2f(0.499f, 0.0055f);
//so and so forth 10 times...

or does it try to do the for loop (and many sin / cos operations) all over for each frame? In other words, is it reasonable to store such a round shape in display lists (and do the rest with glTranslatef, glRotatef, etc...) to avoid trigonometric operations in each frame update, or is there no performance gain at all?

Edit: To avoid a confusion, I intend to create this display list once using the for loop, and then call it by glCallList(list) in each frame update (i.e. glutDisplayFunc()). I do not create a list for each and every frame.


Solution

  • Only the GL command sequence and parameters are "baked" into the display list. Otherwise OpenGL would have to use some sort of terrifying longjmp() monstrosity to re-execute (along with the complete process state at that point!) the code between glNewList()/glEndList().