0

(I am using PyOpenGL and my laptop runs OpenGL 2.1)

I heard that OpenGL draws triangles are much faster than polygons, but that also that using display lists cuts the overhead. Would I gain any speed by converting my models into triangle strips, if I they are currently in polygons (triangles and quads and others) and using glBegin(GL_TRIANGLE_STRIP) to draw instead of glBegin(GL_POLYGON), if I am using display lists anyway? Does the display list automatically trianglulate everything?

I have models with about 50 faces in obj format and the list is made with this code:

treelist = glGenLists(1)
glNewList(treelist, GL_COMPILE)
for s in OBJ.treeobjs:
    for face in s.faces:
        verts, normals, texcoords = face

        glBegin(GL_POLYGON)
        for i in range(len(verts)):
            glNormal3fv(s.normals[normals[i]])
            if texcoords[i] > 0:
                glTexCoord2fv(s.texcoords[texcoords[i]])
            glVertex3fv(s.vertices[verts[i]])
        glEnd()
glEndList()

and drawn with:

glCalllist(treelist)

But if I wanted to convert everything to a triangle strip (triangulation is easy in blender) I would have to use a different format than obj?

Matt Majic
  • 381
  • 9
  • 18
  • A bit pedantic, but nevertheless: _OpenGL_ doesn't draw triangles faster than polygons, because it's a specification; it only defines what happens API calls do what, and doesn't implement anything. That said, most hardware today only renders triangles, and more complex shapes are decomposed into them. If you're using OpenGL 2+, you should be using vertex buffers instead of display lists. – Colonel Thirty Two Jan 03 '16 at 00:50
  • Does vertex buffers include using glDrawArrays? The VBO example in Wikipedia uses glDrawArrays along with glBindBuffer, but I can use glDrawArrays by itself. – Matt Majic Jan 03 '16 at 01:35

1 Answers1

0

obj format doesn't have support for triangle strips. Don't use GL_POLYGON or display lists as they're effectively deprecated. Don't bother triangle stripping unless you have a compelling performance reason.

Assuming you can triangulate everything in blender, load the triangles into a VBO and render indexed via glDrawElements. If you have a lot of models to draw, try to coalesce your models into a single big VBO.

Taylor
  • 5,871
  • 2
  • 30
  • 64
  • Triangles strips are better than an unoptimized triangle list. While an optimized triangle list can usually beat strips, you still have to *optimize* that list. – Nicol Bolas Jan 03 '16 at 00:35
  • I cant find specification on glDrawIndices - is that just another version of glDrawArrays and glDrawElements? – Matt Majic Jan 03 '16 at 01:43