2 /* Copyright (c) Mark J. Kilgard, 1994. */
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. */
9 #include "glutbitmap.h"
12 glutBitmapCharacter(GLUTbitmapFont font
, int c
)
14 const BitmapCharRec
*ch
;
15 BitmapFontPtr fontinfo
;
16 GLint swapbytes
, lsbfirst
, rowlength
;
17 GLint skiprows
, skippixels
, alignment
;
20 fontinfo
= (BitmapFontPtr
) __glutFont(font
);
22 fontinfo
= (BitmapFontPtr
) font
;
25 if (c
< fontinfo
->first
||
26 c
>= fontinfo
->first
+ fontinfo
->num_chars
)
28 ch
= fontinfo
->ch
[c
- fontinfo
->first
];
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
);