opengl-intro: sinus_2.c
File sinus_2.c, 450 bytes (added by , 16 years ago) |
---|
Line | |
---|---|
1 | #include <GL/glut.h> |
2 | #include <math.h> |
3 | |
4 | float x; |
5 | float y; |
6 | |
7 | void display() |
8 | { |
9 | glClear(GL_COLOR_BUFFER_BIT); |
10 | glBegin(GL_LINE_STRIP); |
11 | for(x=-3.14;x<=3.14;x+=0.6) |
12 | { |
13 | y=sin(x); |
14 | glVertex2f(x/3.14, 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 | } |