Hello, I need help!!!

Hi, I am really new to OpenGL,
I draw the polygon using the code below:

 glBegin(GL_LINE_LOOP);
	glVertex2f(10.0f, 10.0f);
	glVertex2f(10.0f, 50.0f);
	glVertex2f(30.0f, 80.0f);
	glVertex2f(50.0f, 80.0f);
	glVertex2f(30.0f, 50.0f);
	glVertex2f(50.0f, 20.0f);
	glVertex2f(30.0f, 30.0f);
	glEnd();	 

But when I change the coding above to:

 glBegin(GL_POLYGON);
        glVertex2f(10.0f, 10.0f);
	glVertex2f(10.0f, 50.0f);
	glVertex2f(30.0f, 80.0f);
	glVertex2f(50.0f, 80.0f);
	glVertex2f(30.0f, 50.0f);
	glVertex2f(50.0f, 20.0f);
	glVertex2f(30.0f, 30.0f);
	glEnd(); 

The polygon shape is changed. Can anyone help me in this. I try to fix the problem for a long time, but I still can’t solve the problem. I hope anyone can help me this.

The polygon shape is “changed” because the polygon is concave and only convex polygons are guaranteed to be drawn correctly. See page 16 in the OpenGL 2.0 spec (page 30 of the PDF).

To fix this you can split your concave polygon into two or more convex polygons.

Thanks!