Re: Format of New glReadPixels

"Mike C. Fletcher" <[email protected]> Mon, 08 Jul 2013 10:24:40 -0400
Newsgroups gmane.comp.python.opengl.user
Message-ID <[email protected]>
On 13-07-07 06:56 PM, Ian Mallett wrote:
> On Fri, Jul 5, 2013 at 2:03 PM, Mike C. Fletcher 
> <[email protected] <mailto:[email protected]>> wrote:
>
>     > What is the return value format of glReadPixels?
>     Apparently ctypes arrays no longer have .raw attributes, so if you
>     don't
>     have numpy the object wasn't being converted to a string. Weird
>     thing is
>     I don't see any documentation on .raw on arrays, so it's possible
>     it was
>     just working by fluke-of-implementation before.  I've added code that
>     does the transformation of a ctypes array to the OpenGL/images.py
>     module
>     in bzr.
>
> This, I assume: 
> http://bazaar.launchpad.net/~mcfletch/pyopengl/trunk/revision/576 
> <http://bazaar.launchpad.net/%7Emcfletch/pyopengl/trunk/revision/576>
>
> Oddly, I theoretically do have NumPy, although my Python setup has 
> probably munged itself over several reinstalls.
>
> Is there a workaround available for current implementations?
You can pass the array in explicitly (param array), then convert it on 
output (.tostring() for numpy).  If you have numpy installed and the 
code isn't picking it up, then we have another failure case :( .  You 
could also just copy the wrapper function from bzr into your code, it's 
just a regular python function wrapper; however, if you have numpy, then 
it should have picked that up as your default output array format 
(generic preferences are numpy, numeric, ctypesarrays, and since *noone* 
has Numeric any more, that's just numpy or ctypes arrays).

You can *explicitly* set your preferred handler with 
OpenGL.arrays.arraydatatype.ArrayDatatype.registerReturn( 'numpy' ), but 
since that's the default anyway, it *shouldn't* make a difference, and 
it will still try the others if it can't find your preferred format.

My guess is that numpy isn't importable/usable, and you fell through to 
the ctypes arrays. If not, we need to spelunk.

HTH,
Mike

-- 
________________________________________________
   Mike C. Fletcher
   Designer, VR Plumber, Coder
   http://www.vrplumber.com
   http://blog.vrplumber.com


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net