With the problem being one of those that is always reoccurring, I was hoping someone would explain a new method or old method to me..
I've done this plenty of ways, one being just a simple creation method (In Present or EndScene)
Code:
if(MyFont == NULL || !MyFont)
{
if(!IsBadReadPtr((void*)MyFont, sizeof(MyFont))
MyFont->Release();
Created = false;
}
if(!Created)
{
D3DXCreateFont(....&MyFont);
Created = true;
}
I have also looked around the forum and talked to some friends and they said to use something that I believe originated from Gellin (Didn't work either)
With pDeviceFontBuffer being defined as: LPDIRECT3DDEVICE9 pDeviceFontBuffer;
Code:
if(pFont == NULL || TabFont == NULL)
{
D3DXCreateFontA(.......&pFont);
D3DXCreateFontA(.......&TabFont);
}
else
{
if(pDeviceFontBuffer != pDevice)
{
pDeviceFontBuffer = pDevice;
try
{
if(pFont != 0 || TabFont != 0){ pFont->Release(); TabFont->Release(); }
} catch (...) {}
pFont = 0, TabFont = 0;
D3DXCreateFontA(......&pFont);
D3DXCreateFontA(......&TabFont);
}
}
After going through these and a few more things I put together off the top of my head, I thought of something that made sense, but still failed. Maybe my logic is wrong here, but I figured that since my text worked perfectly until I joined a game, there was a problem with my Device. Maybe my device changed or was lost somehow (and yes I have Reset hooked). So I figured if I save what ever pDevice is returned in my Reset, i could make a new font from it and it should produce visible text. For some reason it didn't work, maybe me logic is flawed... But give it a look:
Reset: (Setting "Buff" to the reset pDevice, so i can make a font off it)
Code:
HRESULT WINAPI nReset( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* PresentationParameters )
{
__asm pushad;
pFont->OnLostDevice();
TabFont->OnLostDevice();
HRESULT rCSetRet = oReset(pDevice, PresentationParameters);
if(SUCCEEDED(rCSetRet)) pFont->OnResetDevice(), TabFont->OnLostDevice(), Buff = pDevice;
__asm popad;
return rCSetRet;
}
EndScene:
Code:
if(pFont)
{
pFont->Release();
TabFont->Release();
pFont = 0;
TabFont = 0;
font = false;
}
if(!font)
{
if(Buff){
D3DXCreateFont(Buff...... &TabFont);
D3DXCreateFont(Buff.......&pFont);
}else{
D3DXCreateFont(pDevice.......&TabFont);
D3DXCreateFont(pDevice.......&pFont);
}
font = true;
}
It seems like its not my font going bad, its some other issue that wont show my text... I'v also tried just using a hot-key to re-create the font ingame, but it still refused to show!
Any help or additions would be appreciated! Thank you in advanced.