PDA

View Full Version : Odd-size images with gluBuild2DMipmaps



bakery2k
05-16-2002, 10:56 AM
I am loading in some odd sized (24bpp) bitmap files and trying to use them as textures in OpenGL.
For example, suppose I have an image 27 pixels wide. Because this is a .bmp file, it is padded with 3 zero bytes at the end of each line.
1)If I load in rows of 28 pixels wide, then pass this data to gluBuild2dMipmaps with a width of 28, I get what I expect, the correct texture with a black line down the right hand side.
2)If I pass this data to gluBuild2DMipmaps with a width of 27, the correct texture is drawn. glu seems to be ignoring the extra black pixel at the end of each line. It is not being drawn, as I would expect, at the beginning of the next line to cause the texture to slant, it is simply being ignored.
3)If I do not load the extra black pixels, but load rows of width 27, and then pass the data with a width of 27, the image appears slanted as though glu has ignored the last colored pixel on each line and is working with the first 26 pixels only.

Is this the correct behaviour? If so, I am going to find it harder to ignore the extra padding bits for all sizes of texture, unless this is always done for me (as in case 2).

Thanks for your suggestions.

bakery2k
05-16-2002, 11:48 AM
I've sorted it.
Due to the GL_PACK_ALIGNMENT setting, openGL was automatically ignoring the padding bytes. It was fine as it was!