05-11-2004, 01:45 PM
I can't figure out how this is producing a magenta pixel (255,128,255 sampled from a screenshot) in corner of this 2 pixel texture.
glGenTextures(1, &arid[10]);
glBindTexture(GL_TEXTURE_2D, arid[10]);
unsigned char b2[2][2][3];
b2[0][0][0] = 255;
b2[0][0][1] = 255;
b2[0][0][2] = 255;
b2[0][1][0] = 255;
b2[0][1][1] = 255;
b2[0][1][2] = 255;
b2[1][0][0] = 255;
b2[1][0][1] = 255;
b2[1][0][2] = 255;
b2[1][1][0] = 255;
b2[1][1][1] = 255;
b2[1][1][2] = 255;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, b2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
I'm looking at the values set in the debugger and b2[0][0][0] to b[1][1][2] are set to 255. But I can see that the values 255,128,255 are stored in b[1][1][2] and what would be b[1][2][0] and b[1][2][1] if they part of the array. Have I done anything wrong here? I'm stumped.
glGenTextures(1, &arid[10]);
glBindTexture(GL_TEXTURE_2D, arid[10]);
unsigned char b2[2][2][3];
b2[0][0][0] = 255;
b2[0][0][1] = 255;
b2[0][0][2] = 255;
b2[0][1][0] = 255;
b2[0][1][1] = 255;
b2[0][1][2] = 255;
b2[1][0][0] = 255;
b2[1][0][1] = 255;
b2[1][0][2] = 255;
b2[1][1][0] = 255;
b2[1][1][1] = 255;
b2[1][1][2] = 255;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, b2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
I'm looking at the values set in the debugger and b2[0][0][0] to b[1][1][2] are set to 255. But I can see that the values 255,128,255 are stored in b[1][1][2] and what would be b[1][2][0] and b[1][2][1] if they part of the array. Have I done anything wrong here? I'm stumped.