opengl-intro: sinus_1.c
File sinus_1.c, 455 bytes (added by , 16 years ago) |
---|
Line | |
---|---|
1 | #include <GL/glut.h> |
2 | #include <math.h> |
3 | |
4 | int i; |
5 | float y; |
6 | |
7 | void display() |
8 | { |
9 | glClear(GL_COLOR_BUFFER_BIT); |
10 | glBegin(GL_LINE_STRIP); |
11 | for(i=0;i<=10;i++) |
12 | { |
13 | y=sin((i-5)/5.0*3.14); |
14 | glVertex2f((i-5)/5.0, y/3.14); |
15 | } |
16 | glEnd(); |
17 | glFlush(); |
18 | } |
19 | |
20 | |
21 | int main(int argc, char *argv[]) |
22 | { |
23 | glutInit(&argc,argv); |
24 | glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); |
25 | glutCreateWindow("C GLUT program"); |
26 | glutDisplayFunc(display); |
27 | glutMainLoop(); |
28 | return 0; |
29 | } |