-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriAnim.c
66 lines (58 loc) · 1.36 KB
/
triAnim.c
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
#include<stdio.h>
#include<GL/glut.h>
#include <unistd.h>
#include<math.h>
#define PI 3.1415926535897932384626433832795
double x,y,j,i;
// function to initialize
void myInit (void)
{
// making background color black as first
// 3 arguments all are 0.0
glClearColor(0.0, 0.0, 0.0, 1.0);
}
void display (void)
{
while(1){
for(j=0.0; j<=1.0; j+=0.001)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(j, 1.0-j, j+j);
glBegin(GL_LINE_LOOP);
for (i = 0;i < 6.29;i += 0.001)
{
glVertex2f( j * cos(PI/2), j * sin(PI/2));
glVertex2f( j * cos(7* PI/6), j * sin(7 * PI/6));
glVertex2f( j * cos(11* PI/6), j * sin(11* PI/6));
}
glEnd();
glFlush();
}
for(j=1.0; j>=0.0; j-=0.001)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(j, 1.0-j, j+j);
glBegin(GL_LINE_LOOP);
for (i = 0;i < 6.29;i += 0.001)
{
glVertex2f( j * cos(PI/2), j * sin(PI/2));
glVertex2f( j * cos(7* PI/6), j * sin(7 * PI/6));
glVertex2f( j * cos(11* PI/6), j * sin(11* PI/6));
}
glEnd();
glFlush();
}
}
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
// giving window size in X- and Y- direction
glutInitWindowSize(500, 500);
// Giving name to window
glutCreateWindow("Triangle Animation");
myInit();
glutDisplayFunc(display);
glutMainLoop();
}