displaying a 16 bits image

Hello,

I have my depth display set with 16 bits and I would like to display a 16 bits color image using glDrawPixel and also glTexImage2D. But I don’t know which “format” and “components” arguments to give to those functions :

GLubyte * pixels;
pixels = ....

glDrawPixels(
   w,h,
format = GL_RGB ???,
   type = GL_UNSIGNED_BYTE,
   pixels
);

...

glTexImage2D(GL_TEXTURE_2D,
	     0,
	components = 3 ???
	     w, h,
	     0,
	format = GL_RGB??
	    type = GL_UNSIGNED_BYTE,
	     pixels
);

Argument components should be 3 as my color is RGB coded. Argument type is GL_UNSIGNED_BYTE as *pixel is a GLubyte.
So like this, OpenGL will suppose to have 3 bytes for a pixel, won’t it?
But my colors are coded with 16 bits (R->6, G->5, B->5).

Can someone give me the correct arguments please?

Thanks in advance.
Fabien

Easy, just update your docs :stuck_out_tongue: !

http://pyopengl.sourceforge.net/documentation/manual/glTexImage2D.3G.html

For internalformat I am not really sure, probably GL_RGB5, or GL_RGB8. It is probably not important, though.

Set format to GL_RGB (or GL_BGR).
Set type to GL_UNSIGNED_SHORT_5_6_5 (or the _REV version).

Thank you Zbuffer! You’re right : my doc is a bit old, there was no GL_UNSIGNED_SHORT_5_6_5.
It’s going to work (I hope…).
But shouldn’t I use glPixelStore(GL_UNPACK_ALIGNMENT,…) before calling glTexImage2D? I don’t understand how this function works. I’ve tried glPixelStore(GL_UNPACK_ALIGNMENT,2) as my depth is 16 bits but it doesn’t work.