Added a more detailed fps counter displaying the triangle and batch count

actorid
Jacob Essex 13 years ago
parent 022f0fd5bd
commit 18e4b73a86

@ -7,6 +7,7 @@
#include <utility>
#include <OgreRoot.h>
#include <OgreRenderWindow.h>
#include <MyGUI_WidgetManager.h>
@ -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)

@ -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

@ -75,8 +75,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio
("plugin", bpo::value<StringsVector>()->default_value(StringsVector(), "")
->multitoken(), "plugin file(s)")
("fps", boost::program_options::value<bool>()->implicit_value(true)
->default_value(false), "show fps counter")
("fps", boost::program_options::value<int>()->implicit_value(1)
->default_value(0), "fps counter detail (0 = off, 1 = fps counter, 2 = full detail)")
("debug", boost::program_options::value<bool>()->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<bool>());
// other settings
engine.showFPS(variables["fps"].as<bool>());
engine.showFPS(variables["fps"].as<int>());
engine.setDebugMode(variables["debug"].as<bool>());
engine.setSoundUsage(!variables["nosound"].as<bool>());
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());

@ -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<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)
{

@ -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<int>& 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

@ -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);
}
}

@ -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<int>& value);
///< Set value for the given ID.

@ -49,12 +49,19 @@
<Widget type="StaticImage" skin="StaticImage" position="0 0 32
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"
name="FPSBox">
<Widget type="StaticText" skin="NumFPS" position="3 3 21 17" name="FPSCounter"/>
</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>
</MyGUI>

Loading…
Cancel
Save