-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlabtask-1.cpp
More file actions
161 lines (126 loc) · 3.35 KB
/
labtask-1.cpp
File metadata and controls
161 lines (126 loc) · 3.35 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include<GL/gl.h>
#include<GL/glut.h>
void display(void)
{
/* clear all pixels */
glClear(GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f(0, 0., .0);
// glBegin(GL_POLYGON);
// // glVertex3f(0.25, 0.25, 0.0);
// // glVertex3f(0.75, 0.25, 0.0);
// // glVertex3f(0.75, 0.75, 0.0);
// // glVertex3f(0.25, 0.75, 0.0);
// glVertex2d(100,100 );
// glVertex2d(300,100 );
// glVertex2d(300,300);
// glVertex2d(100,300 );
// glEnd();
glColor3f(1, 0.4, 0.5);
glBegin(GL_POLYGON);
glVertex2i(200, 500);
glVertex2i(600, 500);
glVertex2i(700, 350);
glVertex2i(300, 350);
glEnd();
glColor3f(0, 1.0, 0.0);
glBegin(GL_TRIANGLES);
glVertex2i(200, 500);
glVertex2i(100, 350);
glVertex2i(300, 350);
glEnd();
glColor3f(1, 1.3, 1.3);
glBegin(GL_POLYGON);
glVertex2i(100, 350);
glVertex2i(300, 350);
glVertex2i(300, 100);
glVertex2i(100, 100);
glEnd();
glColor3f(0.5, 0.2, 0.4);
glBegin(GL_POLYGON);
glVertex2i(150, 250);
glVertex2i(250, 250);
glVertex2i(250, 100);
glVertex2i(150, 100);
glEnd();
glColor3f(0.1, 0.2, 0.3);
glBegin(GL_POLYGON);
glVertex2i(300, 350);
glVertex2i(700, 350);
glVertex2i(700, 100);
glVertex2i(300, 100);
glEnd();
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2i(330, 320);
glVertex2i(450, 320);
glVertex2i(450, 230);
glVertex2i(330, 230);
glEnd();
// glColor3f(0.7, 0.3, 0.7);
// glLineWidth(8);
// glBegin(GL_LINES);
// glVertex2i(390, 320);
// glVertex2i(390, 230);
// glVertex2i(330, 273);
// glVertex2i(450, 273);
// glEnd();
glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2i(530, 320);
glVertex2i(650, 320);
glVertex2i(650, 230);
glVertex2i(530, 230);
glEnd();
// glColor3f(0.1, 0.7, 0.5);
// glLineWidth(5);
// glBegin(GL_LINES);
// glVertex2i(590, 320);
// glVertex2i(590, 230);
// glVertex2i(530, 273);
// glVertex2i(650, 273);
// glEnd();
// glColor3f(1, 1, 1.0);
// glBegin(GL_POLYGON);
// glVertex2d(100,100 );
// glVertex2d(300,100 );
// glVertex2d(300, 300);
// glVertex2d(100, 300 );
// glEnd();
/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush();
}
void init(void)
{
/* select clearing (background) color */
glClearColor(0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
//Applies subsequent matrix operations to the projection matrix stack
glLoadIdentity(); //by deault ide.
// glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
gluOrtho2D(0, 1000, 0, 1000);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("hello");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ISO C requires main to return int. */
}