16 bit greyscale image.

How can I display a 16bit greyscale image?

The image is represented as an array of unsigned shorts. For testing purposes I have been filling the array with random values.

I have been playing around with glDrawPixels but have had minimal success. If I use GL_LUMINANCE I can get something to display but I get a bunch of columns. Its seems as though only every fourth pixel in a row will display. I’ve tried other values for format, but with those i either get all white or all black. Please help.

Should I be even using glDrawPixels or is there a better way to be doing this?

AFAIK, you cannot display 16 bit in a single channel. Think of mapping 16-bit values to 8-bit to display it (scale down or show some range).

The glDrawPixels() call should look like:
glDrawPixels(imageWidth, imageHeight, GL_LUMINANCE, GL_UNSIGNED_SHORT, imageBuffer);

Also, make sure the data endian is same as the system endian and the correct data alignment (GL_UNPACK_ALIGNMENT).

Here is an example code to draw a 16-bit raw image:
imageRaw16bit.zip