home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / graphics / opengl / 217 < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.6 KB  |  67 lines

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