Vivi

04-25-2004, 09:25 PM

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

View Full Version : opengl primitive

Vivi

04-25-2004, 09:25 PM

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

Platinum Rogue

04-26-2004, 12:50 AM

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.

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.

Ape

04-26-2004, 09:48 AM

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.

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.

jwatte

04-27-2004, 07:20 PM

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.

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.

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.