opengl-intro: sinus_cosinus.c

File sinus_cosinus.c, 618 bytes (added by msitar, 15 years ago)

Izris funkcije sinus in cosinus

Line 
1#include <GL/glut.h>
2#include <math.h>
3
4float x;
5float y;
6
7void 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  glTranslatef(0.0, -1.5, 0.0);
19  glBegin(GL_LINE_STRIP);
20  for(x=-3.14;x<=3.14;x+=0.6)
21  {
22    y=cos(x);
23    glVertex2f(x, y);
24  }
25  glEnd(); 
26  glFlush();
27}
28
29
30int main(int argc, char *argv[])
31{
32  glutInit(&argc,argv);
33  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
34  glutCreateWindow("C GLUT program");
35  glutDisplayFunc(display);
36  glutMainLoop();
37  return 0;
38}