|
CAVELib Sample Program 1
|
Previous Top Next |
| /* Initialize the CAVE */
|
| CAVEConfigure(&argc,argv,NULL);
|
|
|
|
|
| /* Give the library a pointer to the GL initialization function */
|
| CAVEInitApplication(init_gl,0);
|
|
|
|
|
| /* Give the library a pointer to the drawing function */
|
| CAVEDisplay(draw,0);
|
|
|
|
|
| /* Create the multiple processes/threads and
|
| start the display loop */
|
| CAVEInit();
|
|
|
|
|
| /* Wait for the escape key to be hit */
|
| while (!CAVEgetbutton(CAVE_ESCKEY)) {
|
|
|
| /* Nap so that this busy loop doesn't waste CPU time
|
| reset timeval struct every time for linux compatibility
|
| */
|
| CAVEUSleep(10);
|
|
|
| }
|
|
|
| /* Clean up & exit */
|
| CAVEExit();
|
| return 0;
|
| float redMaterial[] = { 1, 0, 0, 1 };
|
|
|
| /* Enable light source 0 */
|
| glEnable(GL_LIGHT0);
|
|
|
| /* Set material to color both front and back face to a diffuse red */
|
| glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, redMaterial);
|
|
|
| /* Create a glu quadric object */
|
| sphereObj = gluNewQuadric();
|
|
|
| /* Set clear color to black and clear both the screen and the zbuffer */
|
| glClearColor(0., 0., 0., 0.);
|
| glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
|
|
|
| /* Turn lighting on */
|
| glEnable(GL_LIGHTING);
|
|
|
| /* Draw a sphere */
|
| glPushMatrix();
|
| glTranslatef(0.0, 4.0, -4.0);
|
|
|
| /* Draw a sphere using GLU quadric object.
|
| Radius = 1
|
| Slices = 8
|
| Stacks = 8
|
| */
|
| gluSphere(sphereObj, 1.0, 8, 8);
|
| glPopMatrix();
|
|
|
| /* Turn lighting off */
|
| glDisable(GL_LIGHTING);
|
|
|