Sign in to follow this  
sweetdaddy

glucylinder fill?

Recommended Posts

sweetdaddy    122
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 this post


Link to post
Share on other sites
Sneftel    1788
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 this post


Link to post
Share on other sites
sweetdaddy    122
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 this post


Link to post
Share on other sites
Sneftel    1788
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this