/* GLUT sample: usage matrix transforms for view model through OpenGL */
#include <stdlib.h>
#include <glut.h>
#include <math.h>
#include <time.h>

void Display( void )
{
  double x, t = clock() / (double)CLOCKS_PER_SEC;

  /* Clear the frame */
  glClear(GL_COLOR_BUFFER_BIT);

  /* Reset OpenGL coordinate system (obsolete) */
  glLoadIdentity();

  /* Draw lines */
  glBegin(GL_LINES);
    glColor3d(1, 0, 0);
    glVertex2d(-1, 0);
    glVertex2d(1, 0);

    glColor3d(0, 1, 0);
    glVertex2d(0, -1);
    glVertex2d(0, 1);
  glEnd();

  glBegin(GL_LINE_STRIP);
  glColor3d(1, 1, 1);
  for (x = -1; x <= 1; x += 0.01)
  {
    glVertex2d(x, sin(t + x * 3.5));
  }
  glEnd();

  glFinish();
  glutSwapBuffers();
  glutPostRedisplay();
} /* End of 'Display' function */

void Keyboard( unsigned char Key, int X, int Y )
{
  if (Key == 27)
    exit(0);
} /* End of 'Keyboard' function */

int main( int ArgC, char *ArgV[] )
{
  glutInit(&ArgC, ArgV);
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

  glutInitWindowPosition(0, 0);
  glutInitWindowSize(600, 600);
  glutCreateWindow("CGC'2018");

  glutDisplayFunc(Display);
  glutKeyboardFunc(Keyboard);

  glClearColor(0.3, 0.5, 0.7, 1);

  glutMainLoop();
} /* End of 'main' function */
