so i have some points to draw a shape using GL_Polygon it gives right result for convex shape i want to make concave polygon shape there are many methods written on the internet i have difficulty understanding it some one help me it will be very appreciated.
#include <windows.h> // use as needed for your system
#include <glut.h>
//<<<<<<<<<<<<<<<<<<<<<<< myInit >>>>>>>>>>>>>>>>>>>>
void mydisplay(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0); // set the bg color to a bright white
glColor3f(0.0f, 1.0f, 1.0f); // set the drawing color to black
glPointSize(4.0);
//glutSolidCube(0.5);
//glutWireTeapot(1.5);
//set the point size to 4 by 4 pixels
glMatrixMode(GL_PROJECTION);// set up appropriate matrices- to be explained
glLoadIdentity();// to be explained
gluOrtho2D(0.0, 640.0, 0.0, 480.0);// to be explained
}
//<<<<<<<<<<<<<<<<<<<<<<<< myDisplay >>>>>>>>>>>>>>>>>
// the redraw function
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glEnable(GL_STENCIL_TEST); // clear the screen
glBegin(GL_POLYGON);
glColor3f(0.0f, 1.5f, 2.5f);
glVertex2i(0 + 100, 0 + 100);
glVertex2i(2 + 100, 0 + 100);
glVertex2i(2 + 100, 2 + 100);
glVertex2i(4 + 100, 2 + 100);
glVertex2i(4 + 100, 0 + 100);
glVertex2i(6 + 100, 0 + 100);
glVertex2i(6 + 100, 0 + 100);
glVertex2i(6 + 100, 4 + 100);
glVertex2i(0 + 100, 4 + 100);
glEnd();
glFlush(); // send all output to display
}
//<<<<<<<<<<<<<<<<<<<<<<<< main >>>>>>>>>>>>>>>>>>>>>>
void main(int argc, char **argv)
{
glutInit(&argc, argv); // initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set the display mode
glutInitWindowSize(800, 600); // set the window size
glutInitWindowPosition(100, 150); // set the window position on the screen
glutCreateWindow("my Pangey"); // open the screen window(with its exciting title)
glutDisplayFunc(myDisplay); // register the redraw function
mydisplay();
glutMainLoop(); // go into a perpetual loop
}