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. */
10 #include "glutbitmap.h"
13 glutBitmapCharacter(GLUTbitmapFont font
, int c
)
15 const BitmapCharRec
*ch
;
16 BitmapFontPtr fontinfo
;
17 GLint swapbytes
, lsbfirst
, rowlength
;
18 GLint skiprows
, skippixels
, alignment
;
21 fontinfo
= (BitmapFontPtr
) __glutFont(font
);
23 fontinfo
= (BitmapFontPtr
) font
;
26 if (c
< fontinfo
->first
||
27 c
>= fontinfo
->first
+ fontinfo
->num_chars
)
29 ch
= fontinfo
->ch
[c
- fontinfo
->first
];
31 /* Save current modes. */
32 glGetIntegerv(GL_UNPACK_SWAP_BYTES
, &swapbytes
);
33 glGetIntegerv(GL_UNPACK_LSB_FIRST
, &lsbfirst
);
34 glGetIntegerv(GL_UNPACK_ROW_LENGTH
, &rowlength
);
35 glGetIntegerv(GL_UNPACK_SKIP_ROWS
, &skiprows
);
36 glGetIntegerv(GL_UNPACK_SKIP_PIXELS
, &skippixels
);
37 glGetIntegerv(GL_UNPACK_ALIGNMENT
, &alignment
);
38 /* Little endian machines (DEC Alpha for example) could
39 benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
40 instead of GL_FALSE, but this would require changing the
41 generated bitmaps too. */
42 glPixelStorei(GL_UNPACK_SWAP_BYTES
, GL_FALSE
);
43 glPixelStorei(GL_UNPACK_LSB_FIRST
, GL_FALSE
);
44 glPixelStorei(GL_UNPACK_ROW_LENGTH
, 0);
45 glPixelStorei(GL_UNPACK_SKIP_ROWS
, 0);
46 glPixelStorei(GL_UNPACK_SKIP_PIXELS
, 0);
47 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
48 glBitmap(ch
->width
, ch
->height
, ch
->xorig
, ch
->yorig
,
49 ch
->advance
, 0, ch
->bitmap
);
50 /* Restore saved modes. */
51 glPixelStorei(GL_UNPACK_SWAP_BYTES
, swapbytes
);
52 glPixelStorei(GL_UNPACK_LSB_FIRST
, lsbfirst
);
53 glPixelStorei(GL_UNPACK_ROW_LENGTH
, rowlength
);
54 glPixelStorei(GL_UNPACK_SKIP_ROWS
, skiprows
);
55 glPixelStorei(GL_UNPACK_SKIP_PIXELS
, skippixels
);
56 glPixelStorei(GL_UNPACK_ALIGNMENT
, alignment
);