PDA

View Full Version : Layers / Mapping



Judith Mortimer
03-30-2000, 01:13 AM
Is it possible to use layers in OpenGL? I want to display maps and am wondering if it's possible to show them as a set of layers -transparent apart from the objects(polygons/lines /bitmaps etc) on them. If so how do I go about creating them?

MikeC
03-30-2000, 05:13 AM
Shouldn't be a problem...

If the contents of each layer are fixed:

Create each layer as an RGBA texture. The A component (alpha) should be zero where you want the layers beneath to show through, 255 where you don't.

Enable blending:
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

Set the texture mode to let the background show through where the texel alpha is zero:
glTexEnv( GL_REPLACE );

Then just draw the layers in order as textured quads, bottom to top.

If you're redrawing each layer every frame, then none of this should be necessary - as long as you're drawing the layers in order it should come out OK.

Hope this helps, feel free to mail me if any problems.