Commit 9955261a authored by Aloshi's avatar Aloshi

Changed Window to cache the framerate string as a TextCache instead of...

Changed Window to cache the framerate string as a TextCache instead of regenerate it every frame which was significantly impacting the framerate because I am dumb.
parent 1b66150f
...@@ -156,7 +156,7 @@ void Window::update(int deltaTime) ...@@ -156,7 +156,7 @@ void Window::update(int deltaTime)
float vramUsageMb = (TextureResource::getTotalMemUsage() + Font::getTotalMemUsage()) / 1000.0f / 1000.0f; float vramUsageMb = (TextureResource::getTotalMemUsage() + Font::getTotalMemUsage()) / 1000.0f / 1000.0f;
ss << "\nVRAM: " << vramUsageMb << "mb"; ss << "\nVRAM: " << vramUsageMb << "mb";
mFrameDataString = ss.str(); mFrameDataText = std::unique_ptr<TextCache>(mDefaultFonts.at(1)->buildTextCache(ss.str(), 50.f, 50.f, 0xFF00FFFF));
} }
mFrameTimeElapsed = 0; mFrameTimeElapsed = 0;
...@@ -200,7 +200,7 @@ void Window::render() ...@@ -200,7 +200,7 @@ void Window::render()
if(Settings::getInstance()->getBool("DrawFramerate")) if(Settings::getInstance()->getBool("DrawFramerate"))
{ {
Renderer::setMatrix(Eigen::Affine3f::Identity()); Renderer::setMatrix(Eigen::Affine3f::Identity());
mDefaultFonts.at(1)->drawText(mFrameDataString, Eigen::Vector2f(50, 50), 0xFF00FFFF); mDefaultFonts.at(1)->renderTextCache(mFrameDataText.get());
} }
} }
......
...@@ -52,7 +52,8 @@ private: ...@@ -52,7 +52,8 @@ private:
int mFrameTimeElapsed; int mFrameTimeElapsed;
int mFrameCountElapsed; int mFrameCountElapsed;
int mAverageDeltaTime; int mAverageDeltaTime;
std::string mFrameDataString;
std::unique_ptr<TextCache> mFrameDataText;
bool mNormalizeNextUpdate; bool mNormalizeNextUpdate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment