PDA

View Full Version : About Chinese characters



LangFox
10-09-2001, 11:54 PM
Hello,everyone.
I want to know if I can put Chinese characters in my OpenGL programs?And how to do it?
Thanks!

T2k
10-10-2001, 12:13 AM
like you would do for other textoutput, if you want to have 3d-fonts you should have a true type font of the wanted charset, then do something like(my temp font class in c++...):

class FONT3D{
DWORD nFontList;
public:
FONT3D(HDC hDC){
HFONT hFont;
GLYPHMETRICSFLOAT agmf[128];
LOGFONT logfont;

logfont.lfHeight = -10;
logfont.lfWeight = 0;
logfont.lfEscapement = 0;
logfont.lfOrientation = 0;
logfont.lfWeight = FW_BOLD;
logfont.lfItalic = FALSE;
logfont.lfUnderline = FALSE;
logfont.lfStrikeOut = FALSE;
logfont.lfCharSet = ANSI_CHARSET;
logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logfont.lfQuality = DEFAULT_QUALITY;
logfont.lfPitchAndFamily= DEFAULT_PITCH;
strcpy(logfont.lfFaceName, "ARIAL");//Here is the font to use http://www.opengl.org/discussion_boards/ubb/smile.gif

hFont = CreateFontIndirect(&logfont);
SelectObject(hDC, hFont);

nFontList = glGenLists(128);
wglUseFontOutlines(hDC, 0, 128, nFontList, 0.0f, 0.1f, WGL_FONT_POLYGONS, agmf);

DeleteObject(hFont);
};
~FONT3D(){
glDeleteLists(nFontList, 128);//Font
};

inline void Draw(const char *txt, const long size){
glListBase(nFontList);
glCallLists( size, GL_UNSIGNED_BYTE, txt);
};
};

or if you want to use 2d fonts, you have to gen some image (via photoshop, not paint or paintshop http://www.opengl.org/discussion_boards/ubb/biggrin.gif),load em as texture and then draw quads textured with the right coords...

LangFox
10-10-2001, 05:58 PM
Thanks!
But Chinese are not the same as English which all are made up of 26 characters.
The number of Chinese characters often used
is 3000~5000.And they are entirely different.
So I can't use a image as a texture to utput Chinese.
But thanks again.I will try more.

ruixp
12-05-2001, 11:44 PM
i have the same question as u ,can u give some help,thank u very much
btw,i use the wglUseFontOutlines(...),i think there must have some methords http://www.opengl.org/discussion_boards/ubb/smile.gif