PDA

View Full Version : Confusion on image formats



Triple Indy
04-15-2016, 01:09 PM
From www.opengl.org/wiki (https://www.opengl.org/wiki/Image_Format#Required_formats) :


The implementation is forbidden to lose information from these formats. So, while an implementation may choose to turn GL_RGB4 into GL_R3_G3_B2 (...)

...but why ?

AFAIK, GL_RGB4 means:
Red = 4 bits
Green = 4 bits
Blue = 4 bits

...and GL_R3_G3_B2 obviously means:
Red = 3 bits
Green = 3 bits
Blue = 2 bits


So why is this allowed ? How can you store 4 bits into 3 bits without loosing information ?

It seems so obvious but i cant figure it out.

mhagain
04-15-2016, 05:30 PM
The wiki isn't formal documentation; don't treat it as such. So it's capable of containing mistakes, and in this case it just looks as though the conversion is the wrong way around: it was probably intended to be "GL_R3_G3_B2 into GL_RGB4".

Alfonse Reinheart
04-15-2016, 05:39 PM
How can you store 4 bits into 3 bits without loosing information ?

You can't. That is in fact the whole point of the statement: if you are not using one of the required formats, the implementation is allowed to give you less precision than you asked for.


in this case it just looks as though the conversion is the wrong way around: it was probably intended to be "GL_R3_G3_B2 into GL_RGB4".

No, it's intended to be exactly what the specification says. It says that, outside of the required formats, an implementation is allowed to do whatever it wants with your internal format. If it chooses to use a 3/3/2 format when you asked for 4-bits per channel, there is not one thing in the specification that will prevent it.

Triple Indy
04-15-2016, 08:35 PM
Of course !

GL_RGB4 is not a required format that's why !

Thank you Alfonse !

I cant believe i couldn't figure this out it was right in the table below too x(