/* includes */
#include <stdio.h>
#include <stdlib.h>
#include <cave_ogl.h>
#include <GL/glut.h>
/* prototypes */
void display(void);
void init(void);
/* main */
int main(int argc, char **argv) {
/* Initialize the CAVE */
CAVEConfigure(&argc, argv, NULL);
CAVEInit();
CAVEInitApplication(init, 0);
/* Give the library a pointer to the drawing function */
CAVEDisplay(display, 0);
/* Wait for the escape key to be hit */
while (!CAVEgetbutton(CAVE_ESCKEY))
sginap(10);
/* Clean up & exit */
CAVEExit();
return(0);
}
/* ------------------------------------------------------------------------ */
void init(void) {
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
}
void display(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glPushMatrix();
glTranslatef(0.0, 100.0, 0.0);
glRotatef(30.0*CAVEGetTime(), 0.0, 1.0, 0.0);
glutSolidCube(50.0);
glPopMatrix();
}
Die CAVELib-Bibliotheken liegen im den Verzeichnissen /usr/local/CAVE/lib, /usr/local/CAVE/lib32 und /usr/local/CAVE/lib64. Je nachdem welche Art von Code erzeugt werden soll (-o32, -n32 oder -64), muß dem Compiler der jeweilige Pfad übergeben werden, mit zum Beispiel: -L/usr/local/CAVE/lib32.
Die folgenden CAVELib/OpenGL-Bibliotheken müssen zu einem ausführbaren Programm gelinkt werden: -lpfcave_ogl -lcave_ogl -lGL -lX11 -lXi -lm
Diese Makefile kompiliert das obige Beispielprogramm.
TARGET = cube_ogl SRC = $(TARGET).c CC = cc CFLAGS = -I/usr/local/CAVE/include -n32 $(OPT) OPT = -O CAVELIB = -L/usr/local/CAVE/lib32 -lcave_ogl -lGLU -lGL -lX11 -lXi -lm GLUTLIB = -lglut LIBS = $(GLUTLIB) $(CAVELIB) $(TARGET): $(SRC) $(CC) $(CFLAGS) $? -o $@ $(LIBS) run: $(TARGET) $(TARGET) clean: clobber: rm -f $(TARGET)