Login  Register

Re: Strange phenomenon about glDrawPixels, Any one can help me ?

Posted by elect on Sep 14, 2015; 8:17am
URL: https://forum.jogamp.org/Strange-phenomenon-about-glDrawPixels-Any-one-can-help-me-tp4035033p4035285.html

Little update, I came across this issue recently for a glTexImage3D

The same logic applies, but it is interesting to know how it works in 3 dimensions.

Supposing we have x, y and z where in general

- x is the layer (for texture arrays)

- y is the face (for cubemap textures)

- z is the level (for mipmaps)

Data will be loaded starting from the xy plane, row by row. So if we have a 4-bytes alignment, x must be aligned to this value and it must be so up to the end. This for all the xy planes on z, except the very last row on the last z.

Examples:

(3, 2, 2) requires 4 bytes for row, this means 4 bytes for the first three rows:

- ([0-3], 0, 0)

- ([0-3], 1, 0)

- ([0-3], 0, 1)

except the last one, ([0-3], 1, 1), that needs only 3

The count is 3*4+3 = 15 Bytes..

So what counts about alignment is always and only the size of the first dimension, except the last row

Let's say this is the complex way of dealing with it. The easy fix is to switch the unpack alignment to 1 byte and forget about it :D