2 * Copyright 1994-1997 Mark Kilgard, All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * GPL licensing not permitted.
13 #include "glutbitmap.h"
17 glutBitmapCharacter(GLUTbitmapFont font
, int c
)
19 const BitmapCharRec
*ch
;
20 BitmapFontPtr fontinfo
;
21 GLint swapbytes
, lsbfirst
, rowlength
;
22 GLint skiprows
, skippixels
, alignment
;
25 fontinfo
= (BitmapFontPtr
) __glutFont(font
);
27 fontinfo
= (BitmapFontPtr
) font
;
30 if (c
< fontinfo
->first
||
31 c
>= fontinfo
->first
+ fontinfo
->num_chars
)
33 ch
= fontinfo
->ch
[c
- fontinfo
->first
];
35 /* Save current modes. */
36 glGetIntegerv(GL_UNPACK_SWAP_BYTES
, &swapbytes
);
37 glGetIntegerv(GL_UNPACK_LSB_FIRST
, &lsbfirst
);
38 glGetIntegerv(GL_UNPACK_ROW_LENGTH
, &rowlength
);
39 glGetIntegerv(GL_UNPACK_SKIP_ROWS
, &skiprows
);
40 glGetIntegerv(GL_UNPACK_SKIP_PIXELS
, &skippixels
);
41 glGetIntegerv(GL_UNPACK_ALIGNMENT
, &alignment
);
42 /* Little endian machines (DEC Alpha for example) could
43 benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
44 instead of GL_FALSE, but this would require changing the
45 generated bitmaps too. */
46 glPixelStorei(GL_UNPACK_SWAP_BYTES
, GL_FALSE
);
47 glPixelStorei(GL_UNPACK_LSB_FIRST
, GL_FALSE
);
48 glPixelStorei(GL_UNPACK_ROW_LENGTH
, 0);
49 glPixelStorei(GL_UNPACK_SKIP_ROWS
, 0);
50 glPixelStorei(GL_UNPACK_SKIP_PIXELS
, 0);
51 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
52 glBitmap(ch
->width
, ch
->height
, ch
->xorig
, ch
->yorig
,
53 ch
->advance
, 0, ch
->bitmap
);
54 /* Restore saved modes. */
55 glPixelStorei(GL_UNPACK_SWAP_BYTES
, swapbytes
);
56 glPixelStorei(GL_UNPACK_LSB_FIRST
, lsbfirst
);
57 glPixelStorei(GL_UNPACK_ROW_LENGTH
, rowlength
);
58 glPixelStorei(GL_UNPACK_SKIP_ROWS
, skiprows
);
59 glPixelStorei(GL_UNPACK_SKIP_PIXELS
, skippixels
);
60 glPixelStorei(GL_UNPACK_ALIGNMENT
, alignment
);