aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/vgui_fpspanel.cpp
diff options
context:
space:
mode:
authorMichael Sartain <[email protected]>2014-10-02 08:25:55 -0700
committerMichael Sartain <[email protected]>2014-10-02 08:25:55 -0700
commit55ed12f8d1eb6887d348be03aee5573d44177ffb (patch)
tree3686f7ca78c780cd9a3d367b79a9d9250c1be7c0 /mp/src/game/client/vgui_fpspanel.cpp
parent* Added support for Visual C++ 2013 Express to VPC (diff)
downloadsource-sdk-2013-55ed12f8d1eb6887d348be03aee5573d44177ffb.tar.xz
source-sdk-2013-55ed12f8d1eb6887d348be03aee5573d44177ffb.zip
Updated the SDK with the latest code from the TF and HL2 branches.
Diffstat (limited to 'mp/src/game/client/vgui_fpspanel.cpp')
-rw-r--r--mp/src/game/client/vgui_fpspanel.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/mp/src/game/client/vgui_fpspanel.cpp b/mp/src/game/client/vgui_fpspanel.cpp
index aec28add..a1e88875 100644
--- a/mp/src/game/client/vgui_fpspanel.cpp
+++ b/mp/src/game/client/vgui_fpspanel.cpp
@@ -18,6 +18,7 @@
#include "filesystem.h"
#include "../common/xbox/xboxstubs.h"
#include "steam/steam_api.h"
+#include "tier0/cpumonitoring.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -209,6 +210,28 @@ void GetFPSColor( int nFps, unsigned char ucColor[3] )
}
//-----------------------------------------------------------------------------
+// Purpose: Set the color appropriately based on the CPU's frequency percentage
+//-----------------------------------------------------------------------------
+void GetCPUColor( float cpuPercentage, unsigned char ucColor[3] )
+{
+ // These colors are for poor CPU performance
+ ucColor[0] = 255; ucColor[1] = 0; ucColor[2] = 0;
+
+ if ( cpuPercentage >= kCPUMonitoringWarning1 )
+ {
+ // Excellent CPU performance
+ ucColor[0] = 10;
+ ucColor[1] = 200;
+ }
+ else if ( cpuPercentage >= kCPUMonitoringWarning2 )
+ {
+ // Medium CPU performance
+ ucColor[0] = 220;
+ ucColor[1] = 220;
+ }
+}
+
+//-----------------------------------------------------------------------------
// Purpose:
// Input :
//-----------------------------------------------------------------------------
@@ -272,6 +295,17 @@ void CFPSPanel::Paint()
GetFPSColor( nFps, ucColor );
g_pMatSystemSurface->DrawColoredText( m_hFont, x, 2, ucColor[0], ucColor[1], ucColor[2], 255, "%3i fps on %s", nFps, engine->GetLevelName() );
}
+
+ const CPUFrequencyResults frequency = GetCPUFrequencyResults();
+ double currentTime = Plat_FloatTime();
+ const double displayTime = 5.0f; // Display frequency results for this long.
+ if ( frequency.m_GHz > 0 && frequency.m_timeStamp + displayTime > currentTime )
+ {
+ int lineHeight = vgui::surface()->GetFontTall( m_hFont );
+ // Optionally print out the CPU frequency monitoring data.
+ GetCPUColor( frequency.m_percentage, ucColor );
+ g_pMatSystemSurface->DrawColoredText( m_hFont, x, lineHeight + 2, ucColor[0], ucColor[1], ucColor[2], 255, "CPU frequency percent: %3.1f%% Min percent: %3.1f%%", frequency.m_percentage, frequency.m_lowestPercentage );
+ }
}
}
m_lastRealTime = gpGlobals->realtime;