0
\$\begingroup\$

I wrote Opengl ES wrapper, and I want to know, when I should use

GL_TRIANGLES, GL_TRIANGLES_FAN and GL_TRINAGLES_STRIP

I read difference from OpenGL Red Book, but still doesn't understand what kind of them and when I should use them.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

First, here's an image to help visualize what we're taking about:

GL modes

And some explanation:

GL_TRIANGLES: You send distinct triangles to draw, with each 3 coordinates representing a corner of the triangle (so (v0,v1,v2) is a triangle and (v3,v4,v5) is a triangle and so on)

GL_TRIANGLE_STRIP: You send a connected strip of triangles that each share an edge with the next one (so (v0,v1,v2) is a triangle, and (v2,v1,v3) is a triangle, sharing (v1,v2) edge and so on)

GL_TIRANGLE_FAN: You send a connected fan of triangles that each share a common corner (v0 in the image above)

As you can see, triangle fans and triangle strips require less data sent to the GPU (vs if you wanted to draw the same thing using GL_TRIANGLES)

\$\endgroup\$
1
\$\begingroup\$

You pretty much use triangle strips and fans when you can, they don't require so many data to be sent to the GPU, thus it can improve loading time (a very very slight improvement, but improvement).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .