views:

24

answers:

1

I am using JOGL with OpenGL. I'm drawing everything through display lists. I'm trying to figure out how to specify materials.

I've been looking at this documentation. The following looks pretty straightforward:

glPushMatrix();
    glTranslatef (-1.25, 3.0, 0.0);
    glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);
    glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
    auxSolidSphere();
glPopMatrix();

How can I do this with display lists? Without them, my app is way too slow.

A: 

First, you should realize that, depending on your hardware, there's no guarantee that using a display list will make even a slight difference in speed. The currently-favored solution would be to use a vertex buffer object instead.

As far as doing it with a display list goes, it's pretty straightforward. You basically just do your drawing to the display list, then when you want to display something you tell it to play the display list with glCallList. There are some operations you can't put into a display list, but at least if memory serves (though it may not -- I haven't used lists in a while now) you can put glMaterialfv into a display list just fine.

Jerry Coffin