text is rotating along w/ model

I render my model as gl.glMatrixMode(GL.GL_MODELVIEW) and I’ve also got text displayed. The problem I’m having with the text is that when I rotate my model, the text (which is as simple as what I’ve got below) is also rotating and I would like for it to stay in one location like a legend in one of the corners of the screen.


        gl.glRasterPos3f(0.10f, 0.10f, 0.10f);
        glut.glutBitmapString(gl, GLUT.BITMAP_HELVETICA_10,
            "Element Id:" + infoElementId);

        gl.glRasterPos2f(0.25f, 0.25f);
        glut.glutBitmapString(gl, GLUT.BITMAP_HELVETICA_10, "Edge #1:");

Any help much appreciated in making my text stay still.

The glRasterPos() function positions the bitmap in 3D space, so all modelview and projection matrix calculations are applied to the given coordinates.

If you don’t mess with the pojection matrix (as for warp-effects and such) you could just call gl.glLoadIdentity() before you draw the text. If you also modify the projection matrix you have to call glLoadIdentity() for this as well.

To be sure, this does not affect the rest of your scene drawing you have to draw the text at last or you have to push and pop the matrices accordingly.

Let me make sure I understand you correctly.

Your saying I have to draw the scene first and the text last? Then I can put gl.glLoadIdentity() after I draw the scene, then draw the text as I do above (which makes it last)!?

[quote]Let me make sure I understand you correctly.

Your saying I have to draw the scene first and the text last? Then I can put gl.glLoadIdentity() after I draw the scene, then draw the text as I do above (which makes it last)!?
[/quote]
It seems to be good for me!

Long story short: yes :wink:

  1. scene
  2. gl.glLoadIdentity()
  3. text

;D