Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ToasterFace

Easiest way to load a sphere

This topic is 6238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
What can you do with gluSphere?, Do you pass it something or is it an entire function? Can you post some code to show where and how you use the function?



HAVE SOME TOAST DARLING! OR I WILL BEAT YOU!

Share this post


Link to post
Share on other sites
Hey ToasterFace,
gluSphere is a member of gluQuadratic. The proper usage is shown below.

//Declare Object
GLUquadraticObj *mysphere = NULL;

//Create Object (can be done in initialization)
mysphere=gluNewQuadratic();
gluQuadraticDrawStyle(mysphere, GLU_FILL);

//Draw Object
gluSphere(mysphere, radius, slices, stacks);

The quadratic should be positioned using glTranslatef command(s).
That''s it I believe. Someone post if I''ve left anything out.
Oh yea, and you need to include glu.h and the glu library.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
I''ll avoid my programming language of choice in this post..

variables: PQuadric As GLUQuadricObj

PQuadric = gluNewQuadric
gluSphere(PQuadric,radius,slices,stacks)

thats all you have to do to draw a sphere, entering in all the desired values in for radius, slices and stacks. Don''t forget to add the glu library.

"You are just as irritating to me as an irrational term that accidentially creeps into your equation and cannot be factorized out."

Share this post


Link to post
Share on other sites

void DrawSphere(float Radius, int Slice, int Stack)
{
float SliceStep=(3.1415f/Slice);
float StackStep=(2.0f*3.1415f/Stack);
int i, j;

for(i=0;i<(Stack);i++)
{
float r0=(float)sin(i*SliceStep);
float r1=(float)sin((i+1)*SliceStep);
float y0=(float)cos(i*SliceStep);
float y1=(float)cos((i+1)*SliceStep);

glBegin(GL_TRIANGLE_STRIP);

for(j=0;j<(Slice+1);j++)
{
float x0=r0*(float)sin(j*StackStep);
float z0=r0*(float)cos(j*StackStep);
float x1=r1*(float)sin(j*StackStep);
float z1=r1*(float)cos(j*StackStep);

glTexCoord2f((float)j/Slice, -i/(float)Stack);
glNormal3f(x0, y0, z0);
glVertex3f(x0, y0, z0);

glTexCoord2f((float)j/Slice, -(i+1)/(float)Stack);
glNormal3f(x1, y1, z1);
glVertex3f(x1, y1, z1);
}

glEnd();

}
}


Edited by - NitroGL on July 20, 2001 11:03:01 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!