/* File: oglexSphere2.c */ #include "stdio.h" #include #include void oglexInit(void); void oglexDraw(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(oglexInit, NULL); /* Give the library a pointer to the drawing function */ CAVEDisplay(oglexDraw, NULL); /* Wait for the escape key to be hit */ while (!CAVEgetbutton(CAVE_ESCKEY)) sginap(10); /* Clean up & exit */ CAVEExit(); } static GLUquadricObj *g_sphereObj; static int g_ndraw = 0; void oglexInit(void) { glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); g_sphereObj = gluNewQuadric(); } void oglexDraw(void) { float magenta[4] = { 1.0, 0.0, 1.0, 1.0 }; float cyan[4] = { 0.0, 1.0, 1.0, 1.0 }; double alpha; float x, y, z; alpha = 2.0*M_PI*((float)g_ndraw/(float)60); x = 3.0*cos(alpha); y = 5.0; z = 3.0*sin(alpha)-4.0; glClearColor(0., 0., 0., 0.); glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); glPushMatrix(); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, cyan); glTranslatef(0.0, 5.0, -4.0); gluSphere(g_sphereObj, 1.0, 15, 15); glPopMatrix(); glPushMatrix(); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, magenta); glTranslatef(x, y, z); gluSphere(g_sphereObj, 1.0, 15, 15); glPopMatrix(); g_ndraw++; }