Results 1 to 2 of 2

Thread: display lists and modelling transformation

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2005
    Posts
    1

    display lists and modelling transformation

    According to the OpenGL Programming Guide V1.4 display lists should be able to handle modelling transformations and such. However I experience something very different, but probably there is just a stupid bug in my code.

    I want to draw graphs, that is a heap of dots and lines, or to let it appear more nicely a heap of spheres and cylinders. So I have a variable number of spheres representing my vertices (of my graph not of an OpenGL thing) and cylinders for edges. For both sphere and cylinder I have a display list and then I simply do all the transformations so the spheres and cylinders appear in all the right places. So far so good.

    However if I put all this, obviously together with the modelling transformations, into another display list, things get messed up. All I see is a single sphere (or probably more correct: n spheres all exactly on top of each other, and no cylinder as it is inside the sphere). Basically what I see is the same as if there would have been no modelling transformations.
    Why is that?

    Here's my code:
    function draw_cubes() {
    GLint cubelist;
    cubelist=glGenLists(1);

    glNewList(cubelist,GL_COMPILE);
    cube->opengl_draw_solid(); //draws one cube
    glEndList();
    delete cube;

    for (pre_opengl_object<pre_opengl_vertex>* vertex=v.first(); vertex!=0; vertex=vertex->next) {
    glPushMatrix();
    glTranslated(vertex->item->x(),vertex->item->y(),vertex->item->z());
    glCallList(cubelist);
    glPopMatrix();
    }
    glDeleteLists(cubelist,1);
    }

    somesub() {
    glNewList(x,GL_COMPILE)
    draw_cubes();
    glEndList();
    }

    someothersub() {
    draw_cubes(); //works
    glCallList(x); //doesn't work

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: display lists and modelling transformation

    Multiple problems:
    1.) It's not allowed to call glNewList while you are in display list compile mode. If you added a glGetError after the glEndLists you would have noticed.
    2.) If you did it correctly, the hierarchical glCallList inside draw_cubes would be included in the root display lists. You cannot expect that to draw soemthing if you call glDeleteLists for the inner display list. glGenLists and glDeleteLists are immediately executed and not compiled into a display list!
    3.) Generating a display list for single usage is a complete waste of time.

Similar Threads

  1. Display lists
    By KeSh in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-26-2004, 03:01 AM
  2. Problem with display and transformation 3D -> 2D
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-04-2003, 02:05 AM
  3. Display Lists
    By virtualchetan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-18-2003, 11:04 AM
  4. display lists inside display lists...
    By architekt in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-22-2002, 08:55 PM
  5. display lists
    By lee in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-15-2001, 04:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean