PDA

View Full Version : opengl text output



Raketman
09-16-2001, 10:56 PM
hello,

can someone tell me how I can write text to my mfc-opengl window ? Is there an opengl command to do this ?

Platinum
09-16-2001, 11:20 PM
the best approach I have found is to draw textured quads with letters.

Haven't found yet how the OGL font facility works http://www.opengl.org/discussion_boards/ubb/smile.gif...

Raketman
09-16-2001, 11:28 PM
hm, thats a complex way for such a simple thing.

DaViper
09-17-2001, 12:11 AM
OpenGL ist graphics api not a typewriter....

Boresight
09-17-2001, 06:13 AM
In a Win32 enviroment, you can use wglUseFontBitmap() or wglUseFontOutline() for create display lists with Windows fonts.

CFont font;
int fontDL;
char* text = "Hello World!";

font.CreatePointFont(120,"Arial",clientDC);
SelectObject(clientDC->GetSafeHdc(),font);
wglUseFontBitmaps(clientDC->GetSafeHdc(),0,255,fontDL);
glRasterPos2f(x,y);
glListBase(fontDL);
glCallLists(strlen(text),GL_UNSIGNED_BYTE,text);

This code write "Hello World!" in (x,y) using Arial 12.

[This message has been edited by Boresight (edited 09-17-2001).]

Raketman
09-17-2001, 11:14 PM
thanx boresight, exactly what i needed !