Example:
void init_display(void) { glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("lescegra sample"); glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); }
Example:
static LsgCamera* camera; static LsgNode* scene; void init_scene(void) { LsgPerspectiveCam* pcam; LsgCoords* coords; pcam = LsgPerspectiveCam_create(); vertex_assign(pcam->location, 3.0, 4.0, 2.0); vertex_assign(pcam->lookat, 0.0, 0.0, 0.0); vertex_assign(pcam->up, 0.0, 1.0, 0.0); pcam->fovy = 45.0; pcam->aspect = 1.0; pcam->dmin = 0.1; pcam->dmax = 10.0; coords = LsgCoords_create(1.0); camera = (LsgCamera*)pcam; scene = (LsgNode*)coords; }
void display(void) { LsgFrustum viewfrustum; LsgFrustum_init(&viewfrustum, matrix_identity, matrix_identity); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); camera->display(camera, &viewfrustum, scene); glFlush(); glutSwapBuffers(); }
clean method after calling update to allow external changes, for example from keyboard handler functions, to propagate up the scene graph.void animate(int ignore) { float now; now = (float)glutGet(GLUT_ELAPSED_TIME) / 1000.0; scene->update(scene, now); scene->clean(scene); glutPostRedisplay(); }