Repository navigation
Expand file tree
/
Copy pathTask_main.cpp
More file actions
145 lines (115 loc) · 5.88 KB
/
Copy pathTask_main.cpp
File metadata and controls
145 lines (115 loc) · 5.88 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
#include <windows.h>
#include <gl/gl.h>
#include <gl/glut.h>
void initGraphics(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(800, 600);
glutInitWindowPosition(100, 100);
glutCreateWindow("Four Buildings - Square Windows with Divider");
glutDisplayFunc([]() {
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0, 0, 0, 0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 800, 0, 600);
// ===================== Building 1 =====================
glColor3f(0.5, 0.5, 0.5);
glBegin(GL_QUADS);
glVertex2f(0, 0); glVertex2f(200, 0);
glVertex2f(200, 300); glVertex2f(0, 300);
glEnd();
glColor3f(1, 1, 0);
// ===== Column 1 (Building 1) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(20, 220); glVertex2f(80, 220); glVertex2f(80, 280); glVertex2f(20, 280); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(20, 130); glVertex2f(80, 130); glVertex2f(80, 190); glVertex2f(20, 190); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(20, 40); glVertex2f(80, 40); glVertex2f(80, 100); glVertex2f(20, 100); glEnd();
// ===== Column 2 (Building 1) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(120, 220); glVertex2f(180, 220); glVertex2f(180, 280); glVertex2f(120, 280); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(120, 130); glVertex2f(180, 130); glVertex2f(180, 190); glVertex2f(120, 190); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(120, 40); glVertex2f(180, 40); glVertex2f(180, 100); glVertex2f(120, 100); glEnd();
// ===================== Building 2 =====================
glColor3f(0.5, 0.5, 0.5);
glBegin(GL_QUADS);
glVertex2f(200, 0); glVertex2f(400, 0);
glVertex2f(400, 500); glVertex2f(200, 500);
glEnd();
glColor3f(1, 1, 0);
// ===== Column 1 (Building 2) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(220, 420); glVertex2f(280, 420); glVertex2f(280, 480); glVertex2f(220, 480); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(220, 320); glVertex2f(280, 320); glVertex2f(280, 380); glVertex2f(220, 380); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(220, 220); glVertex2f(280, 220); glVertex2f(280, 280); glVertex2f(220, 280); glEnd();
// ===== Column 2 (Building 2) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(320, 420); glVertex2f(382, 420); glVertex2f(382, 480); glVertex2f(320, 480); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(320, 320); glVertex2f(382, 320); glVertex2f(382, 380); glVertex2f(320, 380); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(320, 220); glVertex2f(382, 220); glVertex2f(382, 280); glVertex2f(320, 280); glEnd();
// ===================== Building 3 =====================
glColor3f(0.5, 0.5, 0.5);
glBegin(GL_QUADS);
glVertex2f(400, 0); glVertex2f(600, 0);
glVertex2f(600, 300); glVertex2f(400, 300);
glEnd();
glColor3f(1, 1, 0);
// ===== Column 1 (Building 3) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(420, 220); glVertex2f(480, 220); glVertex2f(480, 280); glVertex2f(420, 280); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(420, 130); glVertex2f(480, 130); glVertex2f(480, 190); glVertex2f(420, 190); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(420, 40); glVertex2f(480, 40); glVertex2f(480, 100); glVertex2f(420, 100); glEnd();
// ===== Column 2 (Building 3) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(520, 220); glVertex2f(580, 220); glVertex2f(580, 280); glVertex2f(520, 280); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(520, 130); glVertex2f(580, 130); glVertex2f(580, 190); glVertex2f(520, 190); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(520, 40); glVertex2f(580, 40); glVertex2f(580, 100); glVertex2f(520, 100); glEnd();
// ===================== Building 4 =====================
glColor3f(0.5, 0.5, 0.5);
glBegin(GL_QUADS);
glVertex2f(600, 0); glVertex2f(800, 0);
glVertex2f(800, 500); glVertex2f(600, 500);
glEnd();
glColor3f(1, 1, 0);
// ===== Column 1 (Building 4) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(620, 420); glVertex2f(680, 420); glVertex2f(680, 480); glVertex2f(620, 480); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(620, 320); glVertex2f(680, 320); glVertex2f(680, 380); glVertex2f(620, 380); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(620, 220); glVertex2f(680, 220); glVertex2f(680, 280); glVertex2f(620, 280); glEnd();
// ===== Column 2 (Building 4) =====
// Window 1
glBegin(GL_QUADS); glVertex2f(720, 420); glVertex2f(780, 420); glVertex2f(780, 480); glVertex2f(720, 480); glEnd();
// Window 2
glBegin(GL_QUADS); glVertex2f(720, 320); glVertex2f(780, 320); glVertex2f(780, 380); glVertex2f(720, 380); glEnd();
// Window 3
glBegin(GL_QUADS); glVertex2f(720, 220); glVertex2f(780, 220); glVertex2f(780, 280); glVertex2f(720, 280); glEnd();
// ===================== Dividing Lines =====================
glColor3f(0.2, 0.2, 0.2);
glLineWidth(2);
glBegin(GL_LINES);
glVertex2f(200, 0); glVertex2f(200, 500);
glVertex2f(400, 0); glVertex2f(400, 500);
glVertex2f(600, 0); glVertex2f(600, 500);
glEnd();
glFlush();
});
glutMainLoop();
}
int main(int argc, char* argv[]) {
initGraphics(argc, argv);
return 0;
}