Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kel19

OpenGL How to create arcs in OpenGL

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I would like to find out how could I draw an arc using OpenGL. I have the position of the arc, the radius, the start angle as well as the sweep range. How could I draw with all this information. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
As a sequence of (short) line segments.
Decide how many segments you want to break your arc into.
Use trig (cos,sin) to compute the coordinate of each segment end.
Draw the segments.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan

Share this post


Link to post
Share on other sites
You can use "evaluators" in OpenGL to draw smooth curves.

Look up glMap1f() and glEvalCoord1() and other related functions.

The most flexible way to handle curves would be NURBs
(Non-Uniform Rational B-Splines).

Look into the GLU library. It has support for drawing
curves and surfaces.

Look up gluNewNurbsRenderer() and other related functions.




Kami no Itte ga ore ni zettai naru!

Share this post


Link to post
Share on other sites
Thanks for the advice. I am really new to OpenGL, is it possible for you to show me in codes on how to use the trig(cos,sin) to do it. I know how to start the coding but I am not sure on how to draw the arc out using the mathematical algorithm

glBegin(GL_LINE_STRIP)
for(...)
{
how to do the trig code here??
}
GLEnd()

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Kel19,

Take a look at the gluPartialDisk() function for drawing arcs. I think it will do most of the work you are looking for. Dig into the source code for it if you want to learn more about the math.

Here is a link to the reference in case you don''t have the blue book:
http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5556583

Remember: Search is your friend!

robo

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!