Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#206 Wrong image size for glReadPixels()

Andrew Straw

I've been tracking down an error with the Vision Egg and PyOpenGL 3. (This code works fine with PyOpenGL 2.) The code that led me to this issue is line 476 of VisionEgg/ [1], which is a call to glReadPixels(). Basically, doing glReadPixels with a format of GL_BGRA and type of GL_UNSIGNED_INT_8_8_8_8_REV returns an NxMx4 array of type uint32. I think this should either be an NxM(x1) array of type uint32 or an NxMx4 array of type uint8.

The code at issue seems to be in OpenGL.images.createTargetArray(). It is responsible for creating the mis-sized array. I hesitate to suggest a patch, since I'm not sure what the optimal solution is, but this is at least a change of behavior since PyOpenGL 2.

I am including a test which hopefully clarifies my thinking about the proper size of the array.



  • Andrew Straw
    Andrew Straw

    failing test demonstrating the issue

    • status: open --> closed-fixed
  • Hi Andrew, thanks for the bug report, and particularly for the test case. I've added a table to the OpenGL.images module which enumerates the packed image types and overrides the calculation for their case, as well as checking that the format can hold the number of components specified (at least). bzr head has the fix.