[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Old pygame tutorial not working



On Aug 4, 2008, at 12:53 PM, Ian Mallett wrote:

Exactly, no. In OpenGL, surfaces must be made out of flat 2D polygons. To interpolate a single pixel, I think five steps would be minimally acceptable. That changes one quad into 25. My current heightmap is 257x257 pixels = 256x256 = 65,536 quads, but interpolation would put the number of quads at 1,638,400--from experience, I know that a 1025x1025 heightmap (1,048,576 polygons) runs unacceptably slowly. All this does not take into account the time it would take to do the interpolation calculation.

What type of interpolation? Linear interpolation between points would require no extra vertices.

You may need to implement some sort of variable LOD to get acceptable performance (farther things approximated using far fewer vertices).

You may also be able to achieve much better performance by reducing the detail expressed via vertices and using a normal map instead. You could also use normal mapping to simulate fancy non-linear interpolation between vertices without more polygons.

Speaking of time, even though the data is currently being prebuilt, it still takes an annoying amount of time to convert the height data into an OpenGL display list. I know that C can do it much faster. Anyone have any ideas for how it could be done faster in C? Note that the pointer to the heightdata (a standard array) must be read from Python to C, and the pointer to the display list must be passed back through the interface between the two languages.

How is the display list being built? You can optimize this much like other OpenGL drawing, using fewer calls is always better, but doubly so from Python. So try to use things like vertex arrays instead of immediate mode calls, etc.

I assume that by "passing pointers" you really mean copying/ transforming data. Just passing an array pointer back and forth has basically no cost, so try and arrange your data structures so that they don't need to be transformed to be used by different parts of the program, and in particular steer clear of doing those types of transforms in Python code wherever possible.

-Casey