Displaying a Bitmap

I am writing an application that has a QGLWidget inside of a Qt GUI. I am trying to draw a BMP file that is an arrow onto my screen. I first make a glRasterPos2f( ) function call and I know this is working correctly because what displays is displaying in the correct position. I then make a glBitmap( ) call and this is what it looks like in pseudocode:

 glBitmap( width, height, width/2.0, height/2.0, 0.0, 0.0, arrowImage ); 

But I don’t get my arrow here. I get a whole bunch of garbage that is inside a 16x16 pixel image at the position I requested. The image is supposed to be 16x16 but it’s supposed to be an arrow. I know my BMP file is fine because I have displayed it on a button that I have on a toolbar inside my Qt GUI. Does anyone have any ideas what I might be doing wrong to display the image? The image is a 2-D image. Thanks for your help!

What is the data from your BMP? A bitmap is 1 bit per pixel.

Originally posted by dorbie:
A bitmap is 1 bit per pixel.
a bitmap that you can draw with glBitmap can have only one bit per pixel. you should use glDrawPixels instead.

Thanks…I will try glDrawPixels instead. Some of the BMPs we were trying to use were composed of hex values. I thought that would work but I will try glDrawPixels. Does glDrawPixels do exactly what glBitmap would do if the file is 1 bit/pixel? Is glDrawPixels more of a failsafe in case you don’t know how many bits/pixel your image really is?

of course you have to know the depth, because you have to pass it as a parameter to glDrawPixels. if you have a 24-bit bitmap image of size WxH:

glDrawPixels(W, H, GL_BGR, GL_UNSIGNED_BYTE, pixel_data)

to say it clearly: you can not just load the file into memory and pass it to glDrawPixels. OpenGL will treat it as raw data. so you have to read the file header to get information about width/height, bits per pixel, compression etc., then allocate memory for the image data (or maybe even color tables), then read the image data from the file and create raw, uncompressed image data from it.if the data is compressed, you have to uncompress it by yourself before you send it to glDrawPixels.

Some of the BMPs we were trying to use were composed of hex values.