// Why does OSX include glut differently? #include #include #include #include #include #define MIN (-1.0+r) #define MAX ( 1.0-r) #define abs(i) ((i<0.0)?-i:i) #define NBALLS 20 #define randf() ((float)rand()/(float)RAND_MAX) int rt=0; float px[NBALLS], py[NBALLS], pz[NBALLS], vx[NBALLS], vy[NBALLS], vz[NBALLS]; float tm,th; const float g = 9.8; const float r = 0.05; const float dt = 0.001; const float cor = 0.6; void init() { int i; srand(time(NULL)); for (i=0;i= MAX) { vx[i] *= -cor; px[i] = (px[i]<0)?MIN:MAX; } if (abs(py[i]) >= MAX) { vy[i] *= -cor; py[i] = (py[i]<0)?MIN:MAX; } if (abs(pz[i]) >= MAX) { vz[i] *= -cor; pz[i] = (pz[i]<0)?MIN:MAX; } } if (rt) { th += 0.2; if (th>360.0) th -= 360.0; } glutPostRedisplay(); } void draw() { int i; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(th,0.0,1.0,0.0); glRotatef(90.0,-1.0,0.0,0.0); glutWireCube(2.0); for (i=0;i