PDA

View Full Version : Text writing



Vincent
07-13-2000, 05:26 AM
Hi,

I have to draw and move text on the screen using OpenGL. I do that with wglUseFontBitmaps and CallLists ... but when i move the text with glTranslate*, the mouvement is not fluid. How can i repair that??

Thanks a lot

Vincent

drakaza
07-13-2000, 06:12 AM
Well if you are using orthographic projection, you don't have to translate at all....you just specify the 2D coordinates if you are using a quad/triangle

If it's not too much trouble, could you explain how you are doing it? (i like learning new ways to do things http://www.opengl.org/discussion_boards/ubb/smile.gif )

Vincent
07-13-2000, 06:38 AM
Yes I m using orthographic projection.
But How can I move the text without using glraster or translate functions.

Can you explain me ...
Thanks Vincent

drakaza
07-13-2000, 09:26 PM
Well if you are using:

glOrtho(0,scrwidth,scrheight,0,-99999,99999);

with scrwidth as "800" and scrheight as "600" ,then the bottom left of the screen is 0,0 and the top right is 799,599 right?

So all you have to do is map the font image (a quad or 2 triangles) in 2D space using glVertex2f() & glTexCoord2f() like:



glBegin(GL_QUADS);

glTexCoord2f(0,0);
glVertex2f(0,0);

glTexCoord2f(1,0);
glVertex2f(8,0);

glTexCoord2f(1,1);
glVertex2f(8,8);

glTexCoord2f(0,1);
glVertex2f(0,8);

glEnd();



This assumes that you have bound a texture that (for this example) is best at 8x8, with the alpha values set for transparency

This is just an example of how to do just one character per image....You just have to texcoord() it more complicatedly for an entire alphanumeric-set image

Make sure that the depth test is off

If you are still uncertain, email me and I can send you the full source for it


[This message has been edited by drakaza (edited 07-13-2000).]