CAVEConfigure(): This routine reads the CAVE configuration file, and parses the argc and argv variables for any user-specified configuration options. After this function is called the application is aware of how it is to run, number of walls and pipes, if it's stereo or mono, whether it will use trackd input or keyboard and mouse, etc.
CAVEInit(): This routine initializes the CAVELib application. The primary operation that it performs is to create the necessary display threads and data input thread that the CAVELib manages for the user. When this function returns it is in the parent process, aka "computation process", and it executes the rest of the code in main(). The new threads handle reading any input data and the rendering. There is one rendering thread for each pipe. These threads call the application's init application callback function once (whenever one is given), and each frame execute the the application's draw callback function.
CAVEInitApplication(): Takes a pointer to the application's graphics initialization function and passes it to each of the rendering threads. Since the rendering is not done by the computation process but instead by a separate rendering process, the initialization of graphical objects that need to be local to a thread must be done in each of the rendering threads, not in the parent process. The CAVEInitApplication() function sets a pointer to the intialization function that's passed to it. This tells the rendering thread what function to call, in this example init_gl(). Unless the CAVEInitApplication is called multiple times, the function that is passed to it is called once and only once, it should be called prior to CAVEDisplay, so that any constructs that are needed by draw exist, prior to its execution.
CAVEDisplay(): Takes a pointer to the application's drawing function which gets passed to each rendering thread. Each rendering thread calls this function one or more times depending upon how many viewports the thread is rendering for and how many eyes (mono, or stereo). Each thread is responsible for setting up the proper view matrix before executing the draw function, so the application should not call any functions that may affect the perspective matrix.
CAVEUsleep(): This forces the process to sleep for some number of micro seconds. The calling process also relinquishes control of the processor allowing the OS to schedule another thread to run. If this function is not called, the empty while loop could become a 'cpu hog' and slow down the application's frame rate.
CAVEExit(): This causes all CAVE threads to shutdown, clean-up, and exit, and restores the machine to its normal state.
Note: It is not required that CAVEInitApplication() be called if it is not needed. When it is used, it should be called after CAVEInit() but before CAVEDisplay(). Also, if CAVEConfigure() is not called, CAVEInit() will call it, this is not recommended as then any CAVELib configuration options passed in via argc and argv variables will not be processed.