Drawing Lines Across Transformations

Hi all,

I am sure I am thinking about this problem wrong. Can someone please clarify my thought.

What I want to do is as follows. I apply certain transforms and then I draw glutSolidSphere at the current coordinate based upon my transformation matrix. I then want to apply further transforms and draw another glutSolidSphere at the new coordinate. I would like to connect the 2 points together with a line such as using GL_LINES (actually the line is more important for me than actually drawing the spheres). If I do my GL_LINES at the end, I can have (0.0f, 0.0f, 0.0f) as my second vertex, but how do I get the coordinate for the first vertex of the line which represents the first sphere I drew.

Let MV_0 and MV_1 be the model view matrices when drawing the two spheres respectively.
Store points p0 = MV_0 * [0, 0, 0] and p1 = MV_1 * [0, 0, 0] (that is store the center points of the two spheres in eye coordinates).
Then set the model view matrix to identity and use p0, p1 as the two vertices for your line.

The reason you need to compute the points ‘by hand’ is because you can not change the model view matrix inside a primitive (between glBegin, glEnd).