First you need to understand what glBitmap
does: glBitmap
is a drawing function. It looks at each bit (hence bit map) of the given data, interpreted as a 2 dimensional array and relative to the current raster position (set with glRasterPos
) sets those pixels to the currently set raster color (glRasterColor
) whose corresponding bit in the bitmap are set. Each GLubyte contains 8 bits, so each byte covers 8 pixels width (endianess is set using glPixelStore
).
A for reading a bitmap from a file. AFAIK there's only one widespread bitmap format (in contrast to pixmaps which have channels, where each pixel's channel can assume a range of values). That format is PBM: http://en.wikipedia.org/wiki/Netpbm_format
Given the information from the Wikipedia page it is straightforward to write a function that opens and reads a PBM file (functions required are fopen
, fread
and fclose
) into a structure holding the data. Then one can use that structure to feed the data to glBitmap
.
But remember, bitmaps are just binary valued images, i.e. black and white, no grays, not to speak of colour.
Now your notion was "loading a bitmap". I already told, that glBitmap
immediately draws the data you give it. So I think what you're actually looking for is textures and a image file to texture loader.