[OT] Texturing an indexed triangle mesh in OpenGL

Andrew Bennetts andrew-pythonlist at puzzling.org
Sun May 11 20:38:08 EDT 2003


On Sun, May 11, 2003 at 11:16:43PM +0000, TheDustbustr wrote:
> My renderer is written in python, and thats about all this has to do with this
> newsgroup, hence the [OT]
> 
> This one has been bugging me forever, and nobody seems to know the answer (not
> even google!)  Once I have created a triangle mesh, what is the best way to
> texture it (with potentially different textures for each triangle)?  My current
> method, when used with a medium sized mesh (8000 triangles), yeilds me 40
> frames per second (I have a Geforce 4)- I should be getting about 200.

An obvious thing to try glancing at your code is eliminating common
subexpressions.  You use "VertexArray[int(IndiceArray[ind_i])][1]"
repeatedly in your if tests.  Perhaps try changing the body of your for-loop
to look like:

    val = VertexArray[int(IndiceArray[ind_i])][1]
    if (val <= 0) and (prevtexture > != "data/water-0.bmp"):
        # ...
    elif (val > 3) and (val <= 10) and prevtexture != "data/grass-0.bmp"):
        # ...
    # etc...

I think this makes it slightly more readable, too.

-Andrew.






More information about the Python-list mailing list