CAVELib Callbacks
Previous  Top  Next


There are three types of callbacks in the CAVELib; display, frame update, and initialization.

The graphics routine is passed to the CAVELib as a display callback function. The user's graphics routine is then called by the CAVELib's display loop for each view to be rendered. This approach allows the CAVELib to take care of all necessary projections and synchronization for the user, regardless of the VR device that is being used.

The rendering for each graphics window going to a VR device is done in a separate thread (see Multithreading below). When a stereo display is used, each display thread will call the application's display function twice per frame when in stereo, in mono-scopic mode it is called once per frame. The general rule is there are as many threads as there are pipes, and that for each thread the draw function is called once per frame - per eye - per channel - for a pipe. (For clarification a pipe can be thought of as a graphics card. Each video output from that graphics card/pipe is a channel.)

Because the application does not know in advance how often the display function will be called in each thread, a "frame function" callback is provided. This callback will always be called exactly once per frame in each rendering thread, prior to the display callback being called. This gives a user the ability to perform calculations once per frame in each thread.

The initialization callback will be called exactly once, at the beginning of the next frame after it is defined, or in the first frame if it is called prior to CAVEInit(). This can be used for any one-time display operations, such as defining materials and textures.

An application's display callback function is defined by passing a function pointer to CAVEDisplay(). The frame function is passed to CAVEFrameFunction(). The initialization callback is passed to CAVEInitApplication().