# Create a Sphere?..not centered in middle of screen?

Hi, I’m wondering how to create a sphere that is not centered in the middle of the screen? how can I move it or draw it somewhere else other than the center?

I tried creating my sphere with this
gluSphere(0.4,20,20);

or…
glutSolidSphere(0.4,20,20);

But both put them in the center of the screen.
Does anyone know where I could find an algorithm for creating a sphere? not using glu or glut?

thanks

gluSpehere() as well as the other functions (gluCylinder(), etc.) always place the objects centered at the origin.

What you should do is create the sphere and then translate it with glTranslatef() to whatever location you need.

Thanks, that works.

I also wondered if anyone knows how to create a sphere not using glu or glut? like is there some algorithm or something.

Thanks

You can try either, auxSoildSphere() or auxWireSphere()…

Hi,
this is directly from my code. It illustrates the idea of calculating a sphere at given center, radius, slices and stacks.

void CSurfSphere::Calculate()
{
ClearTopology();

``````CControlPoint* pPolS = new CControlPoint( m_center + C3DPoint(0,0,-m_dRadius,0), this );
CControlPoint* pPolN = new CControlPoint( m_center + C3DPoint(0,0, m_dRadius,0), this );

double dFiStep = 2*M_PI / (m_nStacks - 1);

double dTitaStep  = M_PI / (m_nSlices - 1);
double dTita = - M_PI + dTitaStep;

CControlPoint** pPrevSlice = new CControlPoint* [m_nStacks];
CControlPoint** pCurrSlice = new CControlPoint* [m_nStacks];

int nSlice, nStack;
C3DPoint pt;

for (nSlice = 1; nSlice &lt; m_nSlices - 1; nSlice++, dTita += dTitaStep)
{

double dFi = 0;
for (nStack = 1; nStack &lt; m_nStacks; nStack++, dFi += dFiStep)
{

CControlPoint* pCpt = pCurrSlice[nStack] = new CControlPoint(pt, this);
pCpt-&gt;GetNormalRef().C3DPoint::operator = ( *pCpt - m_center);

}
pCurrSlice = pCurrSlice[nStack-1];

if (nSlice == 1)
{
for (nStack = 1; nStack &lt; m_nStacks; nStack++)
{
}
}
else if (m_bTrisOnly)
{
for (nStack = 1; nStack &lt; m_nStacks; nStack++)
{
}
}
else
{
for (nStack = 1; nStack &lt; m_nStacks; nStack++)
{
}
}
std::swap (pPrevSlice, pCurrSlice);
}

for (nStack = 1; nStack &lt; m_nStacks; nStack++)
{