opengl-intro: sinus_3.c
File sinus_3.c, 473 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 | glScalef(1/3.14, 1/3.14, 1.0); |
11 | glBegin(GL_LINE_STRIP); |
12 | for(x=-3.14;x<=3.14;x+=0.6) |
13 | { |
14 | y=sin(x); |
15 | glVertex2f(x, y); |
16 | } |
17 | glEnd(); |
18 | glFlush(); |
19 | } |
20 | |
21 | |
22 | int main(int argc, char *argv[]) |
23 | { |
24 | glutInit(&argc,argv); |
25 | glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); |
26 | glutCreateWindow("C GLUT program"); |
27 | glutDisplayFunc(display); |
28 | glutMainLoop(); |
29 | return 0; |
30 | } |