diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 7fa98f8e2..b8a71d2e7 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -7,6 +7,7 @@ #include #include +#include #include @@ -112,8 +113,17 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) } // update GUI - if(mShowFPS) + if(mFpsLevel == 1) + { 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); @@ -157,7 +167,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) OMW::Engine::Engine(Cfg::ConfigurationManager& configurationManager) : mOgre (0) , mPhysicEngine (0) - , mShowFPS (false) + , mFpsLevel(0) , mDebug (false) , mVerboseScripts (false) , mNewGame (false) @@ -331,7 +341,7 @@ void OMW::Engine::go() MWScript::registerExtensions (mExtensions); mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment, - mExtensions, mShowFPS, mNewGame); + mExtensions, mFpsLevel, mNewGame); // Create sound system mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre->getRoot(), @@ -451,9 +461,9 @@ void OMW::Engine::setSoundUsage(bool 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) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 443f790a4..259c44d11 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -66,7 +66,7 @@ namespace OMW OEngine::Physic::PhysicEngine* mPhysicEngine; std::string mCellName; std::string mMaster; - bool mShowFPS; + int mFpsLevel; bool mDebug; bool mVerboseScripts; bool mNewGame; @@ -128,7 +128,7 @@ namespace OMW void addMaster(const std::string& master); /// Enable fps counter - void showFPS(bool showFps); + void showFPS(int level); /// Enable debug mode: /// - non-exclusive input diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 933d1c48a..acb852020 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -75,8 +75,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio ("plugin", bpo::value()->default_value(StringsVector(), "") ->multitoken(), "plugin file(s)") - ("fps", boost::program_options::value()->implicit_value(true) - ->default_value(false), "show fps counter") + ("fps", boost::program_options::value()->implicit_value(1) + ->default_value(0), "fps counter detail (0 = off, 1 = fps counter, 2 = full detail)") ("debug", boost::program_options::value()->implicit_value(true) ->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()); // other settings - engine.showFPS(variables["fps"].as()); + engine.showFPS(variables["fps"].as()); engine.setDebugMode(variables["debug"].as()); engine.setSoundUsage(!variables["nosound"].as()); engine.setScriptsVerbosity(variables["script-verbose"].as()); diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 10740e224..ea9a85113 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -13,7 +13,7 @@ using namespace MWGui; -HUD::HUD(int width, int height, bool fpsSwitch) +HUD::HUD(int width, int height, int fpsLevel) : Layout("openmw_hud_layout.xml") { setCoord(0,0, width, height); @@ -37,10 +37,28 @@ HUD::HUD(int width, int height, bool fpsSwitch) 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"); crosshair->setImageTexture("textures\\target.dds"); @@ -59,6 +77,15 @@ void HUD::setFPS(float fps) fpscounter->setCaption(boost::lexical_cast((int)fps)); } +void HUD::setTriangleCount(size_t count) +{ + trianglecounter->setCaption(boost::lexical_cast(count)); +} + +void HUD::setBatchCount(size_t count) +{ + batchcounter->setCaption(boost::lexical_cast(count)); +} void HUD::setStats(int h, int hmax, int m, int mmax, int s, int smax) { diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index ab91f4217..9917dcdcc 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -32,7 +32,7 @@ namespace MWGui class HUD : public OEngine::GUI::Layout { 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 setWeapIcon(const char *str); void setSpellIcon(const char *str); @@ -41,6 +41,8 @@ namespace MWGui void setEffect(const char *img); void setValue (const std::string& id, const MWMechanics::DynamicStat& value); void setFPS(float fps); + void setTriangleCount(size_t count); + void setBatchCount(size_t count); MyGUI::ProgressPtr health, magicka, stamina; MyGUI::StaticImagePtr weapImage, spellImage; @@ -53,6 +55,8 @@ namespace MWGui MyGUI::WidgetPtr fpsbox; MyGUI::StaticTextPtr fpscounter; + MyGUI::StaticTextPtr trianglecounter; + MyGUI::StaticTextPtr batchcounter; }; class MapWindow : public OEngine::GUI::Layout diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 095d347e7..0a17daf80 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -22,7 +22,7 @@ using namespace MWGui; 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) , nameDialog(nullptr) , raceDialog(nullptr) @@ -41,7 +41,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment , shown(GW_ALL) , allowed(newGame ? GW_None : GW_ALL) { - showFPSCounter = fpsSwitch; + showFPSLevel = fpsLevel; creationStage = NotStarted; @@ -53,7 +53,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment int w = gui->getViewSize().width; int h = gui->getViewSize().height; - hud = new HUD(w,h, showFPSCounter); + hud = new HUD(w,h, showFPSLevel); menu = new MainMenu(w,h); map = new MapWindow(); stats = new StatsWindow(*this); @@ -135,9 +135,11 @@ void WindowManager::update() environment.mInputManager->setGuiMode(nextMode); nextMode = GM_Game; } - if (showFPSCounter) + if (showFPSLevel > 0) { hud->setFPS(mFPS); + hud->setTriangleCount(mTriangleCount); + hud->setBatchCount(mBatchCount); } } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 293bac601..0178943eb 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -156,13 +156,15 @@ namespace MWGui void setGuiMode(GuiMode newMode); - bool showFPSCounter; + int showFPSLevel; float mFPS; + size_t mTriangleCount; + size_t mBatchCount; public: /// The constructor needs the main Gui object 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(); /** @@ -204,6 +206,12 @@ namespace MWGui MyGUI::Gui* getGui() const { return gui; } 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& value); ///< Set value for the given ID. diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_hud_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_hud_layout.xml index 8dc3cebab..32eb31027 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_hud_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_hud_layout.xml @@ -49,12 +49,19 @@ - - + + + + + + + +