What Is an OpenGL® Circle?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 12 February 2017
  • Copyright Protected:
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Unlike many soccer stars, Cristiano Ronaldo has no tattoos because getting one could prevent him from giving blood.  more...

March 22 ,  1765 :  The British passed the Stamp Act.  more...

There is no real built-in shape primitive for a basic Open Graphics Library (OpenGL®) circle, so drawing a circle involves following a simple algorithm to determine the location of the points, after which the points can be connected with lines to form the circle. In most instances, for a real-time rendering application, an OpenGL® circle is approximated and actually is composed of a number of straight lines that look like a circle when the distance between the end points of the lines is short enough. One trick that can help to make a circle smooth is to enable blending and to use the smooth-line drawing mode to reduce the appearance of the angles where two lines connect on the perimeter of the circle. Another way to draw a circle is to use the OpenGL® utility shape primitive known as a disk, which essentially is a two-dimensional (2D) circle that has an additional inner circle that can be set to match the outer edge diameter to somewhat inefficiently draw an OpenGL® circle.

The simple definition of a circle is a 2D shape in which each edge point is the exact same distance from a given center point. The most basic algorithm for drawing an OpenGL® circle is to plot points from a center coordinate using the sine and cosine functions in a loop that steps through the degrees of an angle up to 360°. Stepping 1 degree at a time is fairly inefficient, however, so the steps usually are performed in larger increments. The larger the increments, the more angular the circle will look, with the ultimate example being a circle drawn with only four points, which would make a square.

During each step in determining the coordinate of a point on the edge of an OpenGL® circle, a line can be drawn from the last point to the current point. It generally is faster to use a line strip to make a complete circle than to individually draw separate lines. Once the points that comprise the circle have been calculated, they can be stored in an array and translated just like any set of OpenGL® vertices.

An OpenGL® disk is a shape primitive that the OpenGL® utility library can draw natively. It is made of an outer circle and an inner circle, with the area between the inner and outer circles being solid and filled. The OpenGL® disk can be used to draw an OpenGL® circle by setting the inner radius to match the outer radius, although this technique means the circle really is drawn twice because of the inner and outer edges and could leave some graphical artifacts when rotated at different angles.


You might also Like


Discuss this Article

Post your comments

Post Anonymously


forgot password?