• What is your GameDev Story?

Archived

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.

Recommended Posts

Using C++, what is the easiest way to load a sphere? HAVE SOME TOAST DARLING! OR I WILL BEAT YOU!

Share on other sites
How do you mean exactly???

gluSphere?

Share on other sites
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 on other sites
Hey ToasterFace,
gluSphere is a member of gluQuadratic. The proper usage is shown below.

//Declare Object

//Create Object (can be done in initialization)

//Draw Object

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.

A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."

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

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

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• Forum Statistics

• Total Topics
634071
• Total Posts
3015340
×

Important Information

GameDev.net 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!