ID3DXSprite::Flush() Hanging
Jun 19, 2012 at 6:29am UTC
Hello,
I'm wondering if somebody can see something that I am missing.
I have a font class that takes a struct with some information and renders the string to a specified location. It then clears the list after the call to end scene. The problem is that the call to Flush is hanging and i don't know why. It stops only after the second iteration.
Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
struct TextObject
{
string mString;
tagRECT mLocation;
DWORD mColor;
DWORD mFormat;
};
class cFont : public cRenderObject
{
public :
cFont();
~cFont();
//Intilaizes some default values.
bool Intialize(LPDIRECT3DDEVICE9 Device);
void Render(LPDIRECT3DDEVICE9 Device);
//adds new text objects to the render list
void AddTextObject(TextObject* NewText);
private :
//the font object
LPD3DXFONT myFont;
//the sprite object associated with the font object
LPD3DXSPRITE mySprite;
std::list<TextObject*> myStrings;
void Print();
};
void cFont::Render(LPDIRECT3DDEVICE9 Device)
{
mySprite->Begin(D3DXSPRITE_ALPHABLEND);
Print();
HRESULT r = mySprite->Flush();
if (FAILED(r))
Print_Text("cFont: Failed to end scene." );
r = mySprite->End();
myStrings.clear();
};
void cFont::Print()
{
list<TextObject*>::iterator itr;
for (itr = myStrings.begin(); itr != myStrings.end(); itr++)
{
myFont->DrawTextA(mySprite, (*itr)->mString.c_str(), (*itr)->mString.size(), &(*itr)->mLocation, (*itr)->mFormat, (*itr)->mColor);
}
};
Even if I call ID3DXSprite::End() without calling flush, the program still hangs on End().
I also have an ID3DXMesh object that, when added, the cFont render() hangs, but when I remove the ID3DXMesh, the program runs normally.
If I comment out the cFont::Render() function and the ID3DXMesh object is included, the program loads and displays the Mesh normally.
Thanks for the help.
Topic archived. No new replies allowed.