# Drawing 2D crescent

**URL:** <https://community.khronos.org/t/drawing-2d-crescent/65512>\
**Category:** OpenGL: Basic Coding\
**Created:** [September 1, 2011, 7:19am UTC](https://community.khronos.org/t/drawing-2d-crescent/65512 "2011-09-01T07:19:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xEnOnn](https://community.khronos.org/letter_avatar_proxy/v4/letter/x/e99b99/32.png) [@xEnOnn](https://community.khronos.org/u/xEnOnn)\
**Post date:** [September 1, 2011, 7:19am UTC](https://community.khronos.org/t/drawing-2d-crescent/65512/1 "2011-09-01T07:19:20Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![xiphos](https://community.khronos.org/user_avatar/community.khronos.org/xiphos/32/181_2.png) [@xiphos](https://community.khronos.org/u/xiphos)\
**Post date:** [September 2, 2011, 1:13am UTC](https://community.khronos.org/t/drawing-2d-crescent/65512/2 "2011-09-02T01:13:16Z")

</div>

Check below link, hope this will help you…

[http://stackoverflow.com/questions/7260963/drawing-a-crescent-shape-in-opengl](http://stackoverflow.com/questions/7260963/drawing-a-crescent-shape-in-opengl)

---

<div class="post-metadata">

**Author:** ![MaxH](https://community.khronos.org/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@MaxH](https://community.khronos.org/u/MaxH)\
**Post date:** [September 2, 2011, 10:22am UTC](https://community.khronos.org/t/drawing-2d-crescent/65512/3 "2011-09-02T10:22:39Z")

</div>

> [@xEnOnn](#):
>
> ```auto
> 
> while (angle<(2.0f*PI)) {
> angle += step;
> }
> }
> 
> ```

Do you realize that this block of 3 lines has no effect on what gets drawn?  
Comment it out and run your code, you’ll see what I mean.

Concerning your drawing issue, I think you have misdiagnosed the problem.  
Change GL\_POLYGON to GL\_POINTS and run your code.  
You’ll see that nothing is being overdrawn.  
The code (as posted) is not generating an inner curve of vertices.  
I recommend working in point mode until you’re sure the vertices of both  
the inner and outer arc are being generated correctly.  
Then, switch to POLY mode and worry about how to use the vertices to make polygons.
