I want to draw a 2-D square. It is positioned at a specified 3D location but its shape on the user’s screen should be always a square with the same size regardless of translation, rotation, etc. How can I do this? Could someone help me? Thanks.
Get the modelview matrix using glGetDoublev
Fill first 3X3 square in this matrix by
100
010
001
to eliminate rotation.
Extract depth from bottom row of matrix.
Calculate width like w = z*w1/z1 , where z is current depth, w1 is a width desired on z1 depth(this koefficient can be found using some trig).