Getting the corresponding background window but not getting the polygon


Hi there, thanks for clicking into a beginner’s post.

I think this question is simple for you guys. But it really stuck me for a while. Here is the scenario,
I want to draw polygon in my scene.
Below is the simple program for that. i could’t identify the error?
Can any one help me in this?

//#include<Windows.h>   // first include Windows.h header file which is required    


// Init_OpenGL() function    
void Init_OpenGL()
	glClearColor(1, 1, 1, 1);
		// load the identity of matrix by clearing it.    
	gluOrtho2D(0, 1000, 0, 1000);


void polyGon() {
		glVertex2d(100, 100);
		glVertex2d(200, 100);
		glVertex2d(200, 200);
		glVertex2d(150, 250);
		glVertex2d(100, 200);
void display() {

	glClear(GL_COLOR_BUFFER_BIT);// clearing the window or remove all drawn objects  
	glColor3f(1.0, 0.0, 0.0);
	glutSwapBuffers(); //redraws the windoew and completes itn finite time


int main(int argc, char** argv)
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);// initialize glut 		
	glutInitWindowPosition(50, 50);// set window location  
	glutInitWindowSize(700, 500);// set window size  
	glutCreateWindow("Draw polyGon");
	Init_OpenGL();// call Init_OpenGL() function  
	glutDisplayFunc(display);// call glutDisplayFunc() function & pass parameter as display() function  

	glutMainLoop();//glutMainLoop() is used to redisplay the objects

	return 0;

Take a look at this section. In the last line, you’re not calling a function (missing parens).

Going forward, I recommend that you enable full compiler warnings from your compiler and fix the warnings it flags. In fact, tell it to fail the compile on warnings. That’ll save you a lot of time.

Also, start Checking for OpenGL Errors. That would have given you a clue that something was wrong as well.


Thank you so much…Now i am getting the result.
Can you help me to zoom the polygon which i drew and suggest me tutorial which i can follow.