home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.graphics.opengl
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!sgi!fido!news.csd.sgi.com!basia.csd.sgi.com!woo
- From: woo@basia.csd.sgi.com (Mason Woo)
- Subject: Re: GL question
- Message-ID: <1992Dec17.065459.22970@news.csd.sgi.com>
- Sender: news@news.csd.sgi.com (Net News CSD)
- Reply-To: woo@basia.csd.sgi.com (Mason Woo)
- Organization: Silicon Graphics Inc.
- References: <1992Dec4.023016.19762@news.csd.sgi.com> <1992Dec14.164044.16279@kakwa.ucs.ualberta.ca> <1gioc6INNck8@fido.asd.sgi.com>
- Date: Thu, 17 Dec 1992 06:54:59 GMT
- Lines: 54
-
- In article <1gioc6INNck8@fido.asd.sgi.com>, akin@tuolumne.asd.sgi.com
- (Allen Akin) writes:
- |> You can create the display lists in any way you like. OpenGL provides some
- |> utility routines to convert window-system fonts into display lists, but
- since
- |> X11 provides only raster fonts, on X11 you'll only get rasters. (On Windows
- |> NT you also get polygonal fonts.) Since you need Hershy fonts, I'd
- recommend
- |> getting one of the public-domain versions of the glyphs and building display
- |> lists from them. Then you can draw vector fonts with the string-drawing
- |> routines mentioned in step 2 above. This is fairly easy to do, and gives
- |> you the freedom to modify the font in whatever way you'd like.
- |>
- |> [Mason, is there anything like this in the OpenGL books? Might be a good
- |> example.]
-
- Yes, Tom Davis wrote a raster font and a stroke font example for
- the OpenGL Programming Guide, which will be published by Addison-Wesley
- in the spring of 1993 (you have just read a blatant plug). I'll show
- you two subroutines of a code example from the book. This example
- assumes an array rasters[] defines the bitmaps for the character glyphs.
- The printString("string") routine uses the ASCII values for `s', `t', `r',
- `i', `n', and `g' to index into a set of contiguous display lists.
-
- #define FONTOFFSET 1000
-
- void makeRasterFont(void)
- {
- long i;
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- for (i = 32; i < 127; i++) {
- glNewList(i+FONTOFFSET, GL_COMPILE);
- glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, rasters[i-32]);
- glEndList();
- }
- }
-
- void printString(char *s)
- {
- long oldlistbase;
- glPushAttrib (GL_LIST_BIT);
- glListBase(FONTOFFSET);
- glCallLists(strlen(s), GL_UNSIGNED_BYTE, (unsigned char *)s);
- glPopAttrib ();
- }
-
- Mason Woo, "The OpenGL Right Reverend" (415) 390-3314
- Graphics Technology Licensing (Product Marketing)
- Silicon Graphics, Inc. Internet: woo@SGI.COM
- Personal opinion: "I worship Arturs Irbe"
-