-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugOverlay.cs
More file actions
64 lines (52 loc) · 2.28 KB
/
DebugOverlay.cs
File metadata and controls
64 lines (52 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Mogre;
using System;
namespace Mogre.TutorialFramework
{
public class DebugOverlay
{
protected RenderWindow mWindow;
protected float timeSinceLastDebugUpdate = 1;
protected OverlayElement mGuiAvg;
protected OverlayElement mGuiCurr;
protected OverlayElement mGuiBest;
protected OverlayElement mGuiWorst;
protected OverlayElement mGuiTris;
protected OverlayElement mModesText;
protected string mAdditionalInfo = "";
public DebugOverlay(RenderWindow window)
{
mWindow = window;
var debugOverlay = OverlayManager.Singleton.GetByName("Core/DebugOverlay");
debugOverlay.Show();
mGuiAvg = OverlayManager.Singleton.GetOverlayElement("Core/AverageFps");
mGuiCurr = OverlayManager.Singleton.GetOverlayElement("Core/CurrFps");
mGuiBest = OverlayManager.Singleton.GetOverlayElement("Core/BestFps");
mGuiWorst = OverlayManager.Singleton.GetOverlayElement("Core/WorstFps");
mGuiTris = OverlayManager.Singleton.GetOverlayElement("Core/NumTris");
mModesText = OverlayManager.Singleton.GetOverlayElement("Core/NumBatches");
}
public string AdditionalInfo
{
set { mAdditionalInfo = value; }
get { return mAdditionalInfo; }
}
public void Update(float timeFragment)
{
if (timeSinceLastDebugUpdate > 0.5f)
{
var stats = mWindow.GetStatistics();
mGuiAvg.Caption = "Average FPS: " + stats.AvgFPS;
mGuiCurr.Caption = "Current FPS: " + stats.LastFPS;
mGuiBest.Caption = "Best FPS: " + stats.BestFPS + " " + stats.BestFrameTime + " ms";
mGuiWorst.Caption = "Worst FPS: " + stats.WorstFPS + " " + stats.WorstFrameTime + " ms";
mGuiTris.Caption = "Triangle Count: " + stats.TriangleCount;
mModesText.Caption = mAdditionalInfo;
timeSinceLastDebugUpdate = 0;
}
else
{
timeSinceLastDebugUpdate += timeFragment;
}
}
}
}