static void display(void) { char s[20]; static long fps; /* Draw the scene */ scene_redraw(); glDisable(GL_LIGHTING); /* Draw the displays */ glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(-1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(-1.0, -1.0, 0.0); glScalef(0.5, 0.5, 1.0); drawAEGraph(getAzimuth(), getElevation()); glTranslatef(1.2, 0.0, 0.0); drawCompass(getRoll()); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); /* Display fps */ sprintf(s, "%.2f", fps); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(-1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glColor3f(1.0, 1.0, 1.0); glTranslatef(0.75, 0.9, 0.0); glScalef(0.02, 0.02, 0.02); draw_text(s); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); /* Re-enable lighting */ glEnable(GL_LIGHTING); /* Use glFinish() so we don't spin the cube faster than we redraw */ glFinish(); glutSwapBuffers(); }
void display() { glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); // update maze offset Vector2D temp = m_player->displayPos(); m_maze_offset_x = m_screen->width()/2 - temp.x; m_maze_offset_y = m_screen->height()/2 - temp.y; m_maze ->display(m_maze_offset_x, m_maze_offset_y, *m_screen); m_player->display(m_maze_offset_x, m_maze_offset_y, *m_screen); if(m_film_grain) for(int i=0; i<m_screen->width(); i++) for(int j=0; j<m_screen->height(); j++) { if(rand()%m_film_grain_val!=1) continue; float r = (rand()%30+1)/255.0; Color3f c = m_screen->getPixel(i,j); c = c * 1.5f; m_screen->setPixel(i,j,c); } // draw compass if(m_maze->hasDest()) { drawCompass(3,3); } m_screen->render(); m_screen->clear(); if(m_show_data) { char* fps = new char[30]; sprintf(fps,"F: %i N: %i",(int)m_fps,m_maze->size()); glColor3f(0.3,0.2,0.2); glRasterPos2f(5,5); for(int i=0; fps[i]; i++) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,fps[i]); delete [] fps; } glutSwapBuffers(); }