PDA

View Full Version : Global alpha & display list ?



meanfox
01-03-2005, 01:43 AM
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

ZbuffeR
01-03-2005, 04:41 AM
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 (http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_PG/sgi_html/ch07.html#id19353)

Hope it helped.

meanfox
01-03-2005, 12:50 PM
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?

ZbuffeR
01-03-2005, 02:08 PM
??? simply draw your non-faded objects after the quad... (and disable depth writes for the quad)

Lurker_pas
01-04-2005, 05:27 AM
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...

knackered
01-04-2005, 08:14 AM
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.

endash
01-04-2005, 05:14 PM
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.