home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / MesaDLL / glut_bitmap.cpp < prev    next >
C/C++ Source or Header  |  2002-12-19  |  2KB  |  58 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 "glutint.h"
  9. #include "glutbitmap.h"
  10.  
  11. void GLUTAPIENTRY
  12. glutBitmapCharacter(GLUTbitmapFont font, int c)
  13. {
  14.   const BitmapCharRec *ch;
  15.   BitmapFontPtr fontinfo;
  16.   GLint swapbytes, lsbfirst, rowlength;
  17.   GLint skiprows, skippixels, alignment;
  18.  
  19. #if defined(_WIN32)
  20.   fontinfo = (BitmapFontPtr) __glutFont(font);
  21. #else
  22.   fontinfo = (BitmapFontPtr) font;
  23. #endif
  24.  
  25.   if (c < fontinfo->first ||
  26.     c >= fontinfo->first + fontinfo->num_chars)
  27.     return;
  28.   ch = fontinfo->ch[c - fontinfo->first];
  29.   if (ch) {
  30.     /* Save current modes. */
  31.     glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
  32.     glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
  33.     glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
  34.     glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
  35.     glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
  36.     glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
  37.     /* Little endian machines (DEC Alpha for example) could
  38.        benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
  39.        instead of GL_FALSE, but this would require changing the
  40.        generated bitmaps too. */
  41.     glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
  42.     glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
  43.     glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
  44.     glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
  45.     glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
  46.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  47.     glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
  48.       ch->advance, 0, ch->bitmap);
  49.     /* Restore saved modes. */
  50.     glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
  51.     glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
  52.     glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
  53.     glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
  54.     glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
  55.     glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
  56.   }
  57. }
  58.