Sign in to follow this  

Display List is really(!) slow

This topic is 2797 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 everyone, I know I must be doing something very wrong. I had been working in immediate mode until someone told me that I was using the slowest possible method. I've since switched to display lists, but they seem to be even slow than immediate mode. My guess is that I'm doing something wrong. Here's my code which generates the list:
    glNewList(index, GL_COMPILE);
    for (std::vector<FaceGroup*>::iterator i = face_group_0.begin(); i != face_group_0.end(); ++i) {
        glPushMatrix();
        glEnable( GL_TEXTURE_2D );
        glBindTexture(GL_TEXTURE_2D, texture_manager->texture[0].texture);
        glBegin(GL_QUADS);
            glColor4ub(255, 255, 255, 128);
            // Push sides
            glTexCoord2i( 0, 0 );
            glVertex3f((*i)->x_origin + 1.f, (*i)->y_origin + (*i)->height, (*i)->z_origin + (*i)->width);
            glTexCoord2i( (*i)->width, 0 );
            glVertex3f((*i)->x_origin + 1.f, (*i)->y_origin + (*i)->height, (*i)->z_origin);
            glTexCoord2i( (*i)->width, (*i)->height );
            glVertex3f((*i)->x_origin + 1.f, (*i)->y_origin, (*i)->z_origin);         
            glTexCoord2i( 0, (*i)->height );   
            glVertex3f((*i)->x_origin + 1.f, (*i)->y_origin, (*i)->z_origin + (*i)->width); 
        glEnd();
        glDisable(GL_TEXTURE_2D);
        glPopMatrix();
    }
    glEndList();
And I call the list in a draw function:
void FaceGroupManager::Draw()
{
    glCallList(index);
}

Any ideas on what I might be doing wrong? Thank you for the help.

Share this post


Link to post
Share on other sites
Why are you enabling and disabling texturing, and pushing and popping the matrix, for every single polygon? Dear god that must be slow.

Share this post


Link to post
Share on other sites
Remove the glEnable(GL_TEXTURE)/glDisable(GL_TEXTURE) calls. This positively destroys performance.

Avoid using many small textures (one texture per quad, oh dear). Splat them all into a texture atlas and change texture coordinates, this will improve performance by two orders of magnitude.

Display lists aren't helping because you are state-change limited. You are changing state so often that the CPU is bogged down trying to track it all.

Don't use integer texture coordinates, use floats. They are faster.

Don't allow your texture coordinates to go outside [0.0, 1.0] if you can. Older cards may have trouble with that and GL_REPEAT, to the point where they fall back to software rendering (my old Geforce 2 did that when going outside 16.0 or so).

Share this post


Link to post
Share on other sites
Quote:
Original post by Fiddler
Avoid using many small textures (one texture per quad, oh dear). Splat them all into a texture atlas and change texture coordinates, this will improve performance by two orders of magnitude.

Definitely an advice in general. In this particular case, though, his call to glBindTexture is not loop dependent, so he's "only" binding the same texture over and over again (not that it makes it any better, just easier to solve by doing it once). Everything but glColor4ub, glTexCoord2i and glVertex3f can be put outside the loop.

Share this post


Link to post
Share on other sites

This topic is 2797 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