Unhandled exception at 0x76f76579 in ICT311.exe: 0xC0000005: Access violation reading location 0x222c166d.
now for some code.
Creation looks like this:
[source]
m_Font = NULL; //font object
hr = D3DXCreateFont( Direct3D_device, 20, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_Font );
if(FAILED(hr))
{
throw Exception("DX:error loading font\n");
m_Font = NULL;
}
[/source]
~De-constructor:
[source]
if(m_Font!=NULL)
{
m_Font->Release(); //still problems with releasing this
m_Font = NULL;
}
//..a bit later down
//release Direct X stuff
Direct3D_object->Release();
Direct3D_device->Release();
[/source]
within DX::Render()
[source]
D3DCOLOR fontColor = D3DCOLOR_ARGB(255,0,0,255);
RECT rct;
rct.left=2;
rct.right=780;
rct.top=10;
rct.bottom=rct.top+20;
int result = m_Font->DrawText(NULL, TEXT("test text"), -1, &rct, 0, fontColor );
[/source]
Some things that may or may not be related:
- Im using a pixel shader for the terrain rendering, but have tried setting it to NULL before rendering fonts
- i have directx debugging enabled and it does not say anything apart from (Ignoring redundant SetRenderState) which i think is elsewhere
- I do not have WinMain() as my entry point for directX, and instead i retrieve the window handle in the contructor of the graphics class
- do the world, projection and view matrices affect font rendering? and if so, what should they be set as (similar to hud rendering i assume, but have not tried it yet)
- i have also tried rendering the font within a sprite, same results
Any help would be much appreciated , and btw this is my first post, so if i have used the source tags incorrectly then