retrieving transformed screen coordinates for 3d object
I'm wondering if you could help me with an OpenGL programming dilemma I have.
I'm rendering a molecule using openGL, and each atom is a sphere centered around an (x, y, z) point. I want to add some text, slightly offset from the center of each sphere by a constant amount, say 20 pixels in the x and y directions. I'm using GLUT to draw the text, that's no problem. Problem is that I need to use glRasterPos3f() to set the raster position for the text drawing operation in 3d space, rather than 2d screen coordinates. This is good for getting the position of the centers of the atoms, but bad for offsetting the text by a constant amount in screen coordinates. My question is: is there an openGL or utility function, that will return the actual (x, y) screen coordinates of a position in 3D space, using the current transformation and projection matrices?
Re: retrieving transformed screen coordinates for 3d object
Well, never mind, guys, a previous topic has answered my question! I am going to use the gluProject function to obtain screen coordinates from my 3d world coordinates.
Thanks! Very useful message board!