forked from jain02/Computer-Graphics-Lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquare.c
More file actions
49 lines (25 loc) · 1.05 KB
/
square.c
File metadata and controls
49 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<GL/glut.h>
void renderFunction()
{
glClearColor(0.0,0.0,0.0,0.0); /*specifies red,green,blue and alpha (opacity) values used by glclear to clear the color buffers*/
glClear(GL_COLOR_BUFFER_BIT);/*performs clear operation on one or more buffers at the same time*/
glColor3f(0.0,2.0,0.5);/* indicates the color for red, green and blue*/
//glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);/* indicates the clipping value for left, right , bottom, top, nearest and farthest value*/
glBegin(GL_POLYGON);
glVertex2f(0.5,0.5);
glVertex2f(-0.5,0.5);
glVertex2f(-0.5,-0.5);
glVertex2f(0.5,-0.5);
glEnd();
glFlush();
}
int main (int argc, char** argv)
{
glutInit(&argc,argv); /*initialize the toolkit*/
glutInitDisplayMode(GLUT_SINGLE);/*set the display mode*/
glutInitWindowSize(500,500);//set the window size
glutInitWindowPosition(100,100);//set the window position on the screen
glutCreateWindow("square"); //open window with a title
glutDisplayFunc(renderFunction); //screen window is redrawn
glutMainLoop();
}