I’m trying to use a texture from a bitmap image. My code for loading the bitmap into a texture is below. When I run it, I ges the following error:
File "/home/shari/VisualizationBillboards/src/graphics/glWindows.py", line 258, in LoadImage
glPixelStorei(GL_UNPACK_ALIGNMENT, 0)
File "/usr/lib/python2.5/site-packages/OpenGL/error.py", line 194, in glCheckError
baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
err = 1281,
description = 'invalid value',
baseOperation = glPixelStorei,
cArguments = (GL_UNPACK_ALIGNMENT, 0)
)
And here is my code:
textureImageFile = None
textureImageFile = open(filename, 'r')
if textureImageFile:
textureImageFile.close()
im = Image.open(filename)
# The images are mirrored, so flip it so they look the same
#im = im.transpose(Image.FLIP_LEFT_RIGHT)
try:
ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0, -1)
except SystemError:
ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBX", 0, -1)
else:
print "ERROR - Image File not found"
glPixelStorei(GL_UNPACK_ALIGNMENT, 0)
glTexImage2D(GL_TEXTURE_2D, 0, 3, ix, iy, 0, GL_RGBA, GL_UNSIGNED_BYTE, image)
Any help in figuring out what is causing the error would be appreciated! Thank you!