danielepanozzo / cg-old

44 stars 16 forks source link

How to draw faces with different vertices when loading .obj File? #51

Closed ll1733 closed 7 years ago

ll1733 commented 7 years ago

I downloaded some obj files and noticed that not all of them used triangles to draw faces. However, it seems that GL_QUADS and GL_POLYGON are deprecated in modern openGL. Then how should I draw faces with more than 3 vertices?

danielepanozzo commented 7 years ago

You need to triangulate every polygon, and then render the triangles. You can do it programmatically (https://en.wikipedia.org/wiki/Polygon_triangulation) or using a modeling software like blender (https://www.blender.org/manual/modeling/modifiers/generate/triangulate.html).