-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompGraphHW1.cpp
100 lines (68 loc) · 1.53 KB
/
CompGraphHW1.cpp
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
#include <GL/freeglut.h>
#include <vector>
struct Square {
float scale;
Square() : scale(1.0f) {}
};
float a = 0.01;
double width = 5;
double x1 = 0.3;
float elapsedTime = 0.0f;
std::vector<Square> squares;
void createsquare() {
glBegin(GL_LINES);
glColor3ub(255, 255, 255);
glVertex2f(x1, x1);
glVertex2f(x1, -x1);
glColor3ub(255, 255, 255);
glVertex2f(x1, -x1);
glVertex2f(-x1, -x1);
glColor3ub(255, 255, 255);
glVertex2f(-x1, -x1);
glVertex2f(-x1, x1);
glColor3ub(255, 255, 255);
glVertex2f(-x1, x1);
glVertex2f(x1, x1);
glEnd();
}
void mydisplay() {
glClear(GL_COLOR_BUFFER_BIT);
for (auto& square : squares) {
glPushMatrix();
glScalef(square.scale, square.scale, 1.0f);
createsquare();
glPopMatrix();
}
glutSwapBuffers();
}
void myidle()
{
float delta = 0.0003f;
elapsedTime += delta;
//glTranslatef(-0.001, -0.001, 0);
//glPushMatrix();
//glScalef(1 + a * 0.01, 1 + a * 0.01, 0);
//glRotatef(a, 0, 0, 1);
for (auto& square : squares) {
square.scale += delta;
}
if (elapsedTime > 0.5f) {
squares.push_back(Square());
elapsedTime = 0.0f;
//createsquare();
}
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitWindowSize(512, 512);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow("title");
glClearColor(0, 0, 0, 1);
squares.push_back(Square());
glutDisplayFunc(mydisplay);
glutIdleFunc(myidle);
glutMainLoop();
return 0;
}