3

I recently build a obj file loader in python 3 using pygame and pyopengl. It works perfectly fine, but when I load a round object it starts running realy slow. I'd like to load multiple complex objects at a decent framerate, but this aproach wouldn't be suitable for that. Do you have any recommendations for writing the code more efficently, exchanging pygame/pyopengl for something different or (if none of the above work) maybee downsample the object? (important parts of the code are below)

# verticies is a list of all verticies
# surfaces holds tuples of indexes of verticies

def body():

    glBegin(GL_TRIANGLES)
    for surface in surfaces:
        for vertex in surface:
            glVertex3fv(vertices[vertex])
    glEnd()

pygame.init()
size = (800,600)
pygame.display.set_mode(size, DOUBLEBUF|OPENGL)

while True:
    body()
GreenJoFlo
  • 33
  • 7
  • 1
    Drawing by [`glBegin`/`glEnd`](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glBegin.xml) sequences, the fixed function matrix stack and fixed function, per vertex light model, is deprecated since decades. Read about [Fixed Function Pipeline](https://www.khronos.org/opengl/wiki/Fixed_Function_Pipeline) and see [Vertex Specification](https://www.khronos.org/opengl/wiki/Vertex_Specification) and [Shader](https://www.khronos.org/opengl/wiki/Shader) for a state of the art way of rendering. – Rabbid76 Jan 09 '19 at 16:31
  • Thanks a lot @Rabbid76, defenitly gonna try that :) – GreenJoFlo Jan 10 '19 at 19:48

0 Answers0