Re: [PyOpenGL-Users] Pyopengl - slow performance using
Brought to you by:
mcfletch
From: Chris B. <Chr...@no...> - 2011-01-13 22:49:13
|
On 1/13/2011 3:29 AM, pm...@gm... wrote: > I am developing an application using pyopenGL to read data from a shape file and to draw it in 2D using openGl. However, the performance is really bad; it takes up to 20 seconds to draw the map. I am using Ubuntu and nVidia NVS 3100M. You may be interested in this: https://bitbucket.org/dhelfman/maproom/wiki/Home It aims to be a general purpose map viewer/manipulator library for custom mapping applications, written in Python, with PyOpenGL, and some Cython for performance bottlenecks. We don't have shapefile line segment support yet, but the pieces are all there, so it wouldn't be hard to add, and we've addressed your performance issues. How far are you going with this? Maybe an opportunity for collaboration? On 1/13/2011 3:50 AM, Alejandro Segovia wrote: > I find it puzzling that you didn't notice any speedup at all after > doing this. Python lists are just linked lists, no, they are not -- they are internally regular C arrays. > which means they are > probably not consecutive in memory, but rather, they have to be > converted to an array at each call to drawArrays. however, they are arrays of pointers to PyObjects, so you are right, each pyObject needs to be converted, and that can be slow, you don't want to do that with each pain event. On 1/13/2011 3:56 AM, Jonathan Hartley wrote: > Personally I highly recommend using RunSnakeRun to > draw diagrams from the output of stdlib cProfile. cool! thanks, I hadn't see that before -- looks really useful. > I'd guess that part (a) of the code, constructing the arrays, is > probably pretty expensive, since you are processing every individual > vertex. Importantly, this code should only need to be run at application > start-up, not every frame, is this correct? or at data loading. MapRoom is a bit pokey when you load a large data set, but then the drawing is plenty fast. > I can see that the value of objMap represents a vertex array, but how > many vertices are generally in it? You may find substantial acceleration > from increasing the number of vertices in an array, Yup -- I think this is your proplem -- you won't want to have to draw each line segment separately -- I'll bet you have a lot. As a rule, if you have much looping in Python in side your drawing code, it's going to be slow. > the number of times this loop needs to iterate. In order to do this, you > will need to put the arrays for several roads into a single array. yup -- I *think* you can put NaNs in between segments to create a gap and do a bunch with one line drawing call. or, if you know which segments are connected, you ca re-join them, essentially. HTH, -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |