void HUD::renderCameraPosition(float x, float y) { glPushMatrix(); glLoadIdentity(); std::ostringstream temp; temp.precision(3); Vector3D position = m_camera->getPosition(); temp << "Position (" << position.x << ", " << position.y << ", " << position.z << ")"; renderSpacedBitmapString(x, y, 2, GLUT_BITMAP_HELVETICA_10, temp.str().c_str()); glPopMatrix(); }
void drawAxes() { //To prevent the view from disturbed on repaint //this push matrix call stores the current matrix state //and restores it once we are done with the arrow rendering glPushMatrix(); glColor3f(0,0,1); glPushMatrix(); glTranslatef(0,0, 0.8f); glutSolidCone(0.0325,0.2, 4,1); //Draw label glTranslatef(0,0.0625,0.225f); renderSpacedBitmapString(0,0,0,GLUT_BITMAP_HELVETICA_10, (char*)"Z"); glPopMatrix(); glutSolidCone(0.0225,1, 4,1); glColor3f(1,0,0); glRotatef(90,0,1,0); glPushMatrix(); glTranslatef(0,0,0.8f); glutSolidCone(0.0325,0.2, 4,1); //Draw label glTranslatef(0,0.0625,0.225f); renderSpacedBitmapString(0,0,0,GLUT_BITMAP_HELVETICA_10, (char*)"X"); glPopMatrix(); glutSolidCone(0.0225,1, 4,1); glColor3f(0,1,0); glRotatef(90,-1,0,0); glPushMatrix(); glTranslatef(0,0, 0.8f); glutSolidCone(0.0325,0.2, 4,1); //Draw label glTranslatef(0,0.0625,0.225f); renderSpacedBitmapString(0,0,0,GLUT_BITMAP_HELVETICA_10, (char*)"Y"); glPopMatrix(); glutSolidCone(0.0225,1, 4,1); glPopMatrix(); }
void onRender() { //Calculate fps totalFrames++; int current = glutGet(GLUT_ELAPSED_TIME); if((current - startTime) > 1000) { float elapsedTime = float(current-startTime); fps = ((float)(totalFrames * 1000) / elapsedTime) ; startTime = current; totalFrames=0; } snprintf(buffer, HUD_BUFFER_SIZE, "FPS: %3.2f", fps); resetPerspectiveProjection(); // Handle reshaping (preparing NiViewer) glViewport(0, 0, nw, nh); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, (GLfloat)nw / (GLfloat)nh, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glTranslatef(0,0,dist); glRotatef(rX,0,1,0); glRotatef(rY,1,0,0); renderModels(); setOrthoForFont(); glColor3f(1,1,1); //Show the fps renderSpacedBitmapString(20, 20, 0, GLUT_BITMAP_HELVETICA_12, buffer); glutSwapBuffers(); }