patch to import Jon Smirl's work from Bitkeeper
[mesa.git] / src / glut / mini / bitmap.c
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 "glutbitmap.h"
9
10 void APIENTRY
11 glutBitmapCharacter(GLUTbitmapFont font, int c)
12 {
13 const BitmapCharRec *ch;
14 BitmapFontPtr fontinfo;
15 GLfloat swapbytes, lsbfirst, rowlength;
16 GLfloat skiprows, skippixels, alignment;
17
18 #if defined(_WIN32)
19 fontinfo = (BitmapFontPtr) __glutFont(font);
20 #else
21 fontinfo = (BitmapFontPtr) font;
22 #endif
23
24 if (c < fontinfo->first ||
25 c >= fontinfo->first + fontinfo->num_chars)
26 return;
27 ch = fontinfo->ch[c - fontinfo->first];
28 if (ch) {
29 /* Save current modes. */
30 /* glGetFloatv(GL_UNPACK_SWAP_BYTES, &swapbytes); */
31 /* glGetFloatv(GL_UNPACK_LSB_FIRST, &lsbfirst); */
32 /* glGetFloatv(GL_UNPACK_ROW_LENGTH, &rowlength); */
33 /* glGetFloatv(GL_UNPACK_SKIP_ROWS, &skiprows); */
34 /* glGetFloatv(GL_UNPACK_SKIP_PIXELS, &skippixels); */
35 glGetFloatv(GL_UNPACK_ALIGNMENT, &alignment);
36 /* Little endian machines (DEC Alpha for example) could
37 benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
38 instead of GL_FALSE, but this would require changing the
39 generated bitmaps too. */
40 /* glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); */
41 /* glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); */
42 /* glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); */
43 /* glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); */
44 /* glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); */
45 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
46 glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
47 ch->advance, 0, ch->bitmap);
48 /* Restore saved modes. */
49 /* glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); */
50 /* glPixelStorei(GL_UNPACK_LSB_FIRST, (int)lsbfirst); */
51 /* glPixelStorei(GL_UNPACK_ROW_LENGTH, (int)rowlength); */
52 /* glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); */
53 /* glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); */
54 glPixelStorei(GL_UNPACK_ALIGNMENT, (int)alignment);
55 }
56 }