# glucylinder fill?

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

## Recommended Posts

I noticed when creating a glucylinder that it does not actually fill, it is just the outer layer of the cylinder. I need it to fill to the center of the cylinder. I also defined different bases', so the top and bottom radius are not the same. I have seen glutsolidcylinder but that does not allow you to create different base sizes. Anyone know? Thanks

##### Share on other sites
By "fill the cylinder", do you mean that you want the top and bottom of the cylinder to be closed, or do you literally want the full volume of the cylinder to be filled with "stuff"?

As for making the top and bottom different radii, the built-in GLUT primitives don't have that (that would be a circular frustum, not a cylinder). You'll need to make the vertices yourself. It's pretty simple, though. You can do the whole thing as a quad strip, plus polygons for the top and bottom.

##### Share on other sites
I just meant for it to close the top and bottom of the cylinder. Can you give me and example of what you mean, as far as creating a quad strip? I am actually pretty new to opengl.

I was thinking I could create the cylinder and then just create 3d circles for the top and bottom.

##### Share on other sites
I mean, using glBegin()...glVertex()...glEnd(). Drawing by vertices, rather than using glut's utility functions. The frustum (again, if the top and bottom have different radii, it's not a cylinder) would be defined by alternating points on the top and bottom, going around the circle. The code would go something like this:

glBegin(gl_quad_strip)for(angle from 0 to 2*pi, incremented by 2*pi/number_of_slices){  glVertex3f(r1*cos(angle), r1*sin(angle), bottom);  glVertex3f(r2*cos(angle), r2*sin(angle), top);}glEnd()

This code has many problems in it, and is not meant to be copy-pasted. You should understand what each line is doing and why, and use it as a guide to figure out how to do what you want to do.

##### Share on other sites
You could also use gluDisk.

1. 1
2. 2
3. 3
Rutin
20
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013186
×