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.061412.22625@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:14:12 GMT
- Lines: 57
-
- 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 small raster font and vector font example which
- will be in the OpenGL Programming Guide (to be published by Addison-Wesley
- in early spring of 1993). Here's part of that example below.
- The rasters[] array is a whole lot of data for the glyphs of a rasterfont
- which are read into a whole lot of display lists. Then, when you
- `printString ("string")' the ASCII values of `s', `t', `r', `i', `n',
- and `g' will reference the appropriate display list, when
- glCallLists() is called.
-
- #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"
-