Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: displaying a 16 bits image

  1. #1
    Junior Member Newbie
    Join Date
    May 2004
    Location
    Toulouse, France
    Posts
    29

    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 :

    Code :
    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

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: displaying a 16 bits image

    Easy, just update your docs !

    http://pyopengl.sourceforge.net/docu...mage2D.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).

  3. #3
    Junior Member Newbie
    Join Date
    May 2004
    Location
    Toulouse, France
    Posts
    29

    Re: displaying a 16 bits image

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •