#include // OpenGL Utility Toolkit void display(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear the buffer for (int i=0; i<20;i++){ // Draw some random data glColor4f( (double)(i%3)/3., // Set the color (R,G,B,alpha) (double)(i%2)/2., (double)(i)/10., 0.2); glTranslatef( 0.04*(double)i-0.1, // Translate the origin (x,y,z) 0.004*(double)(i*i)-0.1, 0.); glutSolidSphere(0.05,32,32); // Draw a sphere (radius, slices, stacks) glutWireCube(0.4); // Draw a cube with size 0.4 } glutSwapBuffers(); } int main(int argc, char* argv[]){ glutInit(&argc, argv); // Initialise Glut glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(700,700); // Define and create window glutCreateWindow("PiTP OpenGL Demo"); glutDisplayFunc(display); // Define drawing callback function glEnable(GL_BLEND); // Enable transparancy glBlendFunc(GL_SRC_ALPHA, GL_ONE); glutMainLoop(); // Give control away return 0; }