Program outline

#include <cave_ogl.h>

void app_init(int argc,char **argv), app_compute(void), gfx_init(void), gfx_draw(void);

main(int argc,char **argv)     
    { 
    CAVEConfigure(&argc,argv,NULL);
    app_init(argc,argv);
    CAVEInit();
    CAVEInitApplication(gfx_init,0);
    CAVEDisplay(gfx_draw,0);
    while (!CAVEgetbutton(CAVE_ESCKEY))
        app_compute();
    CAVEExit();
    }   

void app_init(int argc,char **argv)
    {
    /* ... allocate shared memory & initialize data ... */
    }

void app_compute(void)
    {
    /* ... compute; update shared data ... */
    }

void gfx_init(void)
    {
    /* ... define materials & textures ... */
    }

void gfx_draw(void)
    {
    /* Do NOT set up projection */
   
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    /* ... render ... */
   
    /* Do NOT call SwapBuffers */
    }

next