# Drawing Circles

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

## Recommended Posts

I'm making a model of the solar system, and for the rings around Saturn I was going to draw a torus and make it long and thin, but those options aren't available in the glutsolidtorus function. Then I thought to just draw a circle around it and place a ring texture I have on that. But there isn't a circle function, so what is the best way to draw one? Or, what would be the best way to put the rings around Saturn?

##### Share on other sites
Quote:
 Original post by CBellI'm making a model of the solar system, and for the rings around Saturn I was going to draw a torus and make it long and thin, but those options aren't available in the glutsolidtorus function. Then I thought to just draw a circle around it and place a ring texture I have on that. But there isn't a circle function, so what is the best way to draw one? Or, what would be the best way to put the rings around Saturn?
A flat ring with a texture rendered to both sides should work fine, I would think. You're right that GLUT does not include a function to render this particular shape, but it's easy enough to generate the mesh data yourself.

Basically, you'll want to generate vertices for two circles of different radii (one for the inner edge of the ring, and one for the outer edge), and then connect them with triangles. If there's any part of this that you're not sure how to do, post back.

##### Share on other sites
Yeah, I came across this problem recently. I used Google.

Find anything? Yeah, it doesn't look like there's any built-in support. But, I'm lucky: where you'll have to do math, I built a PolarVector class a long time ago so all I have to do is set the radius, set theta, it'll give me a RectVector that I'll offset by where the middle of the circle should be. Then I'll just increment theta and do it again!

...On the other hand, that seems a little harder than http://steinsoft.net/index.php?site=Programming/Code%20Snippets/OpenGL/no5
This is what I suggest, simply because it's simplest. Although, if you want what claims to be efficient...
I don't really know how much more efficient it is. In fact, it LOOKS less so.

I suggest going with the simplicity of the first link, but like the second, having the step not (always) be one. I'd make that an argument, prioritizing not circles that look nice, but letting the programmer decide how nice they should look at any one time.

Although, like the above said, you can always use a texture. It'll probably look nicer and run faster, but the above techniques are good if you're not good with MS Paint (I know I'm not).

EDIT
If you look around on the first site I linked, he shows how to do eclipses as well.

##### Share on other sites
Just thought I'd let you guys know that I found out that there is a gluDisk() function that I could use that did exactly what I wanted. But leaning how to draw a circle was good.

Thanks for the help.

• ### What is your GameDev Story?

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

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634048
• Total Posts
3015237
×