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