Re: 16-bit vs. 24-bit texels for pfTex->setImage()

New Message Reply Date view Thread view Subject view Author view

Angus Dorbie (dorbie++at++bitch.reading.sgi.com)
Mon, 17 Mar 1997 05:21:09 +0000


There's a big difference between the internal format and the data you need
to supply the gl. Generally the gl does all the conversion for you so yes
you pick an internal format but you also need to create an appropriate
array of information to match the data format the gl expects.

PFTEX_EXTERNAL_FORMAT, PFTEX_PACK_8

is what is supported by default and you certainly won't need more for
what you are doing, just supply an array of 8 bit packed data in the image
array and let the graphic system do the work. This api smacks of IrisGL
with it's use of the external format token.

There days OpenGL on the Infinite Reality supports packed external
image data like GL_UNSIGNED_SHORT_5_5_5_1_EXT, but I don't know if
these tokens would work through Performer, it'd be worth a try if
you _really_ want to keep your 5 bpc host copy, but it's much simpler
to send the 8 bit per component image and let the machine do the
conversion work for you.

Cheers,Angus.

On Mar 16, 3:15pm, Daniel E. Small wrote:
> Subject: 16-bit vs. 24-bit texels for pfTex->setImage()
> Hello Performers,
>
> Newbie questions continued.
>
> I a bunch of texture data from video that I need to map. I would like
> to conserver memory, so I want to take the 24 bit data and reduce it to
> 16, and scale the image down by 1/2, ending up with a 320x240 16bit
> image. (I know they are not powers of 2 but I have some complex video
> calibration issues that I have to deal with before attempting that piece
> of optimization).
>
>
> I convert each texel component to 5 bits and shift them in the following
> manner:
>
> r,g&b are ushort arrays.
>
> unsigned short tr;
> unsigned short tg;
> unsigned short tb;
> unsigned short dest;
>
> tr = ((r[i]&0x00f8)>>3);
> tg = ((g[i]&0x00f8)<<2);
> tb = ((b[i]&0x00f8)<<7);
>
> dest = tr | tg | tb;
>
> I am 'assuming' that the bit ordering is (from lowest to highest) 5 bits
> red, 5 bits green, 5 bits blue, and 1 bit alpha. Please enlighten me if
> I am in error.
>
> I know the data is good because I am able to use this method to create a
> texture of 32 bits in the same method; by shifting green by 8 and blue
> by 24 and or'ing the 3 components. I am scaling down hthe 24 bit image
> and it looks fine.
>
>
> Using the above method, I step thru the original image data and create a
> new image of 16bit texels.
>
> I then use setImage in the following way:
>
> tex = new(arena) pfTexture;
>
> tex->setFormat(PFTEX_INTERNAL_FORMAT,PFTEX_RGB_5);
>
> where imgPtr is the 16bit data.
>
> tex->setImage((uint *)imgPtr,2,320,240,1);
>
> tex->setRepeat(PFTEX_WRAP,PFTEX_CLAMP);
>
> The texture does appear when it is downloaded, but it has no red or
> green components, just blue.
>
> I am wondering if there is another mode I need to set that I am missing,
> or if I have made some newbie mistake.
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:54 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.