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.

This commit is contained in:
Aloshi 2014-04-11 19:42:04 -05:00
parent 1b66150fe7
commit 9955261a1e
2 changed files with 4 additions and 3 deletions

View file

@ -156,7 +156,7 @@ void Window::update(int deltaTime)
float vramUsageMb = (TextureResource::getTotalMemUsage() + Font::getTotalMemUsage()) / 1000.0f / 1000.0f;
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;
@ -200,7 +200,7 @@ void Window::render()
if(Settings::getInstance()->getBool("DrawFramerate"))
{
Renderer::setMatrix(Eigen::Affine3f::Identity());
mDefaultFonts.at(1)->drawText(mFrameDataString, Eigen::Vector2f(50, 50), 0xFF00FFFF);
mDefaultFonts.at(1)->renderTextCache(mFrameDataText.get());
}
}

View file

@ -52,7 +52,8 @@ private:
int mFrameTimeElapsed;
int mFrameCountElapsed;
int mAverageDeltaTime;
std::string mFrameDataString;
std::unique_ptr<TextCache> mFrameDataText;
bool mNormalizeNextUpdate;