Opengl Fonts and glRasterPos2f

Started by
6 comments, last by q2guy 19 years, 3 months ago
Exists an easy way to tell opengl where to put text on screen ?, I am using display list and HFONTs, and then I have to use glRasterPos2f to put text on a screen position. I want something easy, user friendly, based on window height and width, like this: PrintGL(FontList, win.height / 2, win.width / 2, "Hi world"); so it begin putting in window center the H letter. thanks
Advertisement
what can I say... hmmm...
just read one from the NeHe tutorials

you can find information about fonts in 13th, 14th, 15th and 17th lesson

NeHe

when you read them you will be able create very nice pice of code... For example you will have glPrint function that works not only with 2d bitmap fonts but also with full 3 dimensional fonts! the lessons are great!

good luck :)

Se my programming blog: Code and Graphics

try to glOrtho() and glTranslate*()like this
glMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();glOrtho(0,win.width,0,win.height,-1, 1);glMatrixMode(GL_MODELVIEW);glPushMatrix();glLoadIdentity();glTranslated(X,Y,0);PrintGL("Hi world");glMatrixMode(GL_PROJECTION);glPopMatrix();   glMatrixMode(GL_MODELVIEW);glPopMatrix();


bye! :)
I have read the nehe tutorials, I only ask one thing, easy of use in positioning text.
do you print the letters one after one ??
I call the display lists:
glCallLists(strlen(text),GL_UNSIGNED_BYTE,text);
i think you can control the position easy by your function.
Thanks, I have solved, thanks to ff8 code and "Avoiding 16 Common OpenGL Pitfalls" article.

This topic is closed to new replies.

Advertisement