Almirante

07-31-2011, 05:00 PM

I was going through the reference pages of Open GL 4.1 on glPixelStore and do not quite agree/understand the way GL_PACK_ROW_LENGTH is defined.

Definition:

If greater than 0, GL_PACK_ROW_LENGTH defines the number of pixels in a row. If the first pixel of a row is placed at location p in memory, then the location of the first pixel of the next row is obtained by skipping k components or indices

where:

k = nl when s>=a

n = number of components per pixel

l = number of pixels per row

s = size in bytes of a single component

a = value of GL_PACK_ALIGNMENT (values are 1, 2, 4 or 8)

Not sure how the above formula works for the contrived example below:

Say a = 2 (2 byte alignement for rows)

Now for s = 3, n=3, l=3

k = nl = 9 i.e. 9 components are skipped to go the next row.

That should however correspond to 27 bytes (since s=3).

So how is the GL_PACK_ALIGNMENT requirement of 2 bytes enforced in this case? Seems to be violated.

I am probably not interpreting the definition correctly.

Thanks.

Definition:

If greater than 0, GL_PACK_ROW_LENGTH defines the number of pixels in a row. If the first pixel of a row is placed at location p in memory, then the location of the first pixel of the next row is obtained by skipping k components or indices

where:

k = nl when s>=a

n = number of components per pixel

l = number of pixels per row

s = size in bytes of a single component

a = value of GL_PACK_ALIGNMENT (values are 1, 2, 4 or 8)

Not sure how the above formula works for the contrived example below:

Say a = 2 (2 byte alignement for rows)

Now for s = 3, n=3, l=3

k = nl = 9 i.e. 9 components are skipped to go the next row.

That should however correspond to 27 bytes (since s=3).

So how is the GL_PACK_ALIGNMENT requirement of 2 bytes enforced in this case? Seems to be violated.

I am probably not interpreting the definition correctly.

Thanks.