I am trying to implement HUD to my 3d application, what I have achieved is I have a rectangle at certain position, with texture over it. The problem is that whenever I rotate or move camera, texture scales or moves with the camera, looks very weird. Any ideas why it might happen?
This is what I do to add the HUD:
glDisable(GL_DEPTH_TEST);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
gluOrtho2D( 0, 1, 0, 1);
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D,4 );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBegin( GL_QUADS );
glColor3f( 1.0f, 1.0f, 0.0f );
glTexCoord2f(0,0);
glVertex2f( 0.0f, 0.0f );
glTexCoord2f(1,0);
glVertex2f( 0.4f, 0.0f );
glTexCoord2f(1,1);
glVertex2f( 0.4f, 0.4f );
glTexCoord2f(0,1);
glVertex2f( 0.0f,0.4f );
glEnd();
glPopMatrix();
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glEnable(GL_DEPTH_TEST);
glEnable( GL_LIGHTING );