//============================================================================
// Name        : CCompareToPython.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>

class particle
{
public:
	float x, y, z;
	particle(){x=(rand()%200-100)*.01; y=(rand()%200-100)*.01; z=(rand()%200-100)*.01;};
	void draw()
	{
		glVertex3f(x, y, z);
	}
};

void scene()
{
	particle system[10000];
	float angle = 0.0;
	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);
		  glBegin(GL_POINTS);

		  for(int i=0; i< 10000; i++)
		  {
			  system[i].draw();
		  }

		  glEnd();
		  angle += 0.25;
		  glutSwapBuffers();
	}
}

int main(int argc, char* argv[])
{
	 glutInit(&argc, argv);
	 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	 glutInitWindowSize(640, 480);
	 glutCreateWindow("Python & 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();
 }
