Small RGB texture in openGL all white

Alec Jacobson

May 21, 2012

weblog/

I was trying to load a small 2 pixel by 2 pixel in opengl and damned if it didn't keep coming out all white. My mistake was storing the texture as RGB (3 floats per pixel) and not setting:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
since opengl expects alignment of 4 (which would be fine for RGBA for example).