Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Display List, If statement

  1. #1
    Junior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Display List, If statement

    Hello,
    I've got a simple question regarging display lists.
    If my code would look like this:
    Code :
    // Some where global
    bool expression;
    [..]
    GLuint dlUID = glGenlists(1);
    expression = true;
    glNewList(dlUID, GL_COMPILE);
    if(expression)
    {
    glRotate(angle, 1.0, 0.0, 0.0);
    }
    else
    {
    glRotatef(angle, 0.0, 1.0, 0.0);
    }
    glEndList();
    expression = false;
    Would that always result in(like with compilers with #if statements they cut out the false statements):
    Code :
    glRotate(angle, 1.0, 0.0, 0.0);
    regardles of what expression is after compilation of the list?
    And what about modes, when some function needs something enabled(lets say lights), they are when the list is compiled, but would they still need to be enabled when the list is executed?
    Thanx in advance,
    Hylke

  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Santa Clara, CA
    Posts
    193

    Re: Display List, If statement

    The "if" is not compiled into the display list, so all that matters is the value of the expression at the time the list is compiled.

    Display lists capture (most) OpenGL commands, not program logic. You can think of a display list as a record-and-playback mechanism, although in practice the implementation may be more elaborate (e.g. geometry in display lists may be optimized).

  3. #3
    Junior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: Display List, If statement

    Ok thanx.
    I have one last question.
    If i've made a displaylist, and call that displaylist in a new displaylist(so the first one gets nested in the second one), then would the commands, from the first list, also be cached in the second list?Or is it *just* executing the other list?
    And is there much difference between calling x lists with glCallList and having those x lists in one nested list?
    Hylke

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Display List, If statement

    When nesting display lists, the call to glCallList itself is saved.

    Say you have a display list A which contains a call to display list B. If display list B is changed, then so is A, as A reference B.

  5. #5
    Junior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: Display List, If statement

    Ok, thanx.
    Hylke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •