Learn something new every day More Info... by email
An OpenGL® quadrilateral, or quad, in computer programming and graphics is a three-dimensional (3D) shape, also called a polygon, that has four sides and four points. Each 3D point that represents a single corner of the OpenGL® quad is known as a vertex and is defined with three numbers relating to its coordinate position in the virtual space. The vertices of a quad do not have to follow any real guidelines, except that there has to be four of them; otherwise the shape is known as a polygon, triangle or line depending on the actual number. Most digital images are actually rectangular, so an OpenGL® quad can be a useful shape because the image can be texture mapped to the surface without a large amount of distortion and without the need for complex texture mapping techniques. The use of an OpenGL® quad has its own challenges, however, and there are a number of programmers who suggest avoiding their use completely.
One of the major uses for an OpenGL® quad is to draw two-dimensional (2D) graphics within a 3D environment. This can be done to have a static user interface overlaid on top of a 3D scene or to emulate 2D graphics with OpenGL®. Even though OpenGL® was designed to render complex 3D graphics, it is frequently used in 2D graphics applications because of the optimizations and flexibility of the abstract programming interface (API). A quad becomes very important in rendering 2D graphics, because it is a natural 3D representation of a digital image, meaning a quad can be proportioned to exactly match the dimension of the image. Once the proportions match, the image can be texture mapped, or projected, onto the surface of the quad without any type of distortion, wrapping or gutter space.
An advantage of using an OpenGL® quad, according to some programmers, is that it is easier to think about how quads fit together, as opposed to visualizing how triangles fit together. This is especially true for simple 3D shapes such as a cube in which each quad is a single side; with a triangle mesh, two triangles must be combined to make a quad that makes a single side. Quads also can be easily manipulated to create perspective or other effects within an environment that is either tiled or aligned to a grid.
There are some disadvantages to using an OpenGL® quad, mostly because of the algorithms used to rasterize or render an image within the window of the viewer. One of the most encountered problems is that the rendering or graphics card might, at any point, break the quad into two triangles for the purpose of efficiency. This can cause an otherwise smooth surface to suddenly have a visible distortion at an angle through the quad where the edges of the triangles meet.
Another problem that is more common than sometimes thought has to do with the clipping of an OpenGL® quad. When part of the quad is outside the viewing window, off screen, the renderer will clip the quad so only the visible portion is rendered. This means a quad will be geometrically cut. If the quad was converted into two triangles before the clipping occurs, then each triangle becomes a quad, and each of those quads is converted into two triangles. This leads to a situation in which a clipped quad suddenly consists of four triangles instead of one smooth quad.
The complexities and unpredictability of the conversion of quads into triangles leads to undesirable results. These include distortions in textures, inaccuracies or artifacts related to vertex lighting, and sometimes missing polygon surfaces. For these reasons, some programmers avoid the used of quads altogether.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!