Category:

One of the major uses for an OpenGL® quad is to draw two-dimensional (2D) graphics within a 3D environment.
Article Details
• Written By: Eugene P.
• Edited By: Angela B.
2003-2015
Conjecture Corporation
 J.R.R. Tolkien used two fingers to type out all 1,200 pages of The Lord of the Rings, which took him over 12 years.  more...

 July 6 ,  1928 :  The first all-talking "talkie" movie   more...
wiseGEEK Slideshows

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.

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.