Global alpha & display list ?

Hi,

I have a display list that includes glColor3 calls. I want to be able to fade in and fade out what the display list draws. Am I hosed? Calling glColor4 before the display list draws doesn’t work. BTW the display list has no texturng or lighting - it’s a starfield using points.

Any hints appreciated!

Tom

From the spec, the color3x calls set implicitely alpha to 1.0, so you need something else for your fade.
A simple fullscreen black quad drawn on top of the scene with blending should be enough : just slide the black quad color from from rgba 0,0,0,0 to 0,0,0,1.

Sample program for blending

Hope it helped.

Thanks, but I only want the starfield to fade - there are other objects in the scene so the black quad trick is no good.

Anyone else got any ideas?

??? simply draw your non-faded objects after the quad… (and disable depth writes for the quad)

One thought - maybe you could use stencil buffer to indicate which pixels should be darkened. I haven’t worked with it for a long time but it should look like this:
0) draw whatever goes before the starfield

  1. clear stencil buffer
  2. draw starfield writing to stencil buffer
  3. draw quad with stencil test on(and depth write off)
  4. draw whatever goes after the starfield with stencil test off

I hope this might solve the problem…

Enable lighting, set diffuse/specular/ambient to black. Set emissive to the colour + alpha you desire. Bob’s yer uncle. The glColor’s in your display list will be ignored because lighting’s on, and any enabled lights will have no effect because your material reflectance values are set to zero. You’ll just get the emissive showing through.

You could use a vertex program.

Also, depending on what sorts of interpolation issues you might have, you could use a texture and texture coordinates instead of colors, then you could use one color call before the display list to set alpha.