Overlays

Different graphical elements can be drawn with separate projections.

A 2D overlay can be drawn using an orthographic projection, on top of a scene drawn with a perspective projection.

Disable the depth test for the 2D part.

2D overlays are used for such things as heads-up-displays, text information, lens flares, etc.

Example: overlay.cpp







A 3D overlay can also be drawn - e.g. a 3D cockpit console in a flight simulator.

In this case, depth buffering could cause objects from the main scene to hide parts of the overlay.

Avoid this by clearing just the depth buffer before drawing the overlay.

    glClear(GL_DEPTH_BUFFER_BIT);

Example: overlay1.cpp



next