View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# OpenGL circle problems

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1Whackjack  Members

Posted 01 May 2007 - 05:31 AM

I have found many examples of drawing circles with OpenGL. However, I have not seen one that attempts to drawn one with a line width > 1. In my very-alpha SVG implementation, I need to allow for a stroke-width of an arbitrary size. Unfortunately, when the width gets to be greater than 5, small notches start to appear in the circle. Specifically, they appear at 45 degree angles to the horizontal and vertical. I'm actually doing this in Java/LWJGL for FengGUI, but the code should be clear enough to decipher what the equivalent OpenGL commands are:
gl.lineWidth(15);
gl.startLineLoop();
for (int i = 0; i < 360; i++)
{
}
gl.end();


Now, I do know that cos(45 degrees) == sin(45 degrees). So, it appears that there won't be a line drawn at these locations. Has anyone ever run into this problem and how did you work around it? Also, I tried to render the circle with points instead of a line loop, but the circle starts to take on a square shape after it gets so large.

### #2sjhalayka  Members

Posted 01 May 2007 - 05:54 AM

I'm very lazy, so I generally draw a circle using a torus using GLUT (glutSolidTorus).

### #3zedz  Members

Posted 01 May 2007 - 12:28 PM

for (int i = 0; i < 360; i+=10)
{

}

### #4Whackjack  Members

Posted 02 May 2007 - 03:42 AM

Quote:
 Original post by zedzuse a quad stripfor (int i = 0; i < 360; i+=10){glVertex2f( sin(i*DEG2RAD) * outer_dist, cos(i*DEG2RAD) * outer_dist );glVertex2f( sin(i*DEG2RAD) * inner_dist, cos(i*DEG2RAD) * inner__dist );}

Most excellent. This is by far the fastest and simplest implementation I've seen/tried so far. Thanks!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.