What draw method is better?

I would like to know what is less slow: draw the mesh using glDrawElements method or triangle by triangle using glBegin(GL_TRIANGLES) … glEnd().

Since the Backface Culling isn’t working well (I don’t know why) I wanna make my own culling algorithm and apply it triangle by triangle before the draw method. Actually, and don’t’ know if it’s possible with VAO.

Thanks in advance.

glBegin/glEnd is likely to be the slowest method. Ideally, you should use glDrawElements with buffer objects.

If it’s culling the wrong faces, you probably have inconsistent winding. The vertices need to be ordered consistently, i.e. either always clockwise or always anti-clockwise when looking at a particular side of the mesh (inside or outside).

Well, you could construct the element array each frame so it only includes the triangles you want drawn.

1 Like

I’m pondering a way to debug the mesh. It could be done if @LonelehKitten has access to the triangles (say from a vector).

int triangle_to_test=0; // to be sat through a key of choise like
triangle_to_test++;
and then do a draw-call on this particular triangle with a different color after the full draw. It will repaint the triangle … if it’s facing properly.

It’s not complicated, but I don’t know how @LonelehKitten has setup things.

Setting up for a draw_elements() will impose a harsh scrutiny of each triangle and their needed point-indices, but an ordeal that will fix the faul ordering if done properly - once and for all.

A culling algorithm may need to calculate and estimate the normal for each triangle … that’s a hard penalty for a mesh-error if it cannot be performed only once.

1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.