Bad 24 bit textures

If I specify a 24 bit texture (or mip) whose size is less than 32 bytes I get a bad texture (very odd colours mixed with correct ones).
This does not happen with 4, 8, 16, 32bit and DXTC images.
I’ve only found this today and tested it only on an FX and a software implementation, both behave identically.
I’ve tried different images and looked for other potential errors but there’s nothing to be found. I’ve manually examined the image data and it’s correct.

Anyone ever encountered this? What could it possibly be?

Check out the pixelstore alignment defaults, my guess is you’re not taking into account that the default alignment is four bytes. Look here .

Right you are! I had commented out the code that sets the alignment and completely forgot about it.


Hey, I also used 24bpp textures and I never experienced the problem however, I am somewhat interested in understanding this, in the case it hits me.

Someone can tell how it looks exactly? I never used the pack/unpack mechanism but my textures always looked ok.

Are you familiar with how windows bitmap scanlines are dword aligned? Same thing. When GL_PACK_ALIGNMENT isn’t 1 every scanline is padded with junk at the end to bring the next onto the specified boundary.