I have searched online for about 3 days now but i’m still not getting the concept of how GL_(UN)PACK_ALIGNMENT works.
Let’s say I have 2 pixel row that is 7 pixels long each.
Each pixel is consist of 3 bytes. (GL_RGB)
(I think) The right alignment setting for this particular situation is,
(Please correct me if i’m wrong.)
Now here’s what I think OpenGL would do,
[pixel-1-R][pixel-1-G][pixel-1-B][ padding ][pixel-2-R][pixel-2-G][pixel-2-B]…
Because each pixel is 3 bytes long each, I think OpenGL would put pad every fourth address.
From OpenGL official forum,
Suppose that you have texture data with GL_RGB format (3 bytes per component) and a width of 123, with no padding between rows (i.e. the first byte of the first pixel of one row immediately follows the last byte of the last pixel of the previous row). The stride between rows will be 3*123 = 369 bytes. Note that 369 is not a multiple of 2 or 4.
Why does row length matter? I thought alignment works with each single pixels, not each rows. Or am I wrong?