yj1214,
Post by yj1214Now i'm little confused...
According to these posts,
[snip]
And rightly so.
What you see there is a problem where a row of elements (pixels) does not
need to be a multiple of the required alignment. Just think of 24-bit (3
byte) pixels. If you just put the first pixel of the second line directly
behind the last pixel of the first line it might not start on an alignment
boundary. In such cases the video card may require (to speed up
processing) every line of pixels being started on an alignment boundary
(padding the previous line of pixels to become a multiple of the alignment).
Actually, if you take a look at the BMP file format, thats exactly how an
image is stored in it (a single line of pixels is padded to become a
multiple of the alignment, in this case 4 bytes). :-)
Post by yj1214I think this illustrates your explanation of how alignment works,
[Snip]
Post by yj1214Am I not correct? i'm really confused about how alignment works...
Well, although that wasn't exactly what I ment (I was thinking about the
alignment of a full block of data/pixels, not its individual elements), I
can imagine that a per-pixel alignment could be possible/required somewhere
too (it could speed up the provcessing). It all depends on how the data is
used (which functions are going to use the stored data/how its provided to
the video-card).
In short, an alignment is a requirement of called functions, and below that
of the hardware under it (the video-card or other). There is therefore no
strictly defined rule about when to use an alignment, and which alignment is
needed.
Regards,
Rudy Wieser
Post by yj1214Post by R.WieserThe alignment has got nothing to do with the number of elements/bytes in a
row, but everything with the size of a single element.
Now i'm little confused...
According to these posts,
http://stackoverflow.com/questions/11042027/glpixelstoreigl-unpack-alignment
-1-disadvantages
Post by yj1214http://www.felixgers.de/teaching/jogl/imageStorageMode.html
https://www.opengl.org/discussion_boards/showthread.php/197557-What-does-glP
ixelStore()-do?p=1279209#post1279209
Post by yj1214It says alignment works with row, not with elements...
From OpenGL post,
****************************************************************************
***************************************************
Post by yj1214Suppose 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.
Post by yj1214If GL_UNPACK_ALIGNMENT is 4, and you try to upload the texture data with
glTexImage2D(), the implementation will round the length of each row up to
the next multiple of 4 (i.e. 372 bytes).
****************************************************************************
***************************************************
Post by yj1214It says alignment will round up each row's length(byte) depends on
GL_UNPACK_ALIGNMENT number. It didn't say it will round up each element's
length...
Post by yj1214I think this illustrates your explanation of how alignment works,
Let's say each pixel has value of RGB. So each pixel has 3 bytes.
GL_UNPACK_ALIGNMENT, 4;
<address- 1><address- 2><address- 3><address-4><address- 5><address-
6><address- 7><address- 8>
<myPixel-R><myPixel-G><myPixel-B><alignment><nextPixel-R><nextPixel-G><nextP
ixel-B><alignment>
Post by yj1214This illustrates explanation of alignment from different posts.
GL_UNPACK_ALIGNMENT, 4;
<address- 1><address- 2><address- 3><address-4><address- 5><address-
6><address- 7><address- 8>
<myPixel-R><myPixel-G><myPixel-B><nextPixel-R><nextPixel-G><nextPixel-B><ali
gnment><alignment>
Post by yj1214Am I not correct? i'm really confused about how alignment works...
Again thanks for the help!
--
http://narkive.com/GRey4bF6.10