Here's a primitive 5x2 texture defined in RGB and RGBA formats.
unsigned char rgb[] = { 0, 0, 0, 0, 0, 0, 200, 200, 200, 0, 0, 0, 200, 200, 200,
0, 0, 0, 0, 0, 0, 200, 200, 200, 0, 0, 0, 200, 200, 200, };
unsigned char rgba[] = { 0, 0, 0, 255, 0, 0, 0, 255, 200, 200, 200, 255, 0, 0, 0, 255, 200, 200, 200, 255,
0, 0, 0, 255, 0, 0, 0, 255, 200, 200, 200, 255, 0, 0, 0, 255, 200, 200, 200, 255, };
Downloading the RGBA version works as expected:
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB,
5,
2,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
rgba);

Loading an RGB texture results in a strange color shift:
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB,
5,
2,
0,
GL_RGB,
GL_UNSIGNED_BYTE,
rgb);

The difference in code between the first and second screenshots are just two arguments to glTexImage2D.
What am I doing wrong?
Environment
- ATI Radeon HD5450, OpenGL 4.2
- Windows 7 64-bit
- Visual studio 2010