Skip to main content
gamedev.net
🔒 Locked

Drawing Circles

Started by CBell 2 replies 1.1k views
Original Post
CBell
CBell
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?
Zakwayda
Zakwayda
Quote:
Original post by CBell
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?
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.
Splinter of Chaos
Splinter of Chaos
Yeah, I came across this problem recently. I used Google.

Read the following after searching on Google, please. (If you haven't already.)

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...
http://forum.gamedeception.net/showthread.php?t=7810
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.
CBell
CBell
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.