home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / GLUT / lib / glut / glut_bitmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  1.9 KB  |  53 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <GL/glut.h>
  9. #include "glutint.h"
  10. #include "glutbitmap.h"
  11.  
  12. void
  13. glutBitmapCharacter(GLUTbitmapFont font, int c)
  14. {
  15.   BitmapCharPtr ch;
  16.   BitmapFontPtr fontinfo = (BitmapFontPtr) font;
  17.   GLint swapbytes, lsbfirst, rowlength;
  18.   GLint skiprows, skippixels, alignment;
  19.  
  20.   if (c < fontinfo->first ||
  21.     c >= fontinfo->first + fontinfo->num_chars)
  22.     return;
  23.   ch = fontinfo->ch[c - fontinfo->first];
  24.   if (ch) {
  25.     /* save current modes */
  26.     glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
  27.     glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
  28.     glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
  29.     glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
  30.     glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
  31.     glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
  32.     /* Little endian machines (DEC Alpha for example) could
  33.        benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
  34.        instead of GL_FALSE, but this would require changing the
  35.        generated bitmaps too. */
  36.     glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
  37.     glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
  38.     glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
  39.     glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
  40.     glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
  41.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  42.     glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
  43.       ch->advance, 0, ch->bitmap);
  44.     /* restore saved modes */
  45.     glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
  46.     glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
  47.     glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
  48.     glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
  49.     glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
  50.     glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
  51.   }
  52. }
  53.