-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhut.c
More file actions
97 lines (49 loc) · 1.56 KB
/
hut.c
File metadata and controls
97 lines (49 loc) · 1.56 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include<GL/glut.h>
void renderFunction()
{
glClearColor(1.0,1.0,1.0,1.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.4,0.5);
glVertex2f(-0.75,0);
glVertex2f(0,0);
glEnd();
glColor3f(2.0,0.0,0.5);
glBegin(GL_POLYGON);
glVertex2f(-0.4,0.5);
glColor3f(0.0,1.0,0.0);
glVertex2f(0,0.4);
glVertex2f(0.4,0);
//glColor3f(2.0,0.0,0.5);
glVertex2f(0.7,0.5);
glVertex2f(1,0);
glVertex2f(0,0);
glEnd();
glColor3f(2.0,2.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(-0.75,0);
glVertex2f(-0.75,-0.7);
glVertex2f(0,-0.7);
glVertex2f(0,0);
glEnd();
glColor3f(0.5,1.0,1.5);
glBegin(GL_POLYGON);
glVertex2f(0,0);
glVertex2f(1,0);
glVertex2f(1,-0.7);
glVertex2f(0,-0.7);
glEnd();
glFlush();
}
int main (int argc, char** argv)
{
glutInit(&argc,argv); /*initialize the toolkit*/
glutInitDisplayMode(GLUT_SINGLE);/*set the display mode*/
glutInitWindowSize(700,500);//set the window size
glutInitWindowPosition(300,300);//set the window position on the screen
glutCreateWindow("square"); //open window with a title
glutDisplayFunc(renderFunction); //screen window is redrawn
glutMainLoop();
}