Re: [PyOpenGL-Users] 2d sprite engine performance.
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2005-04-07 00:31:14
|
le...@st... wrote: ... >on a number of medium-old machines including my PowerBook G4. As Mike >says, it's critical to build the array once; then just poke your updated X >and Y value into it and then call .tostring() and glDrawArrays each frame. > > ... Just a minor performance hint: using tostring() is likely going to be slower than passing in the Numpy array directly to the appropriate function. If the array is a contiguous array of the correct datatype PyOpenGL can save a full-data-copy operation for the array. You can make an array contiguous by doing: myarray = contiguous( myarray ) Most arrays are already contiguous, btw, it's just resizes and the like that create non-contiguous arrays... The tostring method, by comparison always has to do the copy, since tostring is creating a copy of the array data in the Python string (and then throwing it away when finished). String-based array functions should likely be the method-of-last-resort for any performance-critical code. Have fun, Mike ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |