# Very few colours with alpha channel textures

**URL:** <https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132>\
**Category:** PowerVR Insider\
**Tags:** pvrtextool\
**Created:** [August 29, 2008, 2:48pm UTC](https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132 "2008-08-29T14:48:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thm](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thm](https://forums.imgtec.com/u/thm)\
**Post date:** [August 29, 2008, 2:48pm UTC](https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132/1 "2008-08-29T14:48:33Z")

</div>

Hi, it’s me again. ![Smile](https://www.imgtec.com/forum/smileys/smiley1.gif)

&nbsp;
  

I have a general problem when using textures with an alpha channel (GL\_RGBA).
  

&nbsp;
  

When using textures&nbsp; **without** alpha (GL\_RGB), it seems that these are internally stored (or at least displayed) with a&nbsp;color depth of&nbsp;16 bit (RGB565 or RGB555). This is just a guess due to my perception of the resulting image (I can see some seams but not too many).
  

&nbsp;
  

Now, when adding an alpha channel to the source image and loading it into OpenGL-ES (with GL\_RGBA), the color depth is extremely bad. My suspicion is that the alpha texture is internally stored (or at least displayed) with 16 bit. That should be the same as with GL\_RGB but now it has to store the alpha channel, too. Thus&nbsp;it may be that RGBA4444 is used, which results in 12 Bit for the colour which means we only have 4096 colours left to display...
  

&nbsp;
  

In PC emulation everything works fine, I have a seamless colour transition. This problem only happens on the embedded device.
  

Also if using one texture with alpha channel and one without in the same scene, only the texture with alpha channel has&nbsp;few colours.
  

Furthermore it does not depend on the OpenGL-settings nor the states (GL\_BLEND can be disabled, too, it doesn't matter).
  

It can be reproduced by using the "08\_AlphaBlend"-TrainingCourse project&nbsp;from the OGLES-1.1\_WINDOWS\_PCEMULATION\_2.02.22.0756 - SDK. Just disable the blending (otherwise it is not easily noticable) and you'll find the red dots displayed with very&nbsp;few colours.
  

It's even more obvious if replacing the background texture with an image which has nice colour-fadings (and an alpha channel which is always set at being opaque).
  

&nbsp;
  

Is this problem known? Does it maybe depend on the driver or the hardware? Is there a solution?
  

&nbsp;
  

Best regards,
  

Thomas
ThM2008-09-01 13:13:05

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [September 1, 2008, 8:30am UTC](https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132/2 "2008-09-01T08:30:52Z")

</div>

Hi Thomas,  
  
  
  
  
  
Which device are you working on? What is the colour depth of your EGL window surface?

---

<div class="post-metadata">

**Author:** ![thm](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thm](https://forums.imgtec.com/u/thm)\
**Post date:** [September 1, 2008, 10:21am UTC](https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132/3 "2008-09-01T10:21:48Z")

</div>

Hi,

&nbsp;
  

my device is a Freescale IMX31 board with a PowerVR MBX Chip.
  

&nbsp;
  

I didn't modify the TrainingCourse project,&nbsp;but the maximum possible&nbsp;colour depth on the device&nbsp;seems to be 565 = 16 bits.
  

&nbsp;
  

If I try it like this:
  

conflist[i++] = EGL\_RED\_SIZE;
  

conflist[i++] = 5;
  

conflist[i++] = EGL\_GREEN\_SIZE;
  

conflist[i++] = 6;
  

conflist[i++] = EGL\_BLUE\_SIZE;
  

conflist[i++] = 5;
  

&nbsp;
  

and if I then ask for the values like this:
  

glGetIntegerv(GL\_RED\_BITS, &value);  

glGetIntegerv(GL\_GREEN\_BITS, &value);  

glGetIntegerv(GL\_BLUE\_BITS, &value);
  

glGetIntegerv(GL\_ALPHA\_BITS, &value);
  

&nbsp;
  

I get 565 and an alpha size of 0 (but alpha is not needed for the display buffer I guess). Nevertheless, the result looks like 444. It looks definitely not like 16 bits used&nbsp;for colour only.
  

It looks exactly the same as when I save the picture with your PVRTexTool in the format&nbsp;ARGB4444.
  

&nbsp;
  

And if I just change the image to a non-alpha-channel image (no other change at all in the code), the result looks fine. glGet still&nbsp;gives a colour depth of 565 and 0 for alpha.

ThM2008-09-01 12:24:45

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [September 4, 2008, 2:16pm UTC](https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132/4 "2008-09-04T14:16:56Z")

</div>

Could you check if the device supports the GL\_IMG\_texture\_format\_BGRA8888 extension? This extension defines a new token, GL\_BGRA (0x80E1), for texture data in BGRA order. You can use this to get 32-bit textures.

Code:

#ifndef GL\_BGRA  
#define GL\_BGRA 0x80E1  
#endif  
  
// convert data to BGRA here  
  
glTexImage2D(GL\_TEXTURE\_2D, 0, GL\_BGRA, width, height, 0, GL\_BGRA, GL\_UNSIGNED\_BYTE, data);

  
  
  
Alternatively, have you tried using PVRTC compressed textures?

---

<div class="post-metadata">

**Author:** ![thm](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thm](https://forums.imgtec.com/u/thm)\
**Post date:** [September 5, 2008, 7:55am UTC](https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132/5 "2008-09-05T07:55:05Z")

</div>

Thank you very much, Xmas! BGRA works on my device&nbsp;with 32 bits. ![Smile](https://www.imgtec.com/forum/smileys/smiley1.gif)

  

One question is left in my brain: Is there no other way to use 32 bit textures on this device?
  

I think it's strange that I pass 32 bits to OpenGL-ES but the textures are only displayed with 16 bits although the device is able to process 32 bits and to display it with this extension.
  

Shouldn't thus GL\_RGBA support 32 bits, too?
  

&nbsp;
  

I found the exactly same question here with the same&nbsp;- good - &nbsp;answer: [http://www.khronos.org/message\_boards/viewtopic.php?f=4&p=3435](http://www.khronos.org/message_boards/viewtopic.php?f=4&p=3435)
ThM2008-09-05 09:55:33

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [September 30, 2008, 9:11am UTC](https://forums.imgtec.com/t/very-few-colours-with-alpha-channel-textures/132/6 "2008-09-30T09:11:17Z")

</div>

ThM wrote:

One question is left in my brain: Is there no other way to use 32 bit textures on this device?

  
No, when the framebuffer config is 16 bit you need to use the BGRA extension to get 32 bit textures on this device.
