Guide to Game Development/Theory/Graphical User Interfaces (GUI) and Heads-up-displays (HUD)

In order to render a GUI or a HUD on top of the gameplay, then you need to clear the depth buffer. Every time you want a new layer of geometry, you'll need to clear the depth buffer to make sure that the layers don't interact with each other.

Here's some pseudocode of the drawing of the game, the HUD and the GUI.