I am working on a turn based strategy game and I have this problem since almost the very beginning. I can’t find it discussed anywhere therefore this post:
I’ve asked a fellow programmer about this already, let me quote the message I sent to him.
He said that he thinks that orthographic projection is the answer here. Unfortunately glOrtho(), which I’ve been using only to display items that should lay “flat on the screen” (menus, etc.), destroys the coordinate system that was set by gluPerspective().
For example: I have a star that is placed in 3D world using the gluPerspective(). I want to display the name of that star right below it. I set the GL coordinates of text with function that looks like this:
text->setTranslationPosition(starGLcoords.x, starGLcoords.y - 0.02f, starGLcoords.z);
When this is drawn with the same perspective as the star it works ok, minus the text scaling problem when camera is zooming out. But it obviously will go wrong when I change to glOrtho(). So, is there any OpenGL mechanism that I can use to position this text correctly or do I have to calculate the proper coordinates manually?
BTW: The camera is fixed to look always straight forward so there’s no need to “billboard” the text to make sure it’s always facing the camera.