| Код | GLvoid buildFont(GLvoid) { XFontStruct *font; base = glGenLists(96); /* storage for 96 characters */ /* load a font with a specific name in "Host Portable Character Encoding" */ font = XLoadQueryFont(GLWin.dpy, "-*-helvetica-bold-r-normal--24-*-*-*-p-*-iso8859-1"); if (font == NULL) { /* this really *should* be available on every X Window System...*/ font = XLoadQueryFont(GLWin.dpy, "fixed"); if (font == NULL) { printf("Problems loading fonts :-(\n"); exit(1); } } /* build 96 display lists out of our font starting at char 32 */ glXUseXFont(font->fid, 32, 96, base); /* free our XFontStruct since we have our display lists */ XFreeFont(GLWin.dpy, font); } /////////////////////////////////////////////////////////////////////////////////// GLvoid printGLf(const char *fmt, ...) { va_list ap; /* our argument pointer */ char text[256]; if (fmt == NULL) /* if there is no string to draw do nothing */ return; va_start(ap, fmt); /* make ap point to first unnamed arg */ /* FIXME: we *should* do boundschecking or something to prevent buffer * overflows/segmentations faults */ vsprintf(text, fmt, ap); va_end(ap); glPushAttrib(GL_LIST_BIT); glListBase(base - 32); glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); glPopAttrib(); }
|
Вот когда-то так делал. TTF тоже можно юзать |