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: glColorTableExt for gray scale palette

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Posts
    9

    glColorTableExt for gray scale palette

    Is it possible to define a gray scale plette with glColorTableExt ? How ? What are the parameters ?

    I succeeded to define 8 bits palette for green levels. But not gray.

    What will be the parameters for glTexImage2D ?

    Thanks in advance.

  2. #2
    Member Regular Contributor
    Join Date
    Jul 2001
    Location
    earth
    Posts
    263

    Re: glColorTableExt for gray scale palette

    basically grayscale pictures doesn't need palettes bcoz colors are stored as intensity (8bits) so if u need to translate your bitmap as indexes->palette just fill each r,g,b with the same value.
    Now if you've planned to use grayscale pics i *strongly* recommend to also use the shared palette extension which will save a little bit of time when binding textures.

    switch(pPicInfos->type){
    case BITMAP_4B:
    pBitmap->infos.format = VR_RGB4;
    pBitmap->infos.bpp = 8;

    if(glColorTableEXT == NULL)
    goto convto15;

    picConvert(pPicInfos,CONVERT_TO_8);

    glColorTableEXT(GL_TEXTURE_2D,GL_RGB,16,GL_RGB,GL_ UNSIGNED_BYTE,pPicInfos->pPalette);

    glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX4_EXT,w ,h,0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,pPicInfos->pData);
    break;
    case BITMAP_8B:
    pBitmap->infos.format = VR_RGB8;
    pBitmap->infos.bpp = 8;

    if(glColorTableEXT == NULL)
    goto convto15;

    glDisable(GL_SHARED_TEXTURE_PALETTE_EXT);
    glColorTableEXT(GL_TEXTURE_2D,GL_RGB,256,GL_RGB,GL _UNSIGNED_BYTE,pPicInfos->pPalette);
    glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,w ,h,0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,pPicInfos->pData);
    break;
    case BITMAP_GRAYSCALE:
    pBitmap->infos.format = VR_GRAYSCALE;
    pBitmap->infos.bpp = 8;

    if(glColorTableEXT == NULL)
    goto convto15;

    glEnable(GL_SHARED_TEXTURE_PALETTE_EXT);
    if (!sharedPaletteLoaded){
    glColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT,GL_R GB,256,GL_RGB,GL_UNSIGNED_BYTE,pPicInfos->pPalette);
    sharedPaletteLoaded = VR_TRUE;

    }
    glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,w ,h,0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,pPicInfos->pData);
    break;


    hth

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: glColorTableExt for gray scale palette

    If all you're doing is grayscale, don't use palette at all. Instead, use GL_ALPHA or GL_LUMINANCE texture formats (and, probably, external formats).
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Posting Permissions

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