The OpenGL image format parameters are quite confusing. My possibly
incorrect understanding is that the format (eg GL_RGBA) specifies the
order of the components and the type (eg GL_UNSIGNED_BYTE) specifies
whether that means the order in memory or the order of the bits within a
larger native type.

The types without numbers assign the whole type to a single component
and the components are packed in increasing memory order - so yes
GL_RGBA and GL_UNSIGNED_BYTE should give the regular RGBA format with
the red component in the lowest address and the green component in the
next address etc.

The types with numbers pack all the components into a single number in
order from most significant bit to least significant. So on
little-endian I think you can get ARGB format with GL_BGRA and
GL_UNSIGNED_INT_8_8_8_8. The A component is last so it ends up in the
least significant byte which is the first byte for little-endian giving
ARGB.

However if you're using Cogl you can just call cogl_read_pixels with the
type as COGL_PIXEL_FORMAT_ARGB_8888 and this will work on either
endian-ness. For Cogl, the types always specify the component order in
increasing memory addresses except for the 16-bit types. Confusing,
isn't it? :)

- Neil

Mustafizur Rahaman <[email protected]> writes:

> Hi,
>
> I am facing some problem when I am reading data from OpenGL using
> glReadPixels (0, 0, pixmap_width, pixmap_height, GL_RGBA,
> GL_UNSIGNED_BYTE, fbp_original) [fbp_original is a char array[4]]
>
> Then I am trying to pass this data to Xserver using ARGB format.
>
> Now, my question is when I am saying GL_RGBA format in byte array,
> what does it actually mean? Is the R component be put into the LSB or
> onto the MSB irrespective of the endianness of the system? From the
> clutter_do_pick logic, i understand the R component is put into
> pixel[0], but somehow i got confused there. Can any one please help?
>
> Regs,
> Mustaf
-- 
To unsubscribe send a mail to [email protected]

Reply via email to