Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/
Upload File :
Current File : /var/www/html/venkat/check3/file/cg2013/pawan/A_1_4.c

#include <bits/stdc++.h>
#include <GL/glut.h>
using namespace std;
void init(float r, float g, float b){
	glClearColor(r,g,b,0.0); //set the background color
	glMatrixMode(GL_PROJECTION);
	gluOrtho2D(0.0,200.0,0.0,200.0);//x from 0 to 200, y from 0 to 200
}

void segment(void){
	
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0,1.0,1.0); //color of point
	//float x[5],y[5];
	//scanf("%f %f", &x1, &y1);
	//scanf("%f %f", &x2, &y2);
	float x[] = {10,90,120,90,10};
	float y[] = {10,10,80,150,150};
	int n = 5;


	glBegin(GL_POLYGON);
		for(int i = 0; i < n; i++){

			glVertex2i(x[i%n],y[i%n]); // co-ordinates of point
			//glVertex2i(x[(i+1) % n],y[(i+1)%n]);
		}
	glEnd();
	glFlush();
}

void main(int argc, int *argv[]){

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // GLUT_RGB stands for OpenGL Utility and RGB for red,green,blue
	glutInitWindowSize(500, 500); //Inbuilt func to set the size of window
	glutInitWindowPosition(200, 200);//inbuilt func to put the output window at position
	glutCreateWindow("GCV Assignment 1 Que 2");	//Title of Window
	init(0.0,0.0,0.0); //Function Called For background colors RGB respectively, vary between 0.0to 1.0 to  see the differn background colors
	glutDisplayFunc(segment); //function called segment
	glutMainLoop();
}