I need an example of a polygon that can be done only by GL_TRIANGLE_STRIP
and another polygon that can be done only by GL_TRIANGLE_FAN
.
GL_TRIANGLES. Treats each triplet of vertices as an independent triangle. Vertices 3n - 2, 3n - 1, and 3n define triangle n. N/3 triangles are drawn.
A triangle fan is a primitive in 3D computer graphics that saves on storage and processing time. It describes a set of connected triangles that share one central vertex (unlike the triangle strip that connects the next vertex point to the last two used vertices to form a triangle), possibly within a triangle mesh.
In OpenGL, an object is made up of geometric primitives such as triangle, quad, line segment and point. A primitive is made up of one or more vertices. OpenGL supports the following primitives: A geometric primitive is defined by specifying its vertices via glVertex function, enclosed within a pair glBegin and glEnd .
When knowing the difference between Triangle Strip and Triangle Fan a shape will be easy to make.
For instance a Triangle Strip is a set of connected triangles which share vertices.
Using Triangle Strip we will be able to get the following output, using those given vertices.
Where a Triangle Fan is also a set of connected triangles, though all these triangles have a common vertex, which is the central vertex.
In OpenGL the central vertex is the first given vertex, in the Triangle Fan.
Using Triangle Fan and the same vertices as in the other example, we will only be able to get the colored area as output. That is due to the importance of the arranged order of the vertices in Triangle Fan. Basically, all the vertices need to go around the central vertex.
As you can see on our 2 example sets of vertices those "output shapes" are unique to both Triangle Strip and Triangle Fan.
Note: The image examples uses clockwise winding order, while in OpenGL the front side uses counter-clockwise winding order, i.e. the examples are literally facing away from the camera. This is an important detail if face culling is enabled.
I made a similar answer here, you can read it if you want, I actually used the same images since the questions are closely related.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With