display lists and color

I was under the impression that glColor calls made during display list creation were stored as part of the display list. The documentation I checked had a list of GL commands which were NOT stored in the display list and the color commands were not in that list.

However, I’m seeing some strange behavior. The pseudo code is below.


glColor(red);

if (display list not yet created)
{
  create new display list and begin recording
  glColor(black);
  use glBegin/glEnd sequences to render geometry
  end recording
}

call display list

What I’m seeing is that the first time I render, the geometry shows up in black. Any subsequent rendering pass renders in red.

Its almost as though the color command is not getting stored in the display list. If it was I would expect to always see the geometry rendered in black not just the first time.

Is there some other flag that might control whether or not color is stored in the display list?

glColor*() certainly can be stored in a display list. You probably have some other problem. Instead of pseudo-code, better post some real code (but not too comprehensive).

Maybe you are not properly setting the alpha component. Without seeing code its hard to tell.

Thanks for the replies. I found the problem. It was caused by lighting.

With lighting turned on, GL uses the material properties. With lighting turned off it uses the glColor value.

What I didn’t realize was that the method I was calling to create the display list was turning lighting OFF, then creating the display list with the glColor(black).

On the first render, I would create the display list and then immediately call it. On this first pass it was getting called with lighting turned off which meant it was using the glColor(black) contained in the display list.

On subsequent renders, I was only calling the display list and lighting was turned on so it was correctly rendering with the material properties I had set.