#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <GL/glut.h>
#include <GL/gl.h>

int order=1;

void drawEverything(void)
	{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glEnable(GL_DEPTH_TEST);
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0, 1.0, 1.0, 10.0);
	glMatrixMode(GL_MODELVIEW);

	glLoadIdentity();
	glTranslatef(0.0, 0.0, -6.0);
	
	glColor3f(1.0, 1.0, 1.0);

	if (order == 1)
		{
		glRotatef(45.0, 1.0, 0.0, 0.0);
		glRotatef(90.0, 0.0, 1.0, 0.0);
		}
	else
		{
		glRotatef(90.0, 0.0, 1.0, 0.0);
		glRotatef(45.0, 1.0, 0.0, 0.0);
		}
	glutWireTorus(0.5, 2.0, 6, 12);

	glutSwapBuffers();
	}


static void key(unsigned char k, int x, int y)
	{
	if (k == 27)
		exit(0);
	else if (k == '1')
		order = 1;
	else if (k == '2')
		order = 2;
	glutPostRedisplay();
	}


int main(int argc, char *argv[])
	{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutCreateWindow("example");
	glutDisplayFunc(drawEverything);
	glutKeyboardFunc(key);
	glutMainLoop();
	return 0;
	}

