Re: [PyOpenGL-Users] Pointer functions copying memory.
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-02-03 17:39:39
|
The biggest problem I see is that the buffer API is loosely considered deprecated. BTW I could've sworn that we were already using the PyArray_ functions to get contiguous array pointers... See the NUMERIC_PyObject_As macro in interface_util.c, as far as I'm aware, this should be getting used everywhere. However, if I understand the mechanism behind the (PyArrayObject*)PyArray_ContiguousFromObject(source, TYPECODE | SAVESPACEBIT, 0, 0); function, it's going to do a copy of the source array is not contiguous, which would give us the copying overhead we're seeing. What I would prefer to see (instead of using a pseudo-deprecated API, or using functions to access the non-contiguous array (which likely won't work for OpenGL, as I believe it requires a true contiguous array)) is a function that, given a Numeric array, returns a contiguous version of that array to Python (or raises a memory error if it's not possible). That should, if I understand correctly, make further PyArray_ContiguousFromObject calls on the _resulting_ array null operations. The "problem" being that the current code doesn't modify the Python pointer to the array to point to the new, contiguous array (and obviously it shouldn't do so in the middle of an OpenGL call), so the effort isn't saved between rendering passes. Just my thoughts, Mike Rene Dudfield wrote: >Hi, > >I had a look at the pointer functions and it appears >they copy memory before passing it to the gl function, >making them quite slow. > >I was thinking of using the buffer api instead. > >http://python.org/doc/current/api/bufferObjects.html > >Not sure if numeric supports it. If it doesn't I'll >use the PyArray_ContiguousFromObject functions. > > >Any thoughts on this? Any compatibility problems with >the buffer api? > > > ... _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |