Hi!
I found samples for drawing circles or ellipses on the web. What I want to do is draw them with stipple pattern, just like glLineStipple. What is the easiest way to do this?
Thanks.
Hi!
I found samples for drawing circles or ellipses on the web. What I want to do is draw them with stipple pattern, just like glLineStipple. What is the easiest way to do this?
Thanks.
Imagine a 4-sided figure. Doesn’t look like a circle. Imagine an 8-sided figure (like a US stop sign). It’s looking more like a circle, but still rought. Now imagine a 36-sided figure. Looks pretty much like a circle.
Really you’re connecting each of the 36 points with a line (which will obey line stipple). So your quest now is to calculate the 36 points you need for a circle.
There are many resources to find this information out. If you still need help I’ll try to post some more details.
Are you having trouble drawing a circle/ellipse or is setting the right line style your problem?
this should work:
int i, steps = 36;
float x = 0.0, y = 0.0, r = 1.0, phi, dphi = 2.*M_PI / (float)(steps);
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0xff);
glBegin(GL_LINE_LOOP);
for(i = 0, phi = 0.0; i < steps; i ++, phi += dphi)
glVertex3f(x+r*cos(phi), y+r*sin(phi), 0.0);
glEnd();
glDisable(GL_LINE_STIPPLE);
draws a circle in the x-y-plane at center x/y,
radius r. increasing “steps” will result in a
smoother curve.
a stipple pattern is defined with glLineStipple.
the pattern is a 16-bit short (values from 0x0000
That’s the code I needed Thank you RigidBody!
If you plan on drawing many circles, consider pre-calculating your sin/cos values. It will save some time in a tight loop with lots of circles.