/* ball.c /* A trivial CAVE demo program, demonstrating the most basic CAVE library /* functions. This program just draws a red ball in the front of the /* CAVE. No interaction (outside of moving around), and nothing changes. */ #include #include void init_gl(void),draw_ball(void); main(int argc,char **argv) { /* Initialize the CAVE */ CAVEConfigure(&argc,argv,NULL); CAVEInit(); /* 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_ball,0); /* Wait for the escape key to be hit */ while (!getbutton(ESCKEY)) sginap(10); /* Nap so that getbuttons don't overload the X server */ /* Clean up & exit */ CAVEExit(); } /* init_gl - GL initialization function. This function will be called exactly once by each of the drawing processes, at the beginning of the next frame after the pointer to it is passed to CAVEInitApplication. It defines and binds the light and material data for the rendering. */ void init_gl(void) { float redMaterial[] = { DIFFUSE, 1, 0, 0, LMNULL }; lmdef(DEFLMODEL,1,0,NULL); lmbind(LMODEL,1); lmdef(DEFLIGHT,1,0,NULL); lmbind(LIGHT0,1); lmdef(DEFMATERIAL,1,0,redMaterial); lmbind(MATERIAL,1); } /* draw_ball - the display function. This function is called by the CAVE library in the rendering processes' display loop. It draws a ball 1 foot in radius, 4 feet off the floor, and 1 foot in front of the front wall (assuming a 10' CAVE). */ void draw_ball(void) { float sphereParam[] = { 0, 4, -4, 1}; czclear(0,getgdesc(GD_ZMAX)); sphdraw(sphereParam); }