home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / graphics / opengl / 218 < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.7 KB  |  70 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.061412.22625@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:14:12 GMT
  11. Lines: 57
  12.  
  13. In article <1gioc6INNck8@fido.asd.sgi.com>, akin@tuolumne.asd.sgi.com
  14. (Allen Akin) writes:
  15. |> 
  16. |> You can create the display lists in any way you like.  OpenGL provides some
  17. |> utility routines to convert window-system fonts into display lists, but
  18. since
  19. |> X11 provides only raster fonts, on X11 you'll only get rasters.  (On Windows
  20. |> NT you also get polygonal fonts.)  Since you need Hershy fonts, I'd
  21. recommend
  22. |> getting one of the public-domain versions of the glyphs and building display
  23. |> lists from them.  Then you can draw vector fonts with the string-drawing
  24. |> routines mentioned in step 2 above.  This is fairly easy to do, and gives
  25. |> you the freedom to modify the font in whatever way you'd like.
  26. |> 
  27. |> [Mason, is there anything like this in the OpenGL books?  Might be a good
  28. |> example.]
  29. |> 
  30.  
  31. Yes, Tom Davis wrote a small raster font and vector font example which
  32. will be in the OpenGL Programming Guide (to be published by Addison-Wesley
  33. in early spring of 1993).  Here's part of that example below.  
  34. The rasters[] array is a whole lot of data for the glyphs of a rasterfont
  35. which are read into a whole lot of display lists.  Then, when you 
  36. `printString ("string")' the ASCII values of `s', `t', `r', `i', `n', 
  37. and `g' will reference the appropriate display list, when
  38. glCallLists() is called.
  39.  
  40. #define FONTOFFSET 1000
  41.  
  42. void makeRasterFont(void)
  43. {
  44.     long i;
  45.     glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
  46.     glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
  47.     glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
  48.     glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
  49.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  50.     for (i = 32; i < 127; i++) {
  51.         glNewList(i+FONTOFFSET, GL_COMPILE);
  52.         glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, rasters[i-32]);
  53.         glEndList();
  54.     }
  55. }
  56.  
  57. void printString(char *s)
  58. {
  59.     long oldlistbase;
  60.     glPushAttrib (GL_LIST_BIT);
  61.     glListBase(FONTOFFSET);
  62.     glCallLists(strlen(s), GL_UNSIGNED_BYTE, (unsigned char *)s);
  63.     glPopAttrib ();
  64. }
  65.  
  66. Mason Woo, "The OpenGL Right Reverend"     (415) 390-3314 
  67. Graphics Technology Licensing (Product Marketing)
  68. Silicon Graphics, Inc.    Internet: woo@SGI.COM     
  69. Personal opinion:  "I worship Arturs Irbe"
  70.