//============================================================================
// Name        : CCompareToPythonV2.cpp
// Author      : from ubuntu forums
// ubuntuforums.org/showthread.php?t=316601
// Version     :
// Copyright   : Your copyright notice
// Description : C++ graphical program to compare to Python
//============================================================================

// !# C++ version

#include <GL/glut.h>

#include <stdlib.h>

void scene()
{
	float angle = 0.0;
	glNewList(1, GL_COMPILE);
	
	glBegin(GL_POINTS);
	for(int i=0; i< 20000; i++)
	{
		glVertex3f((rand()%200-100)*.01, (rand()%200-100)*.01, (rand()%200-100)*.01);
	}
	glEnd();
	glEndList();
	
	while(true){
		glLoadIdentity();
		glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
		glTranslatef(0.0,0.0,-5.0);
		glRotatef(angle,1.0,1.0,0.0);
		glCallList(1);
		angle += 0.25;
		glutSwapBuffers();
	}
 }

int main(int argc, char** argv) 
{
	 glutInit(&argc, argv);
	 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	 glutInitWindowSize(640, 480);
	 glutCreateWindow("C++ with OpenGL Demo");
	 glEnable(GL_DEPTH_TEST);
	 glViewport(0, 0, 640, 480);
	 glMatrixMode(GL_PROJECTION);
	 glLoadIdentity();
	 gluPerspective(45.0, 1.33, 0.1, 100.0);
	 glMatrixMode(GL_MODELVIEW);
	 glutDisplayFunc(scene);
	 glutMainLoop();
 }