The Method of Drawing triangles using gl_triangle_strip is often confusing. Here we will explain its operation mechanism.

Generally, there are three ways to draw a series of triangles: gl_triangles, gl_triangle_strip, and gl_triangle_fan.

As shown in:

Gl_triangles draws a triangle for each of three vertices. The first triangle uses vertices v0, V1, V2, and the second triangle uses V3, V4, V5, and so on. If the number of vertices N is not a multiple of 3, the last one or two vertices will be ignored.

Gl_triangle_strip is a little complicated.

The rule is:

The connection sequence for building the vertex of the current triangle depends on the parity of the sequence number of the current vertex of the triangle to be formed with the two vertices that have appeared before (if starting from 0 ):

If the current vertex is an odd number:

Order of the vertices in a triangle: t = [n-1 N-2 N].

If the current vertex is an even number:

The order of the vertices that make up the triangle: t = [N-2 n-21 N].

For example, if the first triangle and vertex v2 are 2 and an even number, the vertex order is v0, V1, and V2. In the second triangle, if the vertex V3 sequence is 3 and is an odd number, the vertex order is V2, V1, V3. In the third triangle, the vertex V4 sequence is 4, which is an even number, the order of vertices is V2, V3, V4, and so on.

This order is used to ensure that all triangles are drawn in the same direction, so that the triangle string can correctly form a part of the surface. For some operations, maintenance is very important, such as elimination.

Note: The number of vertices n must be at least 3; otherwise, no triangle can be drawn.

Gl_triangle_fan is similar to gl_triangle_strip, but its triangle vertices are arranged in the order t = [n-1 N-2 N]. Each triangle forms a slice sequence.