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.

Close

#206 Wrong image size for glReadPixels()

closed-fixed
nobody
None
5
2009-07-19
2009-02-03
Andrew Straw
No

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/Core.py [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.

[1] http://visionegg.org/trac/browser/tags/release_1.1.2/VisionEgg/Core.py#L476

Discussion

  • Andrew Straw
    Andrew Straw
    2009-02-03

    failing test demonstrating the issue

     
    Attachments
    • 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.