How to Render a Sphere With Glusphere
Open Graphics Library, or OpenGL, is a computer graphics application programming interface (API) used to render twodimensional and threedimensional computer graphic images. It can be implemented on a variety of computer platforms and programming languages. OpenGL is used for video game development and scientific visualization. OpenGL does not offer a direct method of sphere rendering, but it does offer the "Glusphere" function, which draws a sphere of the given radius centered around the origin. To create a sphere, you will code a series of lines, calculate the sin and cosine values necessary to create the sphere, and then implement glusphere in the code.

Launch the OpenGL Viewport window.

Type the following code to provide the sine and cosine functions needed to calculate the circle:
include <math.h> 
Type the following code to render a sphere with glusphere:
void renderSphere(float x, float y, float z, float radius,int subdivisions,GLUquadricObj *quadric)
{
glPushMatrix();
glTranslatef( x,y,z );
gluSphere(quadric, radius, subdivisions,subdivisions);
glPopMatrix();
}
void renderSphere_convenient(float x, float y, float z, float radius,int subdivisions)
{
//the same quadric can be reused for drawing many spheres
GLUquadricObj *quadric=gluNewQuadric();
gluQuadricNormals(quadric, GLU_SMOOTH);
renderSphere(x,y,z,radius,subdivisions,quadric);
gluDeleteQuadric(quadric);
}