Noob Trying to Get D3D8 to Display Text

Started by
2 comments, last by Thawne 5 years, 11 months ago

Greetings, I'm a complete noob when it comes to C++ and DirectX programming. I'm trying to do the good old D3DX hooking. Can anyone please help me figure out why my code isn't displaying the text I wanted. Thank you!
PS If you could link to resourceful sites, I would appreciate it! It's pretty hard to come by.


void myIDirect3DDevice8::DisplayTitle(void)
{
	CD3DFont *D3DFont;
	D3DFont->DrawTextA(0, 0, D3DCOLOR_ARGB(255, 255, 255, 255), "Hello World", 1);
}

HRESULT __stdcall myIDirect3DDevice8::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)  
{
	this->DisplayTitle();

    // Call original routine
	HRESULT hres = m_pIDirect3DDevice8->Present( pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);

	return (hres);
}

 

Advertisement

You create a pointer to a CD3DFont structure but you don't assign anything to it, so it just points to a random memory location.
You should make it point to an initialised CD3DFont structure :)

.:vinterberg:.

I changed my code into the following, and the text is still not showing up. Did I do anything wrong?


void myIDirect3DDevice8::DisplayTitle(void)
{
	CD3DFont *D3DFont = new CD3DFont("Times New Roman", 16, 0);
	D3DFont->InitDeviceObjects(this);
	D3DFont->RestoreDeviceObjects();
	D3DFont->DrawTextA(0, 0, D3DCOLOR_ARGB(255, 255, 255, 255), "Hello World", 0);
}

 

This topic is closed to new replies.

Advertisement