-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation.c
executable file
·64 lines (48 loc) · 1.5 KB
/
animation.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
#include <GL/glut.h>
/* 正方形のサイズを指定 */
GLdouble s = 0.2;
/* 再描写時に実行される関数*/
void display(void) {
/* 画面全体を指定した色で塗りつぶす */
glClear(GL_COLOR_BUFFER_BIT);
/* 線の色を指定: 赤 */
glColor3d(1.0, 0.0, 0.0);
/* 描写 */
glBegin(GL_LINE_LOOP);
/* 図形の頂点を指定 */
glVertex2d(-s,-s);
glVertex2d(-s, s);
glVertex2d( s, s);
glVertex2d( s,-s);
glEnd();
/* まだ実行されていない命令をすべて実行 */
glFlush();
}
/* 100ミリ秒ごとに実行される関数 */
void timer(int value) {
/* 正方形のサイズを増加 */
s += 0.01;
/* 画面を再描写 */
glutPostRedisplay();
/* 100ミリ秒後に再実行 */
glutTimerFunc(100, timer, 0);
}
int main(int argc, char **argv){
glutInit(&argc, argv);
/* ウィンドウの位置とサイズを指定 */
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
/* ウィンドウを生成 */
glutCreateWindow("test");
/* 背景色を指定: 白 */
glutInitDisplayMode(GLUT_RGBA);
glClearColor(1.0, 1.0, 1.0, 1.0);
/* 画面を再描写するときに実行される関数を指定
(初期化、ウィンドウサイズ変更時など) */
glutDisplayFunc(display);
/* 100ミリ秒後に timer() を実行 */
glutTimerFunc(100, timer, 0);
/* ウィンドウが閉じられるまでループ */
glutMainLoop();
return 0;
}