#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#include <math.h>

void renderer(void);
void initialSetup(void);
void changeSize(GLsizei w, GLsizei h);

int main (int argc, const char * argv[]) 
{
    glutInit(&argc, (char **)argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("Spiral");
    glutDisplayFunc(renderer);
    glutReshapeFunc(changeSize);
    initialSetup();
    glutMainLoop();
    return 0;
}

void renderer(void)
{
    GLfloat ang, x, y, z = -50;
    
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
    glRotatef(90,1,0,0);
    glColor3f(1,0,0);
    glBegin(GL_LINE_STRIP);
    for(ang = 0; ang < 10 * 3.14; ang += .1)
    {
        x = 70 *sin(ang);
        y = 70 *cos(ang);
        z += .75;
        glVertex3f(x,y,z);
    }
    glEnd();
    glPopMatrix();
    glFlush();
}

void changeSize(GLsizei w, GLsizei h)
{
    GLfloat sideRange = 200;
    
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-sideRange, sideRange, -sideRange, sideRange, sideRange, -sideRange);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}


void initialSetup(void)
{
    glClearColor(0.0, 0.0, 0.0, 1.0);
}