Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

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


Sign up now

OpenGL circle problems

4: Adsense

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.


  • You cannot reply to this topic
3 replies to this topic

#1 Whackjack   Members   

100
Like
0Likes
Like

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++)
{
    float degInRad = (float)Math.toRadians(i); 
    gl.vertex((float)Math.cos(degInRad)*r, (float)Math.sin(degInRad)*r);
}
gl.end();

Image Hosted by ImageShack.us 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.

#2 sjhalayka   Members   

1218
Like
0Likes
Like

Posted 01 May 2007 - 05:54 AM

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

#3 zedz   Members   

291
Like
0Likes
Like

Posted 01 May 2007 - 12:28 PM

use a quad strip

for (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 );

}

#4 Whackjack   Members   

100
Like
0Likes
Like

Posted 02 May 2007 - 03:42 AM

Quote:
Original post by zedz
use a quad strip

for (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.