An OpenGL triangle is the basic shape used to create larger objects in 3D graphics. It consists of three vertices and is faster to render than other polygons. Triangular stripes and meshes can be used to create complex shapes, while triangular fans can create cones and pyramids.
An OpenGL® triangle is the most basic shape that can be formed in OpenGL® and have a surface area. In geometry, a triangle is a shape made up of three points, each joined by a line. In OpenGL®, each point forming an angle of the triangle is known as a vertex, which is a collection of coordinates in three-dimensional (3D) space. A triangle is the most basic shape with an area, which means it’s also the basic unit used to create all the larger shapes within a given scene. One advantage of using an OpenGL® triangle over other polygons is the support it provides for more complex structures such as triangle streaks, triangle fans, and triangle meshes.
One purpose of the OpenGL® library is to provide mechanisms for displaying and animating complex 3D objects using all available hardware, including graphics cards and graphics processing units (GPUs). Triangles are so widely used in 3D graphics that most graphics cards are optimized to render triangles faster than most other polygons. An object formed in OpenGL® takes advantage of this feature by converting large, complex objects into a sequence of triangles. A commonly used shape, called a quad or quadrilateral, is a simple rectangle, but it’s made up of two triangles that share a single edge. It is faster to render the two triangles than to do the calculations necessary to render a rectangle.
While it may be conceptually simple to use an OpenGL® triangular sequence to construct a larger object, the library provides functions that can make the task easier and faster, and potentially use less space. The most common is called a triangular stripe. This is a shape that starts with a single OpenGL® triangle and allows the user to define another point that, when connected to the previous two points, forms another connected triangle. The process of defining points can continue, adding a new triangle each time defining only one additional point, eventually forming a long streak of triangles that alternate facing as they progress.
A stripe can be used to form another complex OpenGL® triangle shape known as a triangle mesh. This can be visualized as a sequence of triangular stripes lined up on top of each other. The result looks like a grid, except that each square actually consists of two triangles. In 3D space, a triangular mesh can be used to form non-uniform surfaces, such as that of a human face or a mountain range.
Finally, an OpenGL® triangle can also be used to form a shape known as a triangular fan. A triangular fan starts with a single triangle. A fourth vertex is defined, which connects to the previous triangle, forming a new triangle. The difference from a triangular stripe is that not only do each of the triangles share a side with the previous one, they also share a single common endpoint from which they all seem to emanate. In 3D space, a triangular fan can be used to create other shapes, such as a cone or pyramid.
Protect your devices with Threat Protection by NordVPN