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

Re: [pygame] Old pygame tutorial not working



Here is a decorator that speeds up a function using screen lists:

def screen_list(func):
    func.sl = None
    def x():
        if not func.sl:
            func.sl = glGenLists(1)
            glNewList(func.sl, GL_COMPILE)
            func()
            glEndList()
        glCallList(func.sl)
    return x

On Mon, Aug 4, 2008 at 4:15 PM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
> On Mon, Aug 4, 2008 at 12:48 PM, Casey Duncan <casey@xxxxxxxxxxx> wrote:
>>
>> What type of interpolation? Linear interpolation between points would
>> require no extra vertices.
>
> That was what I was doing at the outset, but it gives the "stepping" effect.
>>
>> You may need to implement some sort of variable LOD to get acceptable
>> performance (farther things approximated using far fewer vertices).
>
> That's easier said than done, but I agree that that would be a good idea.
>>
>> 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.
>
> I know the basic theory of normal mapping, but not how to actually do it.  I
> had considered that though.
>>
>> 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.
>
> Vertex arrays aren't widely supported, but VBOs are.  I can do vertex
> arrays, but not vertex buffer objects.  Thus, the map is being made from
> quad or triangle strips (can't remember which).
>>
>> 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.
>
> Right, that is what I'm doing externally.  The height data is precalculated
> as opengl units, then stored in a separate module.  When I run the game,
> this module is used by Objects.py (which makes the landscape from the
> data--the only data processed before the game runs) and the main, which then
> uses it as collision detection.
>
> Presently, this making of the landscape takes some time.  Certainly, not as
> much as making the heightdata on the fly would be, but still some time.
> Currently, I'm not making/using any normal data, but when I do, it will be
> slower still.  That is why the landscape loader must be in C.  By
> transferring data, I mean sending heightmap data (from the premade .py file)
> to C, then getting the display list back.
>
> Ian
>