OpenGL: How to make text appear at the same pixels regardless of camera orientation?
I have text that I am successfully rendering in OpenGL:
GLUT glut = new GLUT();
gl.glRasterPos2d(10, 10);
glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, "We're going to the moon!");
I would like this text to appear in the same location开发者_StackOverflow社区 on the user's screen (occupying the same pixels) regardless of camera orientation. How should I go about doing this?
(I'm using JOGL.)
Try this (I don't know Java, warning):
glPushMatrix() //save the camera state
glLoadIdentity()
//draw your text here
glPopMatrix() //restore the camera state
This resets the camera location to the origin for any rendering commands following the glLoadIdentity()
call.
精彩评论