hi all,
i got a problem loading and displaying a texture in OpenGL, using python (pyOpenGL)
the texture shows up, but it looks like garbage data. ive made a test texture, a 2x2 red/black checkerboard BMP
| red black |
| black red |
my code looks like this
image = Image.open(filename)
image = frombuffer(image.tostring(), ubyte)
print image
glBindTexture (GL_TEXTURE_2D, id);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
the print statement produces:
[255 0 0 0 0 0 0 0 0 255 0 0]
the result on screen is a quad with 4 different colored areas (non of them either red or black, both red/black pixels arent even the same color)
should i give the data in a different format, like as a 2x2x3 matrix? ive played around with and searched the forum, but i just can't get it right
any help on how you usually do this is greatly appreciated, some python specific advice ever more...
thanks :)
[Edited by - UeberBobo on December 15, 2006 1:19:37 AM]