Sign in to follow this  

Display List not working

This topic is 3321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I "modeled" a small city and stored it in a display list. I created displays lists for a building, road, all buildings, all roads and finally the city. It's not working now. It's drawing only the ground, one building and one road. I've looked at the code so many times and still can't figure out the problem. I wonder if some of you could spot something here. The city display list is defined as follows:
glNewList( CITY, GL_COMPILE );

         glCallList( ALLBUILDINGS );
         glCallList( ALLROADS );

         // grass texture
         glBindTexture( GL_TEXTURE_2D, texturesID[0]);

         glPushMatrix();

             glScalef( 5.0, 1.0, 5.0 );

             // ground
             glBegin( GL_QUADS );
                 glNormal3f( 0.0, 1.0, 0.0 );
                 glTexCoord2f(  0.0,  0.0 ); glVertex3f( -100.0, 0.0, 100.0 );
                 glTexCoord2f( 50.0,  0.0 ); glVertex3f(  100.0, 0.0, 100.0 );
                 glTexCoord2f( 50.0, 50.0 ); glVertex3f(  100.0, 0.0,-100.0 );
                 glTexCoord2f(  0.0, 50.0 ); glVertex3f( -100.0, 0.0,-100.0 );
             glEnd();

         glPopMatrix();

    glEndList();

I realized that the one building and road that are being rendered happened to be the first building and first road defined in ALLBUILDINGS and ALLROADS display lists. I checked the display lists ids. They're all valid and they're being called, but for some reason after the drawing the first building it doesn't execute the rest of it. The whole code which define the display list follows:
    BUILDING = glGenLists(1);
    ROADV = glGenLists(1);
    ROADH = glGenLists(1);
    ALLROADS = glGenLists(1);
    ALLBUILDINGS = glGenLists(1);
    CITY = glGenLists(1);

    glNewList( BUILDING, GL_COMPILE );

        glBegin( GL_QUADS );

            //Face Frontal
            glNormal3f( 0.0 , 0.0 , 1.0 );
            glTexCoord2f( 1.0, 0.0 ); glVertex3f( 10.0,  10.0,   0.0 );
            glTexCoord2f( 0.0, 0.0 ); glVertex3f(  0.0,  10.0,   0.0 );
            glTexCoord2f( 0.0, 1.0 ); glVertex3f(  0.0,   0.0,   0.0 );
            glTexCoord2f( 1.0, 1.0 ); glVertex3f( 10.0,   0.0,   0.0 );

            //Face Direita
            glNormal3f( 1.0 , 0.0 , 0.0 );
            glTexCoord2f( 1.0, 0.0 ); glVertex3f( 10.0,  10.0, -10.0 );
            glTexCoord2f( 0.0, 0.0 ); glVertex3f( 10.0,  10.0,   0.0 );
            glTexCoord2f( 0.0, 1.0 ); glVertex3f( 10.0,   0.0,   0.0 );
            glTexCoord2f( 1.0, 1.0 ); glVertex3f( 10.0,   0.0, -10.0 );

            //Face Traseira
            glNormal3f( 0.0 , 0.0 , -1.0 );
            glTexCoord2f( 1.0, 0.0 ); glVertex3f(  0.0,  10.0, -10.0 );
            glTexCoord2f( 0.0, 0.0 ); glVertex3f( 10.0,  10.0, -10.0 );
            glTexCoord2f( 0.0, 1.0 ); glVertex3f( 10.0,   0.0, -10.0 );
            glTexCoord2f( 1.0, 1.0 ); glVertex3f(  0.0,   0.0, -10.0 );

            //Face Esquerda
            glNormal3f( -1.0 , 0.0 , 0.0 );
            glTexCoord2f( 1.0, 0.0 ); glVertex3f(  0.0,  10.0,   0.0 );
            glTexCoord2f( 0.0, 0.0 ); glVertex3f(  0.0,  10.0, -10.0 );
            glTexCoord2f( 0.0, 1.0 ); glVertex3f(  0.0,   0.0, -10.0 );
            glTexCoord2f( 1.0, 1.0 ); glVertex3f(  0.0,   0.0,   0.0 );

            //Face de Cima
            glNormal3f( 0.0 , 1.0 , 0.0 );
            glTexCoord2f( 1.0, 0.0 ); glVertex3f( 10.0,  10.0, -10.0 );
            glTexCoord2f( 0.0, 0.0 ); glVertex3f(  0.0,  10.0, -10.0 );
            glTexCoord2f( 0.0, 1.0 ); glVertex3f(  0.0,  10.0,   0.0 );
            glTexCoord2f( 1.0, 1.0 ); glVertex3f( 10.0,  10.0,   0.0 );

       glEnd();
    glEndList();

    glNewList( ROADV, GL_COMPILE );

         glBegin( GL_QUADS );
             glNormal3f( 0.0, 1.0, 0.0 );
             glTexCoord2f( 1.0, 10.0 ); glVertex3f( 10.0, 0.3, -10.0 );
             glTexCoord2f( 0.0, 10.0 ); glVertex3f(  0.0, 0.3, -10.0 );
             glTexCoord2f( 0.0,  0.0 ); glVertex3f(  0.0, 0.3,   0.0 );
             glTexCoord2f( 1.0,  0.0 ); glVertex3f( 10.0, 0.3,   0.0 );
         glEnd();

    glEndList();

    glNewList( ROADH, GL_COMPILE );

         glBegin( GL_QUADS );
             glNormal3f( 0.0, 1.0, 0.0 );
             glTexCoord2f(  0.0, 10.0 ); glVertex3f( 10.0, 0.2, -10.0 );
             glTexCoord2f(  0.0,  0.0 ); glVertex3f(  0.0, 0.2, -10.0 );
             glTexCoord2f(  1.0,  0.0 ); glVertex3f(  0.0, 0.2,   0.0 );
             glTexCoord2f(  1.0, 10.0 ); glVertex3f( 10.0, 0.2,   0.0 );
         glEnd();

    glEndList();

    glNewList( ALLROADS, GL_COMPILE );

         // road texture
         glBindTexture( GL_TEXTURE_2D, texturesID[1]);
         glPushMatrix();

             glTranslatef( -500.0 , 0.0 , 500.0 );
             glScalef( 10.0, 1.0, 100.0 );
             glCallList( ROADV );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( 0.0 , 0.0 , 500.0 );
             glScalef( 10.0, 1.0, 100.0 );
             glCallList( ROADV );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( 400.0 , 0.0 , 500.0 );
             glScalef( 10.0, 1.0, 100.0 );
             glCallList( ROADV );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( -200.0 , 0.0 , 0.0 );
             glScalef( 10.0, 1.0, 40.0 );
             glCallList( ROADV );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( 0.0 , 0.0 , 400.0 );
             glScalef( 10.0, 1.0, 30.0 );
             glCallList( ROADV );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( 200.0 , 0.0 , 0.0 );
             glScalef( 10.0, 1.0, 20.0 );
             glCallList( ROADV );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( -500.0 , 0.0 , 500.0 );
             glScalef( 100.0, 1.0, 10.0 );
             glCallList( ROADH );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( -500.0 , 0.0 , 100.0 );
             glScalef( 100.0, 1.0, 10.0 );
             glCallList( ROADH );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( -500.0 , 0.0 , -400.0 );
             glScalef( 10.0, 1.0, 20.0 );
             glCallList( ROADH );

         glPopMatrix();

         glPushMatrix();

             glTranslatef( -400.0 , 0.0 , -400.0 );
             glScalef( 100.0, 1.0, 10.0 );
             glCallList( ROADH );

         glPopMatrix();
    glEndList();

    glNewList( ALLBUILDINGS, GL_COMPILE );


         // crab building texture
         glBindTexture( GL_TEXTURE_2D, texturesID[4] );

         glPushMatrix();

            glTranslatef( 250.0, 0.0, -250.0);
            glScalef( 10.0, 30.0, 10.0 );
            glCallList( BUILDING );

         glPopMatrix();

         // blue building texture
         glBindTexture( GL_TEXTURE_2D, texturesID[3] );
         glPushMatrix();

            glTranslatef( -400.0, 0.0, -100.0);
            glScalef( 10.0, 15.0, 20.0 );
            glCallList( BUILDING );

         glPopMatrix();

         glPushMatrix();

            glTranslatef( -300.0, 0.0, 0.0);
            glScalef( 10.0, 10.0, 20.0 );
            glCallList( BUILDING );

         glPopMatrix();

         glPushMatrix();

            glTranslatef( -100.0, 0.0, 0.0);
            glScalef( 10.0, 15.0, 30.0 );
            glCallList( BUILDING );

         glPopMatrix();

         glPushMatrix();

            glTranslatef( 100.0, 0.0, 0.0);
            glScalef( 10.0, 15.0, 30.0 );
            glCallList( BUILDING );

         glPopMatrix();

         // hotel texture
         glBindTexture( GL_TEXTURE_2D, texturesID[2] );
         glPushMatrix();

            glTranslatef( -400.0, 0.0, 200.0);
            glScalef( 20.0, 10.0, 10.0 );
            glCallList( BUILDING );

         glPopMatrix();

         glPushMatrix();

            glTranslatef( -100.0, 0.0, 200.0);
            glScalef( 10.0, 10.0, 10.0 );
            glCallList( BUILDING );

         glPopMatrix();

         glPushMatrix();

            glTranslatef( -400.0, 0.0, 400.0);
            glScalef( 10.0, 10.0, 10.0 );
            glCallList( BUILDING );

         glPopMatrix();

         glPushMatrix();

            glTranslatef( -200.0, 0.0, 400.0);
            glScalef( 20.0, 10.0, 10.0 );
            glCallList( BUILDING );

         glPopMatrix();

    glEndList();

    glNewList( CITY, GL_COMPILE );

         glCallList( ALLBUILDINGS );
         glCallList( ALLROADS );

         // grass texture
         glBindTexture( GL_TEXTURE_2D, texturesID[0]);

         glPushMatrix();

             glScalef( 5.0, 1.0, 5.0 );

             glBegin( GL_QUADS );
                 glNormal3f( 0.0, 1.0, 0.0 );
                 glTexCoord2f(  0.0,  0.0 ); glVertex3f( -100.0, 0.0, 100.0 );
                 glTexCoord2f( 50.0,  0.0 ); glVertex3f(  100.0, 0.0, 100.0 );
                 glTexCoord2f( 50.0, 50.0 ); glVertex3f(  100.0, 0.0,-100.0 );
                 glTexCoord2f(  0.0, 50.0 ); glVertex3f( -100.0, 0.0,-100.0 );
             glEnd();

         glPopMatrix();

    glEndList();

Any idea? Thanks in advance.

Share this post


Link to post
Share on other sites
Thanks ProPuke. That will be really useful. The only problem is that glIntercept has only a windows version, but I'll see how I can overcome that.

I think it might be a hardware problem or maybe a bug in SDL/OpenGL... If I'm not mistaken, I ran the very same code in a different machine a while ago and it worked.

As soon as I find that out I'll post here.

Share this post


Link to post
Share on other sites
Quote:
Original post by felipedrl
Thanks ProPuke. That will be really useful. The only problem is that glIntercept has only a windows version, but I'll see how I can overcome that.

I think it might be a hardware problem or maybe a bug in SDL/OpenGL... If I'm not mistaken, I ran the very same code in a different machine a while ago and it worked.

As soon as I find that out I'll post here.


glsldevil might be of intrest runs fine in linux (maded for glsl but debugs standard opengl too

Share this post


Link to post
Share on other sites

This topic is 3321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this