The text is drawn but it it sort of stays at the origin.I want the text to be drawn,say, at the top left corner of my screen and it STAYS there when I move the camera around in 3D space. Any suggestions? Or does anyone have any text functions they can give me instead? Mine is a bit messy Some simple function like glText(LPCTSTR MyText,int x,int y) sould be nice. I’m still trying to get this whole no-2D issue in OpenGL solved
Oh I have.That’s not the problem because after you move the camera around in the 3D world the text sort of “stays” at that 3D point in the world.So when I rotate the camera to the left,the text moves to the right.Get what I mean?
Push an orthographic matrix onto the projection matrix stack.
Push an identity matrix onto the modelview stack.
Draw your text.
Pop both matrices.
I wouldn’t recommend putting the matrix stuff inside the DrawText function; if you were drawing more than one string you’d get a lot of unnecessary duplication.
Generally speaking, most 2D work in screen space can be done very easily with this combination of ortho projection and identity modelview. Plus, many drivers will detect that you’re using an identity matrix and optimize away the transform step.
… and if you would have problems with the other solutions given you may also want to try my Enter2d() and Exit2d() functions which simpifies things a little.
After calling Enter2d() your upper left corner is at (0,0) and the lower right corner is (1,1). So you can use the glVertex2f( … ) function to specify 2d coords. After calling Exit2d() the previous state is set back again.
[This message has been edited by Humus (edited 04-15-2000).]