Re: [PyOpenGL-Users] Problems with glReadPixels
Brought to you by:
mcfletch
From: Dirk R. <di...@li...> - 2007-06-29 20:14:17
|
Hi Mike, thanks for the quick response. Mike C. Fletcher wrote: > > I don't have any code that uses the un-decorated version. > glReadPixelsub seems to work fine (at least, the > OpenGLContext/tests/saveimage.py test works fine on my CVS-based version > of PyOpenGL). That's on an AMD64 Gentoo machine. Code looks identical > for the two versions of the function (other than a type being specified > by default). > > If you have failing code I could pdb through it might be easier to track > down the issue. One other thing, what versions of ctypes and numpy are > you using? Gah! As it turns out Qt doesn't export the event's position as variables but as accessors, so the event.x and event.y that we passed in ReadPixels were functions, not positions. Fixing that fixed the error. Not exactly an intuitive failure mode, but that's Python for you. ;) But now I have some other questions concerning glReadPixels: I'm a little confused about the return types. Adding the following to cube.py:display data = glReadPixelsub(0, 0, 1, 1, GL_RGB) print data, type(data[0][0][0]) data = glReadPixelsb(0, 0, 1, 1, GL_RGB) print data, type(data[0][0][0]) data = glReadPixelsui(0, 0, 1, 1, GL_RGB) print data, type(data[0][0]) data = glReadPixelsi(0, 0, 1, 1, GL_RGB) print data, type(data[0][0]) data = glReadPixelsf(0, 0, 1, 1, GL_RGB) print data, type(data[0][0]) gives me [[[0 0 0]]] <type 'numpy.int8'> [[[0 0 0]]] <type 'numpy.int8'> [[0]] <type 'numpy.int32'> [[0]] <type 'numpy.int32'> [[ 0.]] <type 'numpy.float32'> Why do I get signed integers in each case? I would have expected unsigneds for the ub/ui cases. Why do I get only a 2D array for the i/ui/f cases? I would have expected the usual RGB triple. None of these are showstoppers, but they surprised me a bit. Thanks Dirk P.S.: Can you please close our bug? No clue why it showed up 5 times. |