I've made a moving map system and I want to add something similar to a HUD along the bottom of the window. I thought the easiest way to do would just be to draw a rectangle a few units in front of the camera and have it follow the camera. I have done this fine when translating along any of the axes but I cant get my had around the maths I will need to keep it facing the camera when rotating around an axis. These images might make it easier to explain:
The left image looks as it should and that bar stays where it is when i pan around the map or zoom in, however as soon as I rotate it (on the right) the rectangle rotates as well.
The camera function which controls all the movements on screen is:
And my code to draw the rectangle at the bottom is.
I know all I have to do is put some additional parameters in the glVertex call relating to the xrot, yrot and zrot but I cant figure it out. Any advice?
Thanks.

The left image looks as it should and that bar stays where it is when i pan around the map or zoom in, however as soon as I rotate it (on the right) the rectangle rotates as well.
The camera function which controls all the movements on screen is:
Code:
void camera (void) {
glRotatef(xrot,1.0,0.0,0.0);
glRotatef(yrot,0.0,1.0,0.0);
glRotatef(zrot,0.0,0.0,1.0);
glTranslated(-xpos,-ypos,-zpos);
}
And my code to draw the rectangle at the bottom is.
Code:
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(xpos, ypos, zpos);
glTexCoord2f(0.0, 1.0); glVertex3f(xpos, ypos-800, zpos);
glTexCoord2f(1.0, 1.0); glVertex3f(xpos-10000, ypos-800, zpos);
glTexCoord2f(1.0, 0.0); glVertex3f(xpos-10000, ypos, zpos);
glEnd();
I know all I have to do is put some additional parameters in the glVertex call relating to the xrot, yrot and zrot but I cant figure it out. Any advice?
Thanks.