If your HUD is an overlay as they usually are, you'll probably want to Disable the depth test & potentially depth writes before drawing the HUD Content:
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
This way the Z value of the HUD is irrelevant. Don't forget to re-enable before drawing the scene.
As others have observed, you have matrix stack issues as well. Separate stacks are associated with the projection & modelview matrices. Right now you are pushing projection matrices and popping modelview matrices, so you're overflowing one and underflowing the other. You need to push & pop in the same mode symmetrically. Given that you're starting with a glLoadIdentity()
in each mode, you may not need to use the matrix stacks at all.
EDIT: A more direct answer
Here's what your render code should probably look like:
void render()
{
//Clear screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//*************************************************************************
//* Prepare to render main scene:
//*************************************************************************
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(...);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef( cam.getEye().getX(), cam.getEye().getY(), cam.getEye().getZ() );
glRotatef( cam.getTheta(), 0.0f, 1.0f, 0.0f );
//*************************************************************************
//* Draw Main Scene Here:
//*************************************************************************
// ...
//*************************************************************************
//* Prepare to render HUD overlay:
//*************************************************************************
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(...);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//*************************************************************************
//* Draw HUD here:
//*************************************************************************
// ...
// Finish the frame:
glutSwapBuffers(); //Send scene to the screen to be shown
}
Now, since you'll be adjusting the projection matrix twice during each render call, you should remove gluPerspective() from your resizeWindow() function. Also, I removed the glClearColor() call from the render function--better to set that once at the beginning of the program and forget it. State changes are expensive so you want to avoid them as much as possible.