Advertisement Jump to content


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


Easiest way to load a sphere

This topic is 6390 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

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?


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)
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

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;

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);


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);



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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!