PDA

View Full Version : Bitmap Texture glPixelStorei Problem



Shari
08-20-2008, 06:36 PM
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!

arekkusu
08-20-2008, 09:45 PM
GL_UNPACK_ALIGNMENT
Specifies the alignment requirements for the start of each pixel
row in memory. The allowable values are 1 (byte-alignment), 2
(rows aligned to even-numbered bytes), 4 (word-alignment), and 8
(rows start on double-word boundaries).

overlay
08-20-2008, 09:45 PM
the valid values for GL_UNPACK_ALIGNMENT are 1,2,4,8.

See the spec 3.0 table 3.1 page 136 or spec 2.1 table 3.1 page 115.

The spec says "Setting a parameter to a value outside the given range results in the error INVALID_VALUE."

Shari
08-23-2008, 05:39 PM
Oops - okay, thank you. I think I had a "1" there before and was messing with it. With the 1, though I still get an error. The error is:



Traceback (most recent call last):
File "/home/shari/VisualizationBillboards/src/graphics/glWindows.py", line 54, in OnPaint
self.OnDraw()
File "/home/shari/VisualizationBillboards/src/graphics/glWindows.py", line 150, in OnDraw
self.DrawBillboard(x, y, z, textureFilename, textureCount)
File "/home/shari/VisualizationBillboards/src/graphics/glWindows.py", line 177, in DrawBillboard
self.textureId = self.LoadImage(filename, textureCount)
File "/home/shari/VisualizationBillboards/src/graphics/glWindows.py", line 258, in LoadImage
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
File "/usr/lib/python2.5/site-packages/OpenGL/error.py", line 194, in glCheckError
baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
err = 1282,
description = 'invalid operation',
baseOperation = glPixelStorei,
cArguments = (GL_UNPACK_ALIGNMENT, 1)


Does anyone have any ideas for that?

Thank you!
Shari