mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 19:39:41 +00:00
Added a more detailed fps counter displaying the triangle and batch count
This commit is contained in:
parent
022f0fd5bd
commit
18e4b73a86
8 changed files with 81 additions and 23 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
|
#include <OgreRenderWindow.h>
|
||||||
|
|
||||||
#include <MyGUI_WidgetManager.h>
|
#include <MyGUI_WidgetManager.h>
|
||||||
|
|
||||||
|
@ -112,8 +113,17 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// update GUI
|
// update GUI
|
||||||
if(mShowFPS)
|
if(mFpsLevel == 1)
|
||||||
|
{
|
||||||
mEnvironment.mWindowManager->wmSetFPS(mOgre->getFPS());
|
mEnvironment.mWindowManager->wmSetFPS(mOgre->getFPS());
|
||||||
|
}
|
||||||
|
else if(mFpsLevel == 2) //detailed
|
||||||
|
{
|
||||||
|
Ogre::RenderWindow* window = mOgre->getWindow();
|
||||||
|
mEnvironment.mWindowManager->wmSetDetailedFPS(window->getLastFPS(),
|
||||||
|
window->getTriangleCount(),
|
||||||
|
window->getBatchCount());
|
||||||
|
}
|
||||||
|
|
||||||
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
|
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
|
||||||
|
|
||||||
|
@ -157,7 +167,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||||
OMW::Engine::Engine(Cfg::ConfigurationManager& configurationManager)
|
OMW::Engine::Engine(Cfg::ConfigurationManager& configurationManager)
|
||||||
: mOgre (0)
|
: mOgre (0)
|
||||||
, mPhysicEngine (0)
|
, mPhysicEngine (0)
|
||||||
, mShowFPS (false)
|
, mFpsLevel(0)
|
||||||
, mDebug (false)
|
, mDebug (false)
|
||||||
, mVerboseScripts (false)
|
, mVerboseScripts (false)
|
||||||
, mNewGame (false)
|
, mNewGame (false)
|
||||||
|
@ -331,7 +341,7 @@ void OMW::Engine::go()
|
||||||
MWScript::registerExtensions (mExtensions);
|
MWScript::registerExtensions (mExtensions);
|
||||||
|
|
||||||
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
||||||
mExtensions, mShowFPS, mNewGame);
|
mExtensions, mFpsLevel, mNewGame);
|
||||||
|
|
||||||
// Create sound system
|
// Create sound system
|
||||||
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre->getRoot(),
|
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre->getRoot(),
|
||||||
|
@ -451,9 +461,9 @@ void OMW::Engine::setSoundUsage(bool soundUsage)
|
||||||
mUseSound = soundUsage;
|
mUseSound = soundUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMW::Engine::showFPS(bool showFps)
|
void OMW::Engine::showFPS(int level)
|
||||||
{
|
{
|
||||||
mShowFPS = showFps;
|
mFpsLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMW::Engine::setEncoding(const std::string& encoding)
|
void OMW::Engine::setEncoding(const std::string& encoding)
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace OMW
|
||||||
OEngine::Physic::PhysicEngine* mPhysicEngine;
|
OEngine::Physic::PhysicEngine* mPhysicEngine;
|
||||||
std::string mCellName;
|
std::string mCellName;
|
||||||
std::string mMaster;
|
std::string mMaster;
|
||||||
bool mShowFPS;
|
int mFpsLevel;
|
||||||
bool mDebug;
|
bool mDebug;
|
||||||
bool mVerboseScripts;
|
bool mVerboseScripts;
|
||||||
bool mNewGame;
|
bool mNewGame;
|
||||||
|
@ -128,7 +128,7 @@ namespace OMW
|
||||||
void addMaster(const std::string& master);
|
void addMaster(const std::string& master);
|
||||||
|
|
||||||
/// Enable fps counter
|
/// Enable fps counter
|
||||||
void showFPS(bool showFps);
|
void showFPS(int level);
|
||||||
|
|
||||||
/// Enable debug mode:
|
/// Enable debug mode:
|
||||||
/// - non-exclusive input
|
/// - non-exclusive input
|
||||||
|
|
|
@ -75,8 +75,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio
|
||||||
("plugin", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
("plugin", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
||||||
->multitoken(), "plugin file(s)")
|
->multitoken(), "plugin file(s)")
|
||||||
|
|
||||||
("fps", boost::program_options::value<bool>()->implicit_value(true)
|
("fps", boost::program_options::value<int>()->implicit_value(1)
|
||||||
->default_value(false), "show fps counter")
|
->default_value(0), "fps counter detail (0 = off, 1 = fps counter, 2 = full detail)")
|
||||||
|
|
||||||
("debug", boost::program_options::value<bool>()->implicit_value(true)
|
("debug", boost::program_options::value<bool>()->implicit_value(true)
|
||||||
->default_value(false), "debug mode")
|
->default_value(false), "debug mode")
|
||||||
|
@ -200,7 +200,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio
|
||||||
engine.setNewGame(variables["new-game"].as<bool>());
|
engine.setNewGame(variables["new-game"].as<bool>());
|
||||||
|
|
||||||
// other settings
|
// other settings
|
||||||
engine.showFPS(variables["fps"].as<bool>());
|
engine.showFPS(variables["fps"].as<int>());
|
||||||
engine.setDebugMode(variables["debug"].as<bool>());
|
engine.setDebugMode(variables["debug"].as<bool>());
|
||||||
engine.setSoundUsage(!variables["nosound"].as<bool>());
|
engine.setSoundUsage(!variables["nosound"].as<bool>());
|
||||||
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
|
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
|
|
||||||
HUD::HUD(int width, int height, bool fpsSwitch)
|
HUD::HUD(int width, int height, int fpsLevel)
|
||||||
: Layout("openmw_hud_layout.xml")
|
: Layout("openmw_hud_layout.xml")
|
||||||
{
|
{
|
||||||
setCoord(0,0, width, height);
|
setCoord(0,0, width, height);
|
||||||
|
@ -37,10 +37,28 @@ HUD::HUD(int width, int height, bool fpsSwitch)
|
||||||
|
|
||||||
getWidget(crosshair, "Crosshair");
|
getWidget(crosshair, "Crosshair");
|
||||||
|
|
||||||
getWidget(fpsbox, "FPSBox");
|
|
||||||
getWidget(fpscounter, "FPSCounter");
|
|
||||||
|
|
||||||
fpsbox->setVisible(fpsSwitch);
|
MyGUI::WidgetPtr fpsBoxAdvanced;
|
||||||
|
MyGUI::WidgetPtr fpsBoxDefault;
|
||||||
|
|
||||||
|
getWidget(fpsBoxDefault, "FPSBox");
|
||||||
|
getWidget(fpsBoxAdvanced, "FPSBoxAdv");
|
||||||
|
if ( fpsLevel == 2 ){
|
||||||
|
fpsBoxDefault->setVisible(false);
|
||||||
|
fpsbox = fpsBoxAdvanced;
|
||||||
|
getWidget(fpscounter, "FPSCounterAdv");
|
||||||
|
}else if ( fpsLevel == 1 ){
|
||||||
|
fpsBoxAdvanced->setVisible(false);
|
||||||
|
fpsbox = fpsBoxDefault;
|
||||||
|
getWidget(fpscounter, "FPSCounter");
|
||||||
|
}else{
|
||||||
|
fpsBoxDefault->setVisible(false);
|
||||||
|
fpsBoxAdvanced->setVisible(false);
|
||||||
|
|
||||||
|
getWidget(fpscounter, "FPSCounter");
|
||||||
|
}
|
||||||
|
getWidget(trianglecounter, "TriangleCounter");
|
||||||
|
getWidget(batchcounter, "BatchCounter");
|
||||||
|
|
||||||
compass->setImageTexture("textures\\compass.dds");
|
compass->setImageTexture("textures\\compass.dds");
|
||||||
crosshair->setImageTexture("textures\\target.dds");
|
crosshair->setImageTexture("textures\\target.dds");
|
||||||
|
@ -59,6 +77,15 @@ void HUD::setFPS(float fps)
|
||||||
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HUD::setTriangleCount(size_t count)
|
||||||
|
{
|
||||||
|
trianglecounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::setBatchCount(size_t count)
|
||||||
|
{
|
||||||
|
batchcounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||||
|
}
|
||||||
|
|
||||||
void HUD::setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
void HUD::setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace MWGui
|
||||||
class HUD : public OEngine::GUI::Layout
|
class HUD : public OEngine::GUI::Layout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HUD(int width, int height, bool fpsSwitch);
|
HUD(int width, int height, int fpsLevel);
|
||||||
void setStats(int h, int hmax, int m, int mmax, int s, int smax);
|
void setStats(int h, int hmax, int m, int mmax, int s, int smax);
|
||||||
void setWeapIcon(const char *str);
|
void setWeapIcon(const char *str);
|
||||||
void setSpellIcon(const char *str);
|
void setSpellIcon(const char *str);
|
||||||
|
@ -41,6 +41,8 @@ namespace MWGui
|
||||||
void setEffect(const char *img);
|
void setEffect(const char *img);
|
||||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
||||||
void setFPS(float fps);
|
void setFPS(float fps);
|
||||||
|
void setTriangleCount(size_t count);
|
||||||
|
void setBatchCount(size_t count);
|
||||||
|
|
||||||
MyGUI::ProgressPtr health, magicka, stamina;
|
MyGUI::ProgressPtr health, magicka, stamina;
|
||||||
MyGUI::StaticImagePtr weapImage, spellImage;
|
MyGUI::StaticImagePtr weapImage, spellImage;
|
||||||
|
@ -53,6 +55,8 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::WidgetPtr fpsbox;
|
MyGUI::WidgetPtr fpsbox;
|
||||||
MyGUI::StaticTextPtr fpscounter;
|
MyGUI::StaticTextPtr fpscounter;
|
||||||
|
MyGUI::StaticTextPtr trianglecounter;
|
||||||
|
MyGUI::StaticTextPtr batchcounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapWindow : public OEngine::GUI::Layout
|
class MapWindow : public OEngine::GUI::Layout
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame)
|
const Compiler::Extensions& extensions, int fpsLevel, bool newGame)
|
||||||
: environment(environment)
|
: environment(environment)
|
||||||
, nameDialog(nullptr)
|
, nameDialog(nullptr)
|
||||||
, raceDialog(nullptr)
|
, raceDialog(nullptr)
|
||||||
|
@ -41,7 +41,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
, shown(GW_ALL)
|
, shown(GW_ALL)
|
||||||
, allowed(newGame ? GW_None : GW_ALL)
|
, allowed(newGame ? GW_None : GW_ALL)
|
||||||
{
|
{
|
||||||
showFPSCounter = fpsSwitch;
|
showFPSLevel = fpsLevel;
|
||||||
|
|
||||||
creationStage = NotStarted;
|
creationStage = NotStarted;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
int w = gui->getViewSize().width;
|
int w = gui->getViewSize().width;
|
||||||
int h = gui->getViewSize().height;
|
int h = gui->getViewSize().height;
|
||||||
|
|
||||||
hud = new HUD(w,h, showFPSCounter);
|
hud = new HUD(w,h, showFPSLevel);
|
||||||
menu = new MainMenu(w,h);
|
menu = new MainMenu(w,h);
|
||||||
map = new MapWindow();
|
map = new MapWindow();
|
||||||
stats = new StatsWindow(*this);
|
stats = new StatsWindow(*this);
|
||||||
|
@ -135,9 +135,11 @@ void WindowManager::update()
|
||||||
environment.mInputManager->setGuiMode(nextMode);
|
environment.mInputManager->setGuiMode(nextMode);
|
||||||
nextMode = GM_Game;
|
nextMode = GM_Game;
|
||||||
}
|
}
|
||||||
if (showFPSCounter)
|
if (showFPSLevel > 0)
|
||||||
{
|
{
|
||||||
hud->setFPS(mFPS);
|
hud->setFPS(mFPS);
|
||||||
|
hud->setTriangleCount(mTriangleCount);
|
||||||
|
hud->setBatchCount(mBatchCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,13 +156,15 @@ namespace MWGui
|
||||||
|
|
||||||
void setGuiMode(GuiMode newMode);
|
void setGuiMode(GuiMode newMode);
|
||||||
|
|
||||||
bool showFPSCounter;
|
int showFPSLevel;
|
||||||
float mFPS;
|
float mFPS;
|
||||||
|
size_t mTriangleCount;
|
||||||
|
size_t mBatchCount;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The constructor needs the main Gui object
|
/// The constructor needs the main Gui object
|
||||||
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame);
|
const Compiler::Extensions& extensions, int fpsLevel, bool newGame);
|
||||||
virtual ~WindowManager();
|
virtual ~WindowManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,6 +206,12 @@ namespace MWGui
|
||||||
MyGUI::Gui* getGui() const { return gui; }
|
MyGUI::Gui* getGui() const { return gui; }
|
||||||
|
|
||||||
void wmSetFPS(float fps) { mFPS = fps; }
|
void wmSetFPS(float fps) { mFPS = fps; }
|
||||||
|
void wmSetDetailedFPS(float fps, size_t triangleCount, size_t batchCount)
|
||||||
|
{
|
||||||
|
mFPS = fps;
|
||||||
|
mTriangleCount = triangleCount;
|
||||||
|
mBatchCount = batchCount;
|
||||||
|
}
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
||||||
///< Set value for the given ID.
|
///< Set value for the given ID.
|
||||||
|
|
|
@ -49,12 +49,19 @@
|
||||||
<Widget type="StaticImage" skin="StaticImage" position="0 0 32
|
<Widget type="StaticImage" skin="StaticImage" position="0 0 32
|
||||||
32" align="Center Center" name="Crosshair"/>
|
32" align="Center Center" name="Crosshair"/>
|
||||||
|
|
||||||
<!-- FPSCounter box -->
|
<!-- Basic FPSCounter box -->
|
||||||
|
|
||||||
<Widget type="Widget" skin="HUD_Box" position="12 12 28 21" align="Left Top"
|
<Widget type="Widget" skin="HUD_Box" position="12 12 28 21" align="Left Top"
|
||||||
name="FPSBox">
|
name="FPSBox">
|
||||||
<Widget type="StaticText" skin="NumFPS" position="3 3 21 17" name="FPSCounter"/>
|
<Widget type="StaticText" skin="NumFPS" position="3 3 21 17" name="FPSCounter"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
|
<!-- Advanced FPSCounter box -->
|
||||||
|
<Widget type="Widget" skin="HUD_Box" position="12 12 58 51" align="Left Top"
|
||||||
|
name="FPSBoxAdv">
|
||||||
|
<Widget type="StaticText" skin="NumFPS" position="3 3 51 17" name="FPSCounterAdv"/>
|
||||||
|
<Widget type="StaticText" skin="NumFPS" position="3 3 51 32" name="TriangleCounter"/>
|
||||||
|
<Widget type="StaticText" skin="NumFPS" position="3 3 51 47" name="BatchCounter"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
</Widget>
|
</Widget>
|
||||||
</MyGUI>
|
</MyGUI>
|
||||||
|
|
Loading…
Reference in a new issue