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

#define SEED 31415926
#define MAX_V 10000
#define DIV_V 5000.0
#define SUB_V 1


#define MY_PI 3.14159
#define ANG_INCR MY_PI / 8
#define ANG_ROT .005

void renderer(void);
void initialSetup(void);
void changeSize(GLsizei w, GLsizei h);
void tf(int blah);
int rand2();

long long lastseed;

float lastang;

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

void renderer()
{
    int last=0;
    float ang;
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glRotatef(45,1,1,0);
    glPushMatrix();
    glutWireCube(80);
    
    glPushMatrix();
    glScalef(2, 1, 3);
    glTranslatef(-80, -90, 0);
    glutWireCube(70);
    glPopMatrix();
    
    glPushMatrix();
    glTranslatef(-80, 90, 0);
    glutWireCube(60);
    glPopMatrix();
    
    glPopMatrix();
    glutSwapBuffers();
}

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)
{
    lastang =0;

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glPolygonMode(GL_BACK, GL_LINE);
    glPolygonMode(GL_FRONT, GL_FILL);
    
    glClearColor(0.0, 0.0, 0.0, 1.0);
}


int rand2()
{
    lastseed = lastseed * 16807 % 2147483647;
    return lastseed;
}

