-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flurry.txt
69 lines (53 loc) · 1.12 KB
/
Flurry.txt
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
#include<Windows.h>
#include<gl/GL.h>
#include<gl/glut.h>
#include <iostream>
float R = 0.2;
float G = .7;
float B = 0.5;
int random(int a) {
return (rand() % a);
}
float random2(int a) {
return (rand() % a);
}
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glPointSize(4.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640, 0.0, 480);
}
void flurry()
{
for (size_t i = 0; i < 200; i++)
{
GLint x = random(640);
GLint y = random(480);
GLint lingth = random(200);
R = (random2(10) / 10.0);
G = (random2(10) / 10.0);
B = (random2(10) / 10.0);
glBegin(GL_POLYGON);
glColor3f(R, G, B);
glVertex2i(x - lingth, y);
glVertex2i(x, y - lingth);
glVertex2i(x + lingth, y);
glVertex2i(x, y + lingth);
glEnd();
glFlush();
}
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(50, 50);
glutCreateWindow("Flurry");
glutDisplayFunc(flurry);
myInit();
glutMainLoop();
}