mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Merge pull request #1787 from akortunov/profilierfont
Use the DejaVuLGCSansMono.ttf for profiler output
This commit is contained in:
commit
99e4d49e7c
3 changed files with 43 additions and 25 deletions
|
@ -637,28 +637,19 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
std::cout << "OSG version: " << osgGetVersion() << std::endl;
|
std::cout << "OSG version: " << osgGetVersion() << std::endl;
|
||||||
|
|
||||||
mViewer = new osgViewer::Viewer;
|
// Load settings
|
||||||
mViewer->setReleaseContextAtEndOfFrameHint(false);
|
|
||||||
|
|
||||||
osg::ref_ptr<osgViewer::StatsHandler> statshandler = new osgViewer::StatsHandler;
|
|
||||||
statshandler->setKeyEventTogglesOnScreenStats(osgGA::GUIEventAdapter::KEY_F3);
|
|
||||||
|
|
||||||
statshandler->addUserStatsLine("Script", osg::Vec4f(1.f, 1.f, 1.f, 1.f), osg::Vec4f(1.f, 1.f, 1.f, 1.f),
|
|
||||||
"script_time_taken", 1000.0, true, false, "script_time_begin", "script_time_end", 10000);
|
|
||||||
statshandler->addUserStatsLine("Mechanics", osg::Vec4f(1.f, 1.f, 1.f, 1.f), osg::Vec4f(1.f, 1.f, 1.f, 1.f),
|
|
||||||
"mechanics_time_taken", 1000.0, true, false, "mechanics_time_begin", "mechanics_time_end", 10000);
|
|
||||||
statshandler->addUserStatsLine("Physics", osg::Vec4f(1.f, 1.f, 1.f, 1.f), osg::Vec4f(1.f, 1.f, 1.f, 1.f),
|
|
||||||
"physics_time_taken", 1000.0, true, false, "physics_time_begin", "physics_time_end", 10000);
|
|
||||||
|
|
||||||
mViewer->addEventHandler(statshandler);
|
|
||||||
|
|
||||||
mViewer->addEventHandler(new Resource::StatsHandler);
|
|
||||||
|
|
||||||
Settings::Manager settings;
|
Settings::Manager settings;
|
||||||
std::string settingspath;
|
std::string settingspath;
|
||||||
|
|
||||||
settingspath = loadSettings (settings);
|
settingspath = loadSettings (settings);
|
||||||
|
|
||||||
|
// Create encoder
|
||||||
|
ToUTF8::Utf8Encoder encoder (mEncoding);
|
||||||
|
mEncoder = &encoder;
|
||||||
|
|
||||||
|
// Setup viewer
|
||||||
|
mViewer = new osgViewer::Viewer;
|
||||||
|
mViewer->setReleaseContextAtEndOfFrameHint(false);
|
||||||
|
|
||||||
mScreenCaptureOperation = new WriteScreenshotToFileOperation(mCfgMgr.getUserDataPath().string(),
|
mScreenCaptureOperation = new WriteScreenshotToFileOperation(mCfgMgr.getUserDataPath().string(),
|
||||||
Settings::Manager::getString("screenshot format", "General"));
|
Settings::Manager::getString("screenshot format", "General"));
|
||||||
|
|
||||||
|
@ -668,12 +659,24 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
mEnvironment.setFrameRateLimit(Settings::Manager::getFloat("framerate limit", "Video"));
|
mEnvironment.setFrameRateLimit(Settings::Manager::getFloat("framerate limit", "Video"));
|
||||||
|
|
||||||
// Create encoder
|
|
||||||
ToUTF8::Utf8Encoder encoder (mEncoding);
|
|
||||||
mEncoder = &encoder;
|
|
||||||
|
|
||||||
prepareEngine (settings);
|
prepareEngine (settings);
|
||||||
|
|
||||||
|
// Setup profiler
|
||||||
|
osg::ref_ptr<Resource::Profiler> statshandler = new Resource::Profiler;
|
||||||
|
|
||||||
|
statshandler->addUserStatsLine("Script", osg::Vec4f(1.f, 1.f, 1.f, 1.f), osg::Vec4f(1.f, 1.f, 1.f, 1.f),
|
||||||
|
"script_time_taken", 1000.0, true, false, "script_time_begin", "script_time_end", 10000);
|
||||||
|
statshandler->addUserStatsLine("Mechanics", osg::Vec4f(1.f, 1.f, 1.f, 1.f), osg::Vec4f(1.f, 1.f, 1.f, 1.f),
|
||||||
|
"mechanics_time_taken", 1000.0, true, false, "mechanics_time_begin", "mechanics_time_end", 10000);
|
||||||
|
statshandler->addUserStatsLine("Physics", osg::Vec4f(1.f, 1.f, 1.f, 1.f), osg::Vec4f(1.f, 1.f, 1.f, 1.f),
|
||||||
|
"physics_time_taken", 1000.0, true, false, "physics_time_begin", "physics_time_end", 10000);
|
||||||
|
|
||||||
|
mViewer->addEventHandler(statshandler);
|
||||||
|
|
||||||
|
osg::ref_ptr<Resource::StatsHandler> resourceshandler = new Resource::StatsHandler;
|
||||||
|
mViewer->addEventHandler(resourceshandler);
|
||||||
|
|
||||||
|
// Start the game
|
||||||
if (!mSaveGameFile.empty())
|
if (!mSaveGameFile.empty())
|
||||||
{
|
{
|
||||||
mEnvironment.getStateManager()->loadGame(mSaveGameFile);
|
mEnvironment.getStateManager()->loadGame(mSaveGameFile);
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include <osgViewer/Viewer>
|
#include <osgViewer/Viewer>
|
||||||
#include <osgViewer/Renderer>
|
#include <osgViewer/Renderer>
|
||||||
|
|
||||||
|
#include <components/myguiplatform/myguidatamanager.hpp>
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -19,7 +21,7 @@ StatsHandler::StatsHandler():
|
||||||
_statsType(false),
|
_statsType(false),
|
||||||
_statsWidth(1280.0f),
|
_statsWidth(1280.0f),
|
||||||
_statsHeight(1024.0f),
|
_statsHeight(1024.0f),
|
||||||
_font("fonts/arial.ttf"),
|
_font(""),
|
||||||
_characterSize(20.0f)
|
_characterSize(20.0f)
|
||||||
{
|
{
|
||||||
_camera = new osg::Camera;
|
_camera = new osg::Camera;
|
||||||
|
@ -28,6 +30,15 @@ StatsHandler::StatsHandler():
|
||||||
_camera->setProjectionResizePolicy(osg::Camera::FIXED);
|
_camera->setProjectionResizePolicy(osg::Camera::FIXED);
|
||||||
|
|
||||||
_resourceStatsChildNum = 0;
|
_resourceStatsChildNum = 0;
|
||||||
|
|
||||||
|
_font = osgMyGUI::DataManager::getInstance().getDataPath("DejaVuLGCSansMono.ttf");
|
||||||
|
}
|
||||||
|
|
||||||
|
Profiler::Profiler()
|
||||||
|
{
|
||||||
|
_font = osgMyGUI::DataManager::getInstance().getDataPath("DejaVuLGCSansMono.ttf");
|
||||||
|
|
||||||
|
setKeyEventTogglesOnScreenStats(osgGA::GUIEventAdapter::KEY_F3);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StatsHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
|
bool StatsHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
|
||||||
|
@ -77,7 +88,6 @@ void StatsHandler::setWindowSize(int width, int height)
|
||||||
{
|
{
|
||||||
_camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0,_statsWidth,_statsHeight-height*_statsWidth/width,_statsHeight));
|
_camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0,_statsWidth,_statsHeight-height*_statsWidth/width,_statsHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsHandler::toggle(osgViewer::ViewerBase *viewer)
|
void StatsHandler::toggle(osgViewer::ViewerBase *viewer)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef OPENMW_COMPONENTS_RESOURCE_STATS_H
|
#ifndef OPENMW_COMPONENTS_RESOURCE_STATS_H
|
||||||
#define OPENMW_COMPONENTS_RESOURCE_STATS_H
|
#define OPENMW_COMPONENTS_RESOURCE_STATS_H
|
||||||
|
|
||||||
#include <osgGA/GUIEventHandler>
|
#include <osgViewer/ViewerEventHandlers>
|
||||||
|
|
||||||
namespace osgViewer
|
namespace osgViewer
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,11 @@ namespace osg
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
|
class Profiler : public osgViewer::StatsHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Profiler();
|
||||||
|
};
|
||||||
|
|
||||||
class StatsHandler : public osgGA::GUIEventHandler
|
class StatsHandler : public osgGA::GUIEventHandler
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue