gluScaleImage appears to be corrupting my data

I’m tracking down a problem when I build mipmaps with gluBuild2DMipmaps.

I’ve isolated the problem to gluScaleImage (as you know gluBuild2DMipmaps calls gluScaleImage when the width or the height is non power of 2). My image is being damaged when I try to reduce it. I even tried requesting the original size from the routine, and it still damages the image!

The call looks like this:
int err = gluScaleImage(GL_RGB, 146, 84, GL_UNSIGNED_BYTE, img, 146, 84, GL_UNSIGNED_BYTE, (void *)newImg);

produces an image with a discolored line starting in the second row, and an x position of zero. It continues diagnally down the image towards the bottom. It almost looks like a classic alignment or pixel storage problem, but I’ve played around with glPixelStorei a little but to no avail. I’ve got ample storage for my destination image so I know its not blowing out of storage. And the maddening thing is it almost works – the image is almost perfect, leading me to believe there is some subtle problem.

Has anyone had a problem with gluScaleImage? It seems like I’m doing a fairly common operation here.

On my vaudoo2 with standard OpenGL & GLU drivers, i have a problem with textures using mipmapping. It looks like the last levels of gluBuild2dMipmaps are incorrectly built ( and i’m using standard RGB 256x256 textures ). Since gluBuild2dMipmaps is using gluScaleImage, i think my problem is related to yours.

Do not use gluScaleImage… code your own


Maybe that’s alignment?
I remember I was killing such bug for few days.
Try rgba format or use image with x*4 dimensions to check it.