Category: 

What Is an OpenGL® Sphere?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 20 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...

An Open Graphics Library® (OpenGL®) sphere, at the most basic level, is a three-dimensional (3D) object made up of a series of triangles or quadrilaterals whose vertices are all equidistant from a center point. This means that, when an OpenGL® sphere is viewed from any angle, the outline appears as a perfect circle to the viewer, although lighting and shading might give the volume a more ball-like appearance. The number of vertices used to create an OpenGL® sphere determines the smoothness of the object in its approximation of an actual sphere, with any less than 12 points creating an object that cannot be considered a sphere. Even though a sphere is considered a shape primitive in many graphical applications and libraries, OpenGL® does not have any innate functionality to render a sphere, meaning supplementary toolkits such as the OpenGL® utility toolkit (GLUT) need to be used to avoid writing code to manually generate the shape.

When dealing with vertices in OpenGL®, the least amount of points that can be used to generate a sphere with some degree of smoothness is 12, creating an object with 20 triangular faces known as an icosahedron. Without further processing, an OpenGL® sphere constructed in this way will have visible sharp corners around the edges, which might be acceptable for some applications. To achieve a more rounded sphere, each face needs to be further subdivided.

Ad

Subdividing an icosahedron to increase the number of vertices it contains and form a smoother OpenGL® sphere involves creating new vertices in the center of each edge of each existing triangle. This means each triangular face will now contain four triangles. The subdivision can continue as much as required, although adding points exponentially can quickly create an object that has a high render time and can become unwieldy to translate.

Despite some of the mathematical conveniences an OpenGL® sphere provides for programmers, such as the surface normals that can be readily calculated from the vertex coordinates, texturing a sphere can present some complexities. Using a standard two-dimensional (2D) texture projected onto the sphere means that the top and bottom areas of the texture image will become compressed, because the shape of the triangles near the poles of the sphere are compressed themselves. To overcome this, cube mapping could be used or the programmer could generate the texture coordinates manually for the object.

One factor should be noted about using a utility library for generating an OpenGL® sphere. A sphere generated by GLUT or similar toolkits can sometimes be difficult to modify, optimize and manage within OpenGL® itself. For this reason, it is sometimes beneficial to use custom written code to generate an OpenGL® sphere so it is created and can be used in the most efficient way possible within the program.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email