Open GL Pixel Operations Bitmaps Fonts and Images
Open. GL Pixel Operations, Bitmaps, Fonts and Images The Current Raster Position Current raster position: A position in window coordinates where the next bitmap (or image) is to be drawn. void gl. Raster. Pos 2{sifd}(TYPE x, TYPE y) void gl. Raster. Pos 3{sifd}(TYPE x, TYPE y , TYPE z) void gl. Raster. Pos 4{sifd}(TYPE x, TYPE y , TYPE z , TYPE h) void gl. Raster. Pos {234}{sifd}v(TYPE * coords) Sets the current raster position. (x, y, z, h) is treated as object coordinates and is transformed by current modelview matrix, projection matrix and viewport. The transformed position is stored as current raster position.
Bitmaps Bitmap: An array of bit values (0 or 1). void gl. Bitmap(GLsizei width, GLsizei height, GLfloat xo, GLfloat yo, GLfloat xi, GLfloat yi, const GLubyte * bitmap) Draw a bitmap at current raster position. width, height: Width and height of the bitmap in pixels. xo, yo: Origin of the bitmap relative to its lower-left corner. xi, yi: x and y offsets to be added to the current raster position after the bitmap is drawn. bitmap: Array that stores the bitmap Pixel corresponding to “ 1” in bitmap is written using current raster color. Pixel corresponding to “ 0” in bitmap is unchanged. Current raster color is set to current color when gl. Raster. Pos*() is called.
The bits in a bitmap must be stored in chunks of 8 and start from lower left corner. But the width of the actually bitmap doesn't have to be multiple of 8. 0 xff, 0 xc 0, 0 xc 0, 0 xff, 0 xc 0, 0 xc 0, 0 x 00 0 x 00 0 x 00 GLubyte bitmap_F[] = {0 xc 0, 0 x 00, 0 xc 0, 0 x 00, 0 xff, 0 x 00, 0 xc 0, 0 x 00, 0 xff, 0 xc 0}; gl. Bitmap(10, 12, 0. 0, 11. 0, 0. 0, bitmap_F);
GLUT Bitmap Font void glut. Bitmap. Character(void *font, int character) Render character with given font at current raster position. The width of the character is added to the x coordinate of current raster position. Internally GLUT implements this function using gl. Bitmap(). font bitmap font GLUT_BITMAP_8_BY_13 8 by 13 fixed width font GLUT_BITMAP_9_BY_15 9 by 15 fixed width font GLUT_BITMAP_TIMES_ROMAN_1 0 10 -point Times Roman GLUT_BITMAP_TIMES_ROMAN_2 4 24 -point Times Roman GLUT_BITMAP_HELVETICA_10 10 -point Helvetica GLUT_BITMAP_HELVETICA_12 12 -point Helvetica GLUT_BITMAP_HELVETICA_18 18 -point Helvetica
int glut. Bitmap. Width(void * font, int character) Return the width, in pixels, of character with given font To render a null-terminated string: void Draw. String(void *font, char *str) { while((*str)!='