Category: 

What Is an OpenGL® Circle?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 05 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The atmosphere of Jupiter's moon Io collapses every time it is eclipsed by the planet.   more...

September 29 ,  2008 :  The Dow Jones Industrial Average experienced its largest one-day drop in history.  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.

Ad

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.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

exception 'Exception' with message 'error writing captcha: Duplicate entry '2147483647' for key 'PRIMARY'' in /ssd/www/wisegeek/public_html/_core/classes/public/Captcha.php:44
Stack trace:
#0 /ssd/www/wisegeek/public_html/_core/controls/public/ControlDiscussionPostBox.php(324): Captcha->createCaptcha()
#1 /ssd/www/wisegeek/public_html/framework/classes/Control.php(104): ControlDiscussionPostBox->preRender(false)
#2 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): Control->render()
#3 /ssd/www/wisegeek/public_html/tpl/default-nocustom-lu/pages/public/article/article.htm(526): Control->__toString()
#4 /ssd/www/wisegeek/public_html/framework/classes/Control.php(300): require('/ssd/www/wisege...')
#5 /ssd/www/wisegeek/public_html/framework/classes/Control.php(309): Control->requireTpl('pages/public/ar...', Object(PageArticleCom), true)
#6 /ssd/www/wisegeek/public_html/framework/classes/Control.php(131): Control->renderTpl('pages/public/ar...', Object(PageArticleCom))
#7 /ssd/www/wisegeek/public_html/framework/classes/FormDataControl.php(87): Control->renderTemplate()
#8 /ssd/www/wisegeek/public_html/framework/classes/Control.php(109): FormDataControl->renderTemplate()
#9 /ssd/www/wisegeek/public_html/framework/classes/ScriptPage.php(50): Control->render(false)
#10 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): ScriptPage->render()
#11 /ssd/www/wisegeek/public_html/framework/classes/Page.php(97): Control->__toString()
#12 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(443): Page->processRequest()
#13 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(7): PublicFrontController->renderPage()
#14 /ssd/www/wisegeek/public_html/index.php(11): PublicFrontController::run()
#15 {main}