Changeset 880
- Timestamp:
- 08/04/07 08:41:39 (1 year ago)
- Files:
-
- branches/fcptr_stable_jun07/Source/System/Statistics/Foregrounds/OSGPerfMonitorForeground.cpp (modified) (5 diffs)
- branches/fcptr_stable_jun07/Source/System/Statistics/Foregrounds/testPerfMonitorForeground.cpp (modified) (2 diffs)
- branches/fcptr_stable_jun07/Source/System/Statistics/PerfMonitor/OSGPerfMonitor.cpp (modified) (2 diffs)
- branches/fcptr_stable_jun07/Source/System/Statistics/PerfMonitor/OSGPerfMonitor.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/fcptr_stable_jun07/Source/System/Statistics/Foregrounds/OSGPerfMonitorForeground.cpp
r867 r880 218 218 219 219 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); 220 225 221 226 // compute the max length of the prefix strings (" sample_name") … … 231 236 // Now create the lines of text 232 237 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]; 235 239 std::string header_string = boost::str( 236 240 boost::format("%s%s %=10s %=10s %=7s") % mode_name … … 409 413 std::vector<OSG::Color4f> chart_colors; 410 414 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_color 1[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; 414 418 chart_colors.push_back(chart_color1); 415 419 chart_colors.push_back(chart_color2); … … 431 435 432 436 // 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); } 434 440 glTranslatef(0.0, -sample_height, 0.0); 435 441 … … 438 444 { 439 445 // Draw border box 440 glColor 3fv(chart_colors[next_base_color_idx].getValuesRGBA());446 glColor4fv(chart_colors[next_base_color_idx].getValuesRGBA()); 441 447 next_base_color_idx += 1; 442 448 if (next_base_color_idx >= chart_colors.size()) branches/fcptr_stable_jun07/Source/System/Statistics/Foregrounds/testPerfMonitorForeground.cpp
r867 r880 85 85 perfmon_fg->cycleMode(); 86 86 break; 87 case 'S': 88 case 's': 89 mgr->setStatistics(!mgr->getStatistics()); 90 break; 87 91 88 92 // Output help about the controls … … 94 98 std::cerr << "\nControls:" 95 99 << "ESC: Exit application\n" 96 << "m: Switch stat mode.\n" 100 << "m/M: Switch stat mode.\n" 101 << "s: Cycle stats display.\n" 97 102 << std::endl; 98 103 } branches/fcptr_stable_jun07/Source/System/Statistics/PerfMonitor/OSGPerfMonitor.cpp
r858 r880 4 4 #include <OpenSG/OSGBaseInitFunctions.h> 5 5 #include <OpenSG/OSGSingletonHolder.ins> 6 #include <OpenSG/OSGBaseFunctions.h> 6 7 7 8 OSG_USING_NAMESPACE … … 125 126 } 126 127 128 129 float 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 127 146 unsigned PerfMonitorBase::max_samples = 500; 128 147 branches/fcptr_stable_jun07/Source/System/Statistics/PerfMonitor/OSGPerfMonitor.h
r857 r880 217 217 bool getEnabled() 218 218 { 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 221 225 frame_times_vector_t getFrameTimes() 222 226 { return frame_times_vector_t(mFrameTimes.begin(), mFrameTimes.end()); }
