summaryrefslogtreecommitdiffhomepage
path: root/StarsEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-03 17:24:16 +0200
committerAki <please@ignore.pl>2022-04-03 17:24:16 +0200
commitcd57c84c5fe34c2ac548d6d119a9828a303923ef (patch)
treeaac3545bcb95bf0d30b8b356c91adc492c07d3a6 /StarsEx
parent150bd957db8eb19b1a07643317767ff5c3007f48 (diff)
downloadstarshatter-cd57c84c5fe34c2ac548d6d119a9828a303923ef.zip
starshatter-cd57c84c5fe34c2ac548d6d119a9828a303923ef.tar.gz
starshatter-cd57c84c5fe34c2ac548d6d119a9828a303923ef.tar.bz2
Removed video stats in Game
Diffstat (limited to 'StarsEx')
-rw-r--r--StarsEx/Game.cpp60
-rw-r--r--StarsEx/Game.h8
-rw-r--r--StarsEx/GameWinDX9.cpp36
-rw-r--r--StarsEx/GameWinDX9.h1
-rw-r--r--StarsEx/Mfd.cpp4
-rw-r--r--StarsEx/Starshatter.cpp1
-rw-r--r--StarsEx/Video.h4
-rw-r--r--StarsEx/VideoDX9.cpp10
8 files changed, 49 insertions, 75 deletions
diff --git a/StarsEx/Game.cpp b/StarsEx/Game.cpp
index f9bf31d..b7a4fb1 100644
--- a/StarsEx/Game.cpp
+++ b/StarsEx/Game.cpp
@@ -33,7 +33,7 @@ const double MAX_FRAME_TIME_NORMAL = 1.0 / 5.0;
Game::Game()
: world(0), video_factory(0), video(0), video_settings(0), soundcard(0),
- screen(0), totaltime(0),
+ screen(0),
status(Game::OK), exit_code(0)
{
Clock::Init();
@@ -67,9 +67,6 @@ Game::~Game()
delete video;
delete soundcard;
delete video_settings;
-
- if (status == EXIT)
- ShowStats();
}
// +--------------------------------------------------------------------+
@@ -175,7 +172,6 @@ Game::GameLoop()
if (!server) {
UpdateScreen();
- CollectStats();
}
wait_for_windows_events = false;
@@ -232,60 +228,6 @@ Game::GetInstance()
// +--------------------------------------------------------------------+
-void
-Game::CollectStats()
-{
- if (!totaltime) totaltime = Clock::GetInstance()->RealTime();
-
- if (video) {
- stats.nframe = video->GetStats().nframe;
- stats.nverts = video->GetStats().nverts;
- stats.npolys = video->GetStats().npolys;
- stats.nlines = video->GetStats().nlines;
- stats.ncalls += video->GetStats().ncalls;
-
- stats.total_verts += stats.nverts;
- stats.total_polys += stats.npolys;
- stats.total_lines += stats.nlines;
- }
-}
-
-// +--------------------------------------------------------------------+
-
-void
-Game::ShowStats()
-{
- if (server) return;
-
- totaltime = Clock::GetInstance()->RealTime() - totaltime;
-
- Print("\n");
- Print("Performance Data:\n");
- Print("-----------------\n");
-
- Print(" Time: %d msec\n", totaltime);
- Print(" Frames: %d\n", stats.nframe);
- Print(" Polys Rendered: %d\n", stats.total_polys);
- Print(" Lines Rendered: %d\n", stats.total_lines);
- Print(" Verts Rendered: %d\n", stats.total_verts);
- Print(" Render Calls: %d\n", stats.ncalls);
- Print("\n");
-
- Print("Performance Statistics:\n");
- Print("-----------------------\n");
-
- Print(" Frames/Second: %.2f\n", (stats.nframe * 1000.0) / totaltime);
- Print(" Polys/Frame: %.2f\n", (double) stats.total_polys / (double) stats.nframe);
- Print(" Polys/Call: %.2f\n", (double) stats.total_polys / (double) stats.ncalls);
- Print(" Polys/Second: %.2f\n", (stats.total_polys * 1000.0) / totaltime);
- Print(" Lines/Second: %.2f\n", (stats.total_lines * 1000.0) / totaltime);
- Print(" Verts/Second: %.2f\n", (stats.total_verts * 1000.0) / totaltime);
-
- Print("\n");
-}
-
-// +====================================================================+
-
DWORD Game::Frame()
{
return frame_number;
diff --git a/StarsEx/Game.h b/StarsEx/Game.h
index c3790f6..228d23f 100644
--- a/StarsEx/Game.h
+++ b/StarsEx/Game.h
@@ -49,8 +49,6 @@ public:
virtual void Pause(bool f);
int Status() const { return status; }
- const RenderStats& GetPolyStats() { return stats; }
-
//
// GENERAL GAME CLASS UTILITY METHODS:
//
@@ -71,12 +69,9 @@ public:
virtual void UpdateWorld();
virtual void GameState();
virtual void UpdateScreen();
- virtual void CollectStats();
virtual bool InitGame();
- virtual void ShowStats();
-
protected:
Universe* world;
VideoFactory* video_factory;
@@ -85,9 +80,6 @@ protected:
SoundCard* soundcard;
Screen* screen;
- RenderStats stats;
- DWORD totaltime;
-
int status;
int exit_code;
diff --git a/StarsEx/GameWinDX9.cpp b/StarsEx/GameWinDX9.cpp
index 9a63e36..671464e 100644
--- a/StarsEx/GameWinDX9.cpp
+++ b/StarsEx/GameWinDX9.cpp
@@ -70,8 +70,6 @@ GameWinDX9::Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow)
Print(" Initializing Game\n");
- stats.Clear();
-
if (!InitApplication(hInst)) { // Initialize shared things
Panic::Panic("Could not initialize the application.");
status = INIT_FAILED;
@@ -581,6 +579,40 @@ GameWinDX9::Run()
}
+void
+GameWinDX9::ShowStats()
+{
+ if (server) return;
+
+ auto total_time = Clock::GetInstance()->RealTime();
+ auto stats = Video::GetInstance()->GetStats();
+
+ Print("\n");
+ Print("Performance Data:\n");
+ Print("-----------------\n");
+
+ Print(" Time: %d msec\n", total_time);
+ Print(" Frames: %d\n", stats.nframe);
+ Print(" Polys Rendered: %d\n", stats.total_polys);
+ Print(" Lines Rendered: %d\n", stats.total_lines);
+ Print(" Verts Rendered: %d\n", stats.total_verts);
+ Print(" Render Calls: %d\n", stats.ncalls);
+ Print("\n");
+
+ Print("Performance Statistics:\n");
+ Print("-----------------------\n");
+
+ Print(" Frames/Second: %.2f\n", (stats.nframe * 1000.0) / total_time);
+ Print(" Polys/Frame: %.2f\n", (double) stats.total_polys / (double) stats.nframe);
+ Print(" Polys/Call: %.2f\n", (double) stats.total_polys / (double) stats.ncalls);
+ Print(" Polys/Second: %.2f\n", (stats.total_polys * 1000.0) / total_time);
+ Print(" Lines/Second: %.2f\n", (stats.total_lines * 1000.0) / total_time);
+ Print(" Verts/Second: %.2f\n", (stats.total_verts * 1000.0) / total_time);
+
+ Print("\n");
+}
+
+
int
GameWinDX9::MaxTexSize() const
{
diff --git a/StarsEx/GameWinDX9.h b/StarsEx/GameWinDX9.h
index ee316b8..ef86956 100644
--- a/StarsEx/GameWinDX9.h
+++ b/StarsEx/GameWinDX9.h
@@ -36,6 +36,7 @@ public:
virtual bool LoadPalette(PALETTEENTRY* pal, BYTE* inv);
virtual int Run() override;
+ void ShowStats();
int MaxTexSize() const;
int MaxTexAspect() const;
diff --git a/StarsEx/Mfd.cpp b/StarsEx/Mfd.cpp
index f79f2af..15731d8 100644
--- a/StarsEx/Mfd.cpp
+++ b/StarsEx/Mfd.cpp
@@ -25,7 +25,6 @@
#include "WeaponGroup.h"
#include "Sim.h"
#include "StarSystem.h"
-#include "Starshatter.h"
#include "Drive.h"
#include "QuantumDrive.h"
#include "Power.h"
@@ -1093,8 +1092,7 @@ MFD::DrawGameMFD()
if (lines <= 1) return;
- Starshatter* game = Starshatter::GetInstance();
- sprintf_s(txt, "Polys: %d", game->GetPolyStats().npolys);
+ sprintf_s(txt, "Polys: %d", Video::GetInstance()->GetStats().npolys);
DrawMFDText(t++, txt, txt_rect, DT_LEFT);
txt_rect.y += 10;
}
diff --git a/StarsEx/Starshatter.cpp b/StarsEx/Starshatter.cpp
index 77aaca5..3981917 100644
--- a/StarsEx/Starshatter.cpp
+++ b/StarsEx/Starshatter.cpp
@@ -803,7 +803,6 @@ Starshatter::GameLoop()
UpdateWorld();
GameState();
UpdateScreen();
- CollectStats();
/***
static DWORD vmf_time = 0;
diff --git a/StarsEx/Video.h b/StarsEx/Video.h
index 87cf1f9..a35a32e 100644
--- a/StarsEx/Video.h
+++ b/StarsEx/Video.h
@@ -50,8 +50,8 @@ struct RenderStats
int total_polys;
int total_lines;
- void Clear() { nverts = npolys = nlines = ncalls =
- total_verts = total_polys = total_lines = 0; }
+ RenderStats() : total_verts {0}, total_polys {0}, total_lines {0} {}
+ void Clear() { nverts = npolys = nlines = ncalls = 0; }
};
// +--------------------------------------------------------------------+
diff --git a/StarsEx/VideoDX9.cpp b/StarsEx/VideoDX9.cpp
index cf7ed68..c4dd09f 100644
--- a/StarsEx/VideoDX9.cpp
+++ b/StarsEx/VideoDX9.cpp
@@ -1935,6 +1935,8 @@ VideoDX9::DrawPolys(int npolys, Poly* polys)
if (SUCCEEDED(hr)) {
stats.nverts += nverts;
stats.npolys += num_tris;
+ stats.total_verts += nverts;
+ stats.total_polys += num_tris;
result = true;
}
}
@@ -2060,6 +2062,8 @@ VideoDX9::DrawScreenPolys(int npolys, Poly* polys, int blend)
else {
stats.nverts += num_verts;
stats.npolys += num_tris;
+ stats.total_verts += num_verts;
+ stats.total_polys += num_tris;
result = true;
}
}
@@ -2496,6 +2500,8 @@ VideoDX9::DrawSegment(Segment* segment)
} else {
stats.nverts += num_verts;
stats.npolys += num_tris;
+ stats.total_verts += num_verts;
+ stats.total_polys += num_tris;
result = true;
}
}
@@ -2739,6 +2745,8 @@ VideoDX9::DrawLines(int nlines, Vec3* points, Color c, int blend)
if (SUCCEEDED(hr)) {
stats.nverts += 2*nlines;
stats.nlines += nlines;
+ stats.total_verts += 2*nlines;
+ stats.total_lines += nlines;
result = true;
}
}
@@ -2810,6 +2818,8 @@ VideoDX9::DrawScreenLines(int nlines, float* points, Color c, int blend)
if (SUCCEEDED(hr)) {
stats.nverts += 2*nlines;
stats.nlines += nlines;
+ stats.total_verts += 2*nlines;
+ stats.total_lines += nlines;
result = true;
}
}