Category: 

What Are OpenGL® Lines?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 22 November 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The mongoose was introduced to Hawaii in order to kill rats, but mongooses hunt in the day, while rats are nocturnal.  more...

December 7 ,  1941 :  Japanese bombers attack Pearl Harbor.  more...

In Open Graphics Library® (OpenGL®), lines are one of the basic primitive shapes that OpenGL® is able to draw, and they constitute one of the building blocks that are sometimes used to render triangles. OpenGL® lines are just a straight, connecting graphic between two vertices. Even though the concept and execution of OpenGL® lines can be simple, they tend to take a longer time to render than other primitives in some implementations, partly because there is no specification about their behavior in the OpenGL® standard. Using OpenGL® lines explicitly can sometimes have unexpected results, because the lines are rasterized in a specific way that might make them seemed detached from other geometry in the scene or appear to be slightly off from where they are expected to be. In addition to a basic line, OpenGL® lines also can be formed into line strips and loops, much like triangle strips, with the end of each line being the start of the next one.

Ad

When used in a scene, OpenGL® lines are a type of shape primitive consisting of two vertices, or coordinates in three-dimensional (3D) space, that are connected by a straight, visible path. Unlike other primitives, such as a triangle, a line does not generally have a surface, although it can still be colored with blending and by using vertex coloring. Lines are frequently used in mathematical and scientific 3D visualizations, as well as for two-dimensional (2D) display indicators — such as crosshairs or arrows pointing to areas of the display — for the viewer.

The width of a line can be defined to some extent through OpenGL®. The number of pixels wide that the line should be at any given point can be specified, although there is no real standard for how this should operate from one platform to another. In some situations, the width cannot be changed at all while, in other instances, the width of OpenGL® lines is restricted to a seemingly arbitrary number.

In addition to the basic line, multiple OpenGL® lines can be combined to form two other structures known as line strips and line loops. Line strips are simply a sequence of vertices in which the start of each new line is the end point of the last line. This is mostly a convenience function but can render more quickly than using individual lines. A line loop is almost identical to a line strip, except that the very last vertex in the loop is then connected back to the first vertex specified.

One complication when using OpenGL® lines is that, because they are only 1 pixel wide by default, they sometimes do not render in the correct way. In certain instances, especially if the line is anti-aliased, certain pixels in the rasterized image might not be displayed. The line itself also might appear a few pixels away from where it is expected to be. This is largely caused by minute variations in the floating point math that OpenGL® uses; it is not always an issue that can be easily solved without converting lines into polygons for rendering purposes.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email