|
|
@@ -29,6 +29,7 @@
|
|
|
#include "Font.h"
|
|
|
#include "Text.h"
|
|
|
#include "SystemUI.h"
|
|
|
+#include "UIElement.h"
|
|
|
#include "DebugHud.h"
|
|
|
|
|
|
#include "../../DebugNew.h"
|
|
|
@@ -60,7 +61,7 @@ DebugHud::DebugHud(Context* context) :
|
|
|
Object(context),
|
|
|
profilerMaxDepth_(M_MAX_UNSIGNED),
|
|
|
profilerInterval_(1000),
|
|
|
- useRendererStats_(false),
|
|
|
+ useRendererStats_(true),
|
|
|
mode_(DEBUGHUD_SHOW_NONE),
|
|
|
fpsTimeSinceUpdate_(FPS_UPDATE_INTERVAL),
|
|
|
fpsFramesSinceUpdate_(0),
|
|
|
@@ -69,23 +70,28 @@ DebugHud::DebugHud(Context* context) :
|
|
|
SystemUI* ui = GetSubsystem<SystemUI>();
|
|
|
UIElement* uiRoot = ui->GetRoot();
|
|
|
|
|
|
+ layout_ = new UIElement(context_);
|
|
|
+ uiRoot->AddChild(layout_);
|
|
|
+
|
|
|
+ layout_->SetSize(uiRoot->GetSize());
|
|
|
+
|
|
|
statsText_ = new Text(context_);
|
|
|
statsText_->SetAlignment(HA_LEFT, VA_TOP);
|
|
|
statsText_->SetPriority(100);
|
|
|
statsText_->SetVisible(false);
|
|
|
- uiRoot->AddChild(statsText_);
|
|
|
+ layout_->AddChild(statsText_);
|
|
|
|
|
|
modeText_ = new Text(context_);
|
|
|
modeText_->SetAlignment(HA_LEFT, VA_BOTTOM);
|
|
|
modeText_->SetPriority(100);
|
|
|
modeText_->SetVisible(false);
|
|
|
- uiRoot->AddChild(modeText_);
|
|
|
+ layout_->AddChild(modeText_);
|
|
|
|
|
|
profilerText_ = new Text(context_);
|
|
|
profilerText_->SetAlignment(HA_RIGHT, VA_TOP);
|
|
|
profilerText_->SetPriority(100);
|
|
|
profilerText_->SetVisible(false);
|
|
|
- uiRoot->AddChild(profilerText_);
|
|
|
+ layout_->AddChild(profilerText_);
|
|
|
|
|
|
SubscribeToEvent(E_POSTUPDATE, ATOMIC_HANDLER(DebugHud, HandlePostUpdate));
|
|
|
}
|
|
|
@@ -97,6 +103,23 @@ DebugHud::~DebugHud()
|
|
|
profilerText_->Remove();
|
|
|
}
|
|
|
|
|
|
+void DebugHud::SetExtents(bool useRootExtents, const IntVector2& position, const IntVector2& size)
|
|
|
+{
|
|
|
+ if (useRootExtents)
|
|
|
+ {
|
|
|
+ SystemUI* ui = GetSubsystem<SystemUI>();
|
|
|
+ UIElement* uiRoot = ui->GetRoot();
|
|
|
+
|
|
|
+ layout_->SetPosition(IntVector2::ZERO);
|
|
|
+ layout_->SetSize(uiRoot->GetSize());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ layout_->SetPosition(position);
|
|
|
+ layout_->SetSize(size);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void DebugHud::Update(float timeStep)
|
|
|
{
|
|
|
Graphics* graphics = GetSubsystem<Graphics>();
|
|
|
@@ -105,13 +128,11 @@ void DebugHud::Update(float timeStep)
|
|
|
return;
|
|
|
|
|
|
// Ensure UI-elements are not detached
|
|
|
- if (!statsText_->GetParent())
|
|
|
+ if (!layout_->GetParent())
|
|
|
{
|
|
|
SystemUI* ui = GetSubsystem<SystemUI>();
|
|
|
UIElement* uiRoot = ui->GetRoot();
|
|
|
- uiRoot->AddChild(statsText_);
|
|
|
- uiRoot->AddChild(modeText_);
|
|
|
- uiRoot->AddChild(profilerText_);
|
|
|
+ uiRoot->AddChild(layout_);
|
|
|
}
|
|
|
|
|
|
if (statsText_->IsVisible())
|
|
|
@@ -138,7 +159,16 @@ void DebugHud::Update(float timeStep)
|
|
|
}
|
|
|
|
|
|
String stats;
|
|
|
- stats.AppendWithFormat("FPS %d\nTriangles %u\nBatches %u\nViews %u\nLights %u\nShadowmaps %u\nOccluders %u",
|
|
|
+
|
|
|
+ unsigned singlePassPrimitives = graphics->GetSinglePassPrimitives();
|
|
|
+ unsigned editorPrimitives = graphics->GetNumPrimitives() - renderer->GetNumPrimitives();
|
|
|
+
|
|
|
+ if (singlePassPrimitives)
|
|
|
+ stats.AppendWithFormat("FPS %d\nTriangles (All passes) %u\nTriangles (Single pass) %u\nTriangles (Editor) %u\n", fps_, primitives, singlePassPrimitives, editorPrimitives);
|
|
|
+ else
|
|
|
+ stats.AppendWithFormat("FPS %d\nTriangles %u\n", fps_, primitives);
|
|
|
+
|
|
|
+ stats.AppendWithFormat("Batches %u\nViews %u\nLights %u\nShadowmaps %u\nOccluders %u",
|
|
|
fps_,
|
|
|
primitives,
|
|
|
batches,
|