Problem with creating a new font object

I'm trying to display the frames per second on the window

So I decided to create an appStatistics object
which has several methods that calculate fps, triangles etc..

here is the code for the constructor:


appStatistics::appStatistics()
{
D3DXFONT_DESC font;
font.Height = 12;
font.Width = 8;
font.Weight = 2;
font.MipLevels = 0;
font.Italic = true;
font.CharSet = DEFAULT_CHARSET;
font.OutputPrecision = OUT_DEFAULT_PRECIS;
font.Quality = DEFAULT_QUALITY;
font.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
_tcscpy(font.FaceName, _T("Matisse ITC"));

HR(D3DXCreateFontIndirect(gd3dDevice, &font, &displayFont));

//HR() is simply a debugging macro!

}

here is the class declaration:
class appStatistics
{
public:
appStatistics();
~appStatistics();
void update(float dt);
void display();


private:


float FPS;
ID3DXFont* displayFont;



};


whenever I run this it gives me an error D3DERR_INVALID CALL

This is extremely simple stuff I don't understand why it is not working. I cannot even create a appStatistics object without it crashing and giving this error code


Answer this question

Problem with creating a new font object

  • Thrix

    Has the device been initialized already when you're creating the appStatistics object
  • Problem with creating a new font object