PDA

View Full Version : opengl text output



Raketman
09-16-2001, 11: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-17-2001, 12:20 AM
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-17-2001, 12:28 AM
hm, thats a complex way for such a simple thing.

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

Boresight
09-17-2001, 07: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-18-2001, 12:14 AM
thanx boresight, exactly what i needed !