On 21/01/11 06:58, David Griffiths wrote:
On Thu, 2011-01-20 at 22:26 +0100, Kassen wrote:
Yeah, I think that could be the problem.
The problem is lack of an alpha channel. It's skewed in that way as it's
expecting 4 bytes per pixel but it's getting 3.
[snip]
I suspect it's more subtle:
http://www.opengl.org/sdk/docs/man/xhtml/glPixelStore.xml
in particular: GL_UNPACK_ALIGNMENT
To be more explicit: pixels are contiguous in each row, but there might
need to be gaps between the rows in memory as each row needs to start
aligned to a certain number of bytes. With 4 channels (RGBA) this works
fine with the default alignment of 4, but with 3 channels you'd need a
multiple of 4 pixels in each row otherwise you'd get diagonal weirdness
(and potentially a buffer overflow crash).
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // potential fix
Similar alignment issues occur reading back from the GPU, with
corresponding GL_PACK_ALIGNMENT.
Claude