/* File: sv4.c */ #include #include #include #include #include static GLUquadricObj *g_sphereObj; static int g_ndraw = 0; int hAud; void oglexDraw(void){ float magenta[4] = { 1.0, 0.0, 1.0, 1.0 }; float cyan[4] = { 0.0, 1.0, 1.0, 1.0 }; double alpha; float x, y, z; alpha = 2.0*M_PI*((float)g_ndraw/(float)60); x = 3.0*cos(alpha); y = 5.0; z = 3.0*sin(alpha)-4.0; AUDupdateFloats(hAud, "ModifyFm", 4, 0.2, 100.0, z*2 + 16, .402); glClearColor(0., 0., 0., 0.); glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); glPushMatrix(); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, cyan); glTranslatef(0.0, 5.0, -4.0); gluSphere(g_sphereObj, 1.0, 15, 15); glPopMatrix(); glPushMatrix(); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, magenta); glTranslatef(x, y, z); gluSphere(g_sphereObj, 1.0, 15, 15); glPopMatrix(); g_ndraw++; } void oglexInit(void) { glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); g_sphereObj = gluNewQuadric(); } main(int argc, char **argv) { char audfile[100]; if (argc != 2) { fprintf(stderr, "Usage: %s audfile\n", *argv); exit(44); } strcpy(audfile, argv[1]); if (!BeginSoundServer()) { printf("Error: couldn't find a running copy of VSS.\n"); exit (44); } if ((hAud = AUDinit(audfile)) < 0) { EndSoundServer(); exit(44); } /* Initialize the CAVE */ CAVEConfigure(&argc,argv,NULL); CAVEInit(); /* Give the library a pointer to the GL initialization function */ CAVEInitApplication(oglexInit, NULL); /* Give the library a pointer to the drawing function */ CAVEDisplay(oglexDraw, NULL); /* Wait for the escape key to be hit */ while (!CAVEgetbutton(CAVE_ESCKEY)) sginap(10); AUDterminate(hAud); EndSoundServer(); /* Clean up & exit */ CAVEExit(); }