From 9955261a1e08bd39aa157b4a3391c1b659350127 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Fri, 11 Apr 2014 19:42:04 -0500 Subject: [PATCH] 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. --- src/Window.cpp | 4 ++-- src/Window.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index 72952b524..2fbb08a4d 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -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(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()); } } diff --git a/src/Window.h b/src/Window.h index 0860f7f20..c71b8d742 100644 --- a/src/Window.h +++ b/src/Window.h @@ -52,7 +52,8 @@ private: int mFrameTimeElapsed; int mFrameCountElapsed; int mAverageDeltaTime; - std::string mFrameDataString; + + std::unique_ptr mFrameDataText; bool mNormalizeNextUpdate;