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

Re: [pygame] Old pygame tutorial not working




>>> I'm curious why? ( My thought is that doing a get on r,g,b,a would be
>>> fast relative the blur operation? )
>>>
>>> Does this fix it?
>>>
>>> soften[1:][0:] += Data[0:-1][0:]*8
Traceback (most recent call last):
  File "<pyshell#24>", line 1, in <module>
    antialias(array)
  File "<pyshell#23>", line 3, in antialias
    soften[1:][:]  += array[:-1][:]*8
ValueError: frames are not aligned

>>>
>>> I think if you want to slice pixel arrays then PixelArray() works
>>> better: http://www.pygame.org/docs/ref/pixelarray.html

>> Why not just use an array of floats?
My current solution for testing is to prebuild the height data using a separate script, then save that data as an array of floats in a separate .py file.  Effectively, the heightmap is not loaded or otherwise processed at runtime.  I think this might be my final solution, as prebuilding data will always be faster than building it at runtime.


> Why not use the height as interpolation points and interpolate between them?
> (using a spline or bezier or any other interpolation method)

That would be cool but would it be fast enough for real time use?
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. 

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. 

Thanks,
Ian