I’m trying to draw a 2D crescent(a moon) but I’m facing a lot of problem. Here’s what I’ve been playing with so far, which have problems with the start and end vertices:
void drawCresent(float step, float radius, float cut) {
float angle=0.0f;
glBegin(GL_POLYGON);
glColor4f(1.0, 1.0, 1.0, 1.0);
glVertex2f(cut*radius*sinf(-1.5f*PI),0);
while (angle<=PI) {
glVertex2f(radius*sinf(angle),radius*cosf(angle));
angle+=step;
}
while (angle<(2.0f*PI)) {
angle+=step;
}
glEnd();
} [/b]
[/b]
Unfortunately, because of the start and end points of the polygon are automatically joined, a straight line is being cut across the polygon and the colour filling of the area is incorrect. The inner curve of the crescent is lost because of the straight line.
I found this method really troublesome and not flexible because I have hardcoded the angles. I was thinking to use the intersection between 2 circles instead. Is it possible to remove an intersection area of a polygon in OpenGL? How can I do it? I’ve searched the web but have no answers to how I could remove intersected areas between polygons.
If removal of intersections is not possible or turns out to be more complicated, what else can I do to fix the problem in the above code?
Thanks for any help.