Original Post
Im currently developing a profiler for my application so i can time draw calls. And all has worked out fine so far except for the drawing of the text, to display the profiled infomation on screen. Unfortunatly, the rendering of the text seems to be taking up the most frametime, usally around 50% of the actual frame time. Which kinda defeats the object if the profiler is taking more time than anythng else. Im using ID3DXFont for the rendering of the text. Does anyone have any ideas how i can speed this up? I use the following class for the text which i use as: the time seems to be all spent on the HR(mFont->DrawText(0, Text.c_str(), -1, &R, DT_NOCLIP, col)); call, which i timed on its on. any help would be appreciated
#ifndef GFX_STATS_H
#define GFX_STATS_H
#include "Util.h"
class InfoText
{
public:
InfoText(IDirect3DDevice9* dev, int fontsize);
~InfoText();
void display(int x, int y, D3DCOLOR col, const std::string& Text );
private:
ID3DXFont* mFont;
RECT R;
};
#endif // GFX_STATS_H
#include "InfoText.h"
InfoText::InfoText(IDirect3DDevice9* dev, int fontsize)
{
D3DXFONT_DESC fontDesc;
fontDesc.Height = fontsize;
fontDesc.Width = 0;
fontDesc.Weight = 0;
fontDesc.MipLevels = 1;
fontDesc.Italic = false;
fontDesc.CharSet = DEFAULT_CHARSET;
fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS;
fontDesc.Quality = DRAFT_QUALITY;
fontDesc.PitchAndFamily = FIXED_PITCH;
strcpy(fontDesc.FaceName, "Courier New");
HR(D3DXCreateFontIndirect(dev, &fontDesc, &mFont));
}
InfoText::~InfoText()
{
ReleaseCOM(mFont);
}
void InfoText::display(int x, int y, D3DCOLOR col, const std::string& Text )
{
R.left = x;
R.top = y;
HR(mFont->DrawText(0, Text.c_str(), -1, &R, DT_NOCLIP, col));
}
static InfoText a(this->mD3dDevice, 14);
static std::stringstream sstr;
sstr.str("");
sstr << "Pos : " << this->mCamera->GetPos().ToString() << std::endl
<< "Triangles : " << Effect::GetRenderedTriangles() << std::endl
<< "Vertices : " << Effect::GetRenderedVertices() << std::endl
<< "DrawCalls : " << Effect::GetDrawCalls() << std::endl;
sstr << m_ProfileInfo;
a.display(0, 0, D3DCOLOR_RGBA(255, 255, 0, 225),mClock->getFPSandLapse() + sstr.str());