Opengl primitive

how do you draw a semicircle(arc)with the opengl library or glut

Hi
You can write a routine for that using the sin and cos values in the interval 0 to pi (180) and plotting a vertex at each location. this kind of a routine is definitely expected to be slow and will get slower as you increase the number of points to be plotted. You may use the glutIdleFunc for calc these vertices while ur processor is idle but i guess theres much of an overhead associated.

Alternatively you can use triangle fans.

Hi:
You could calculate de values of SIN or COS one time and save them in a table. Then draw the semicircles you need with no overhead by using the values calculated before and operate de vertex with diferent matix to change sizes.

You could try the gluSphera and make it draw a circle. It is possible ? I dont know. Never used it.

Google for “bresenham circle rasterization” and take it from there. Instead of drawing a pixel, you want to make your line strip go to that point.

You don’t need to emit a vertex for each pixel; in fact, that’ll probably look pretty bad. A vertex every 3 pixels or so should be fine for all but the smallest circles. In fact, the best trade-off may be a vertex for ever (2+floor(radius/5)) pixels or so.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.