Bug found in glReadPixels
Geert Henk Visser <[email protected]> Wed, 6 Apr 2016 12:13:14 +0200
| Newsgroups | gmane.comp.python.opengl.devel |
|---|---|
| Message-ID | <CADP4gbCkROLQaUKiYFaQcBcP=d+7xuP_t_6_ouTczWDzB8tSaQ@mail.gmail.com> |
Hey guys, Just wanted to report a bug I found in glReadPixels which has caused me major annoyance yesterday. glReadPixels returns a numpy array with a specific datatype. I found out that the shape parameter given to this array has the rows and columns switched. This will not be a problem for most users, as the flattened array will be interpreted correctly. If one however does some operations on it, like transposes or left right swapping, this results in a corrupted image. For me there was an easy workaround by using: data = data.reshape((data.shape[1],data.shape[0])) However, it would be nice if this was fixed in future versions. It can be fixed in multiple points of the source code, like this line in OpenGL/GL/images.py: array = imageData = images.SetupPixelRead( format, (width,height), type ) Only width and height need to be swapped for it to work. I tested this on both a windows and a linux distribution but would like someone else to test it as well to rule out any stupidity. I believe the cause of the bug is the way OpenGL presents the array data is not consistent with the standard way numpy expects it. Kind regards, Geert Henk Visser ------------------------------------------------------------------------------ _______________________________________________ PyOpenGL Homepage http://pyopengl.sourceforge.net