views:

127

answers:

1

I'm trying to figure out how to specify a BGR 8 bit texture.

I've tried the following combinations (allowed), but all render with wrong colors:

  • Internal format: RGB; Format: RGB; Data Type: UNSIGNED_BYTE_3_3_2;
  • Internal format: RGB; Format: RGB; Data Type: UNSIGNED_BYTE_2_3_3_REV;

I've tried the following combinations, all with the INVALID_OPERATION error:

  • Internal format: RGB; Format: BGR; Data Type: UNSIGNED_BYTE_3_3_2;
  • Internal format: RGB; Format: BGR; Data Type: UNSIGNED_BYTE_2_3_3_REV;
  • Internal format: RGB; Format: BGR; Data Type: UNSIGNED_BYTE_3_3_2;
  • Internal format: RGB; Format: BGR; Data Type: UNSIGNED_BYTE_2_3_3_REV;

Other not working tries:

  • Internal format: R3_G3_B2; Format: RGB; Data Type: UNSIGNED_BYTE_3_3_2; (wrong color)
  • Internal format: R3_G3_B2; Format: RGB; Data Type: UNSIGNED_BYTE_2_3_3_REV; (wrong color)
  • Internal format: R3_G3_B2; Format: BGR; Data Type: UNSIGNED_BYTE_3_3_2; (invalid op)
  • Internal format: R3_G3_B2; Format: BGR; Data Type: UNSIGNED_BYTE_2_3_3_REV; (invalid op)

Is it possible to have a BGR format for a 8 bit color representation?

I think that "Internal format: RGB; Format: RGB; Data Type: UNSIGNED_BYTE_2_3_3_REV;" should work, but actually give the same (wrong) colors than "Internal format: RGB; Format: RGB; Data Type: UNSIGNED_BYTE_3_3_2;"... isn't it strange?


Edit:

The man page of glTexImage2D say:

GL_INVALID_OPERATION is generated if type is one of GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, or GL_UNSIGNED_SHORT_5_6_5_REV and format is not GL_RGB.

Indeed format should be GL_RGB. But so why GL_UNSIGNED_BYTE_2_3_3_REV doesn't give the correct result?

A: 

At least if I understand you correctly, what you want is:

Internal Format = GL_RGB, Format = GL_BGR, data type = GL_UNSIGNED_BYTE.

This specifies that it's in BGR order with an unsigned byte for each channel.

Jerry Coffin
Is this the combination for 24 bit BGR? I want store a 8 bit BGR.
Luca
Yes -- that was part of the "if I understand you correctly", which I clearly didn't.
Jerry Coffin