Easiest way to load a sphere
Using C++, what is the easiest way to load a sphere?
HAVE SOME TOAST DARLING! OR I WILL BEAT YOU!
HAVE SOME TOAST DARLING! OR I WILL BEAT YOU!
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!
HAVE SOME TOAST DARLING! OR I WILL BEAT YOU!
HAVE SOME TOAST DARLING! OR I WILL BEAT YOU!
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!"
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!"
Alex BroadwinA-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!"
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."
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."
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
Celeron ][ 566 @ 850256MB PC-100 CAS2 RAMDFI PA-61 Mainboard (250MB memory bandwidth sucks, it should be 500MB)ATI Radeon 32MB DDR LEWindows 98SE
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement