Changeset 880

Show
Ignore:
Timestamp:
08/04/07 08:41:39 (1 year ago)
Author:
allenb
Message:

- Updated display to make line charts look better
- Added perfMon frame rate to the display

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/fcptr_stable_jun07/Source/System/Statistics/Foregrounds/OSGPerfMonitorForeground.cpp

    r867 r880  
    218218 
    219219   std::vector<std::string> output_lines;       // This will be the list of lines of text 
     220 
     221   // Put some basic stats at the top of the output 
     222   boost::format stats_formatter("FPS: %s"); 
     223   std::string stats_line = boost::str(stats_formatter % PerfMonitor::the()->getFrameRate(10)); 
     224   output_lines.push_back(stats_line); 
    220225    
    221226   // compute the max length of the prefix strings ("   sample_name") 
     
    231236   // Now create the lines of text 
    232237   OSG_ASSERT(mode_names.count(render_mode) == 1); 
    233    std::string mode_name = mode_names[render_mode]; 
    234    std::ostringstream ostring; 
     238   std::string mode_name = mode_names[render_mode];    
    235239   std::string header_string = boost::str( 
    236240         boost::format("%s%s %=10s %=10s %=7s") % mode_name 
     
    409413   std::vector<OSG::Color4f> chart_colors; 
    410414   OSG::Color4f bg_color = getBgColor(); 
    411    OSG::Color4f chart_color1 = (bg_color * 1.2f); 
    412    OSG::Color4f chart_color2 = (bg_color * 0.8f); 
    413    chart_color1[3] = chart_color2[3] = bg_color[3]
     415   OSG::Color4f chart_color1 = OSG::Color4f(1.0,1.0,1.0,0.0); 
     416   OSG::Color4f chart_color2 = (bg_color * 0.2f); 
     417   chart_color2[3] = 0.4
    414418   chart_colors.push_back(chart_color1); 
    415419   chart_colors.push_back(chart_color2); 
     
    431435 
    432436      // Skip the first line since it is the header and skip another to get to bottom of sample line 
    433       glTranslatef(0.0, -sample_height, 0.0); 
     437      unsigned num_header_lines(2); 
     438      for (unsigned i=0;i<num_header_lines;i++) 
     439      {  glTranslatef(0.0, -sample_height, 0.0); } 
    434440      glTranslatef(0.0, -sample_height, 0.0); 
    435441 
     
    438444      { 
    439445         // Draw border box 
    440          glColor3fv(chart_colors[next_base_color_idx].getValuesRGBA()); 
     446         glColor4fv(chart_colors[next_base_color_idx].getValuesRGBA()); 
    441447         next_base_color_idx += 1; 
    442448         if (next_base_color_idx >= chart_colors.size()) 
  • branches/fcptr_stable_jun07/Source/System/Statistics/Foregrounds/testPerfMonitorForeground.cpp

    r867 r880  
    8585           perfmon_fg->cycleMode();         
    8686           break; 
     87        case 'S': 
     88        case 's': 
     89           mgr->setStatistics(!mgr->getStatistics()); 
     90           break; 
    8791 
    8892        // Output help about the controls 
     
    9498          std::cerr << "\nControls:" 
    9599                    << "ESC: Exit application\n" 
    96                     << "m: Switch stat mode.\n" 
     100                    << "m/M: Switch stat mode.\n" 
     101                    << "s: Cycle stats display.\n" 
    97102                    << std::endl; 
    98103       } 
  • branches/fcptr_stable_jun07/Source/System/Statistics/PerfMonitor/OSGPerfMonitor.cpp

    r858 r880  
    44#include <OpenSG/OSGBaseInitFunctions.h> 
    55#include <OpenSG/OSGSingletonHolder.ins> 
     6#include <OpenSG/OSGBaseFunctions.h> 
    67 
    78OSG_USING_NAMESPACE 
     
    125126} 
    126127 
     128 
     129float PerfMonitorBase::getFrameRate(unsigned avgOverFrames) 
     130{ 
     131   if (0 == avgOverFrames) 
     132   {  
     133      return mFrameRate;  
     134   } 
     135   else 
     136   { 
     137      avgOverFrames = OSG::osgMin(avgOverFrames, unsigned(mFrameTimes.size())); 
     138      float av_frame_time = std::accumulate(mFrameTimes.begin(), mFrameTimes.begin()+avgOverFrames, 0.0) 
     139                         / float(avgOverFrames); 
     140      float frame_rate = 1.0/av_frame_time; 
     141      return frame_rate; 
     142   } 
     143} 
     144 
     145 
    127146unsigned PerfMonitorBase::max_samples = 500; 
    128147 
  • branches/fcptr_stable_jun07/Source/System/Statistics/PerfMonitor/OSGPerfMonitor.h

    r857 r880  
    217217   bool getEnabled() 
    218218   { return mEnabled; } 
    219    float getFrameRate() 
    220    { return mFrameRate; } 
     219 
     220   /** Return the average frame rate. 
     221    *  avgOverFrames: If 0, then over all frames we know about. 
     222    */ 
     223   float getFrameRate(unsigned avgOverFrames=0); 
     224 
    221225   frame_times_vector_t getFrameTimes() 
    222226   { return frame_times_vector_t(mFrameTimes.begin(), mFrameTimes.end()); }