Results 1 to 3 of 3

Thread: Silly question: generating display lists.

  1. #1

    Silly question: generating display lists.

    I've been writing a Videoscape file reader to play around with. I've managed to get it to read the information into custom arrays(with vertex information in Vertex objects of float xyz coords, and faces(planes) of the object in objects containing how many vertices in the face, and an array of 3-4 Vertex objects).
    However, when I go to build the display list, the resulting object comes out wonky. A pyramid has two points, a cube has some faces drawn correctly but others with holes, etc.
    I suspect that I'm overlooking something simple when writing the glVertexes. Here's the section that builds the list; nplanes is the number of faces, and planes is the array of face objects:

    mesh = glGenLists(1);
    printf("Now building display list.\n");
    glNewList(mesh, GL_COMPILE);
    /* The nplanes loop */
    for(i = 0; i <= (nplanes-1); i++){
    if(planes[i].numVerts == 3){
    count = 2;
    glBegin(GL_TRIANGLES);
    }
    else if(planes[i].numVerts == 4){
    count = 3;
    glBegin(GL_QUADS);
    }
    else{
    /* shouldn't happen */
    count = 4;
    glBegin(GL_POLYGON);
    }
    /* generic coloring for now */
    glColor3f(1.0f, 1.0f, 0.0f);
    /* Individual plane loop */
    for(j = 0; j <= count; j++){
    glVertex3f(planes[i].vertexes[j].x,planes[i].vertexes[j].y, planes[i].vertexes[j].z);
    }
    glEnd();

    }
    glEndList();
    return mesh;

  2. #2
    Member Contributor
    Join Date
    Feb 2000
    Location
    Breda, Netherlands
    Posts
    57

    Re: Silly question: generating display lists.

    Hi!

    I can only guess what goes wrong here:
    where's the information that connects the right points in a face?
    Yesterday I just tried to read some ascii object file generated my moonlight, (.off file) and it generated the amount of vertices, faces and what vertices are in one face (allways 4: quads).

    I guess that's why you have holes in you object.

    And just as a coding tip:
    try to use only '<' in your for loops, and the numbers make a whole lot more sence. for a triangle you get:
    for (i=0; i<3; i++)
    once reading this line and you see it coverts 3 points (0..2). much simpler.
    well, that's my opinion, and i'm sure others as well.
    And you van use planes[i].numVerts in your 'j' loop like this:
    for(j = 0; j < planes[i].numVerts; j++)

    no need for the count variable anymore too..


    happy coding,
    John

  3. #3

    Re: Silly question: generating display lists.

    Yeah, I'm surprised I didn't notice the <= statements; too many long hours coding for a filesystem. Doh..

    The face information is what's in the planes array; each plane/face has three or four vertexes that were assigned earlier, and how many verts are in itself. In Videoscape, you can have either 3 or 4 vertexes for a face:
    4 0 3 2 1 0x(color)
    This line says "four verts total, the first one is the 0th vertex in the vertex list, the next is the 3rd vertex in the vertex list, the next is the 2nd vertex in the vertex list, the next is the 1st vertex in the vertex list".

    I guess the logic flow is like:

    for(each face(counted by i)
    if numVerts = 3
    {
    glBegin(GL_TRIANGLES)
    else if numVerts = 4
    glBegin(GL_QUADS)
    for(each vertex(counted by j) in the current plane)
    {
    assign it a glVertex.
    }
    glEnd;
    }

    I tried looking at a flat regular plane with the reader; three of the points come out normal. However, the fourth one wasn't there--it looked like someone had snipped off a third of the square.

    Sorry for being somewhat obtuse, I'm trying to get a handle on 3d coordinates.

Similar Threads

  1. Noobie question on display lists
    By thealmightyone in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-24-2009, 02:45 AM
  2. DIsplay Lists Question
    By ToddAtWSU in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 02-09-2007, 10:31 AM
  3. Question about display lists
    By Alessandro_dup1 in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 08-01-2006, 08:57 AM
  4. Question about display lists and performance
    By 147-2 in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 02-22-2004, 10:11 PM
  5. very silly question but.....
    By uglyduck in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-01-2000, 10:14 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