void display(void) { static char s[256], t[32]; static char* p; static int frames = 0; glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindFramebuffer(GL_FRAMEBUFFER, 0); //glBindFramebuffer(GL_FRAMEBUFFER, shadowBuffer); glUseProgram(shadowShaderID); // Render to our framebuffer glViewport(0,0,windowW,windowH); // Render on the whole framebuffer, complete from the lower left corner to the upper right glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(pan_x, pan_y, 0.0); gltbMatrix(); #if 0 /* glmDraw() performance test */ if (material_mode == 0) { if (facet_normal) glmDraw(model, GLM_FLAT); else glmDraw(model, GLM_SMOOTH); } else if (material_mode == 1) { if (facet_normal) glmDraw(model, GLM_FLAT | GLM_COLOR); else glmDraw(model, GLM_SMOOTH | GLM_COLOR); } else if (material_mode == 2) { if (facet_normal) glmDraw(model, GLM_FLAT | GLM_MATERIAL); else glmDraw(model, GLM_SMOOTH | GLM_MATERIAL); } #else glCallList(model_list); #endif drawTexToScreen(); glDisable(GL_LIGHTING); if (bounding_box) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_CULL_FACE); glColor4f(1.0, 0.0, 0.0, 0.25); glutSolidCube(2.0); glDisable(GL_BLEND); } glPopMatrix(); if (stats) { /* XXX - this could be done a _whole lot_ faster... */ int height = glutGet(GLUT_WINDOW_HEIGHT); glColor3ub(0, 0, 0); sprintf(s, "%s\n%d vertices\n%d triangles\n%d normals\n" "%d texcoords\n%d groups\n%d materials", model->pathname, model->numvertices, model->numtriangles, model->numnormals, model->numtexcoords, model->numgroups, model->nummaterials); shadowtext(5, height-(5+18*1), s); } /* spit out frame rate. */ frames++; if (frames > NUM_FRAMES) { sprintf(t, "%g fps", frames/elapsed()); frames = 0; } if (performance) { shadowtext(5, 5, t); } //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSwapBuffers(); glEnable(GL_LIGHTING); }
void display(void) { static char s[256], t[32]; static char* p; static int frames = 0; glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(pan_x, pan_y, 0.0); gltbMatrix(); if(!start) { #if 0 // glmDraw() performance test if (material_mode == 0) { if (facet_normal) glmDraw(model, GLM_FLAT); else glmDraw(model, GLM_SMOOTH); } else if (material_mode == 1) { if (facet_normal) glmDraw(model, GLM_FLAT | GLM_COLOR); else glmDraw(model, GLM_SMOOTH | GLM_COLOR); } else if (material_mode == 2) { if (facet_normal) glmDraw(model, GLM_FLAT | GLM_MATERIAL); else glmDraw(model, GLM_SMOOTH | GLM_MATERIAL); } #else glCallList(model_list); #endif glDisable(GL_LIGHTING); if (bounding_box) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_CULL_FACE); glColor4f(1.0, 0.0, 0.0, 0.25); glutSolidCube(2.0); glDisable(GL_BLEND); } } else { //glDisable(GL_LIGHTING); newDrawMechanism(); glEnable(GL_LIGHTING); } glPopMatrix(); if (stats) { /* XXX - this could be done a _whole lot_ faster... */ int height = glutGet(GLUT_WINDOW_HEIGHT); glColor3ub(0, 0, 0); sprintf(s, "%s\n%d vertices\n%d triangles\n%d normals\n" "%d texcoords\n%d groups\n%d materials", model->pathname, model->numvertices, model->numtriangles, model->numnormals, model->numtexcoords, model->numgroups, model->nummaterials); shadowtext(5, height-(5+18*1), s); } /* spit out frame rate. */ frames++; if (frames > NUM_FRAMES) { sprintf(t, "%g fps", frames/elapsed()); frames = 0; } if (performance) { shadowtext(5, 5, t); } glutSwapBuffers(); glEnable(GL_LIGHTING); }