DirectX drawn lines are not visible

11/06/2017 13:50 znoeen#1
Hello guys,

I'm trying to draw some lines with DirectX. I hooked into present, and using the games LPDIRECT3DDEVICE9 to draw strings/lines. Somehow only the strings are visible, and not the lines.

Code:
void Menu::Box(int x, int y, int w, int h, DWORD Color, LPDIRECT3DDEVICE9 pDevice)
{
	if (!pDevice)
		return;

	const DWORD D3D_FVF = (D3DFVF_XYZRHW | D3DFVF_DIFFUSE);

	struct Vertex
	{
		float x, y, z, ht;
		DWORD yourcolor;
	}
	V[4] =
	{
		{ (float)x, (float)(y + h), 0.0f, 0.0f, Color },
		{ (float)x, (float)y, 0.0f, 0.0f, Color },
		{ (float)(x + w), (float)(y + h), 0.0f, 0.0f, Color },
		{ (float)(x + w), (float)y, 0.0f, 0.0f, Color }
	};

	pDevice->SetTexture(0, NULL);
	pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
	pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
	pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
	pDevice->SetRenderState(D3DRS_FOGENABLE, false);

	pDevice->SetFVF(D3D_FVF);
	pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, V, sizeof(Vertex));
}
12/17/2017 19:08 elmarcia#2
I think your code is OK..

Shouldn't u call this function in:
Code:
HRESULT WINAPI EndScene(LPDIRECT3DDEVICE9 pDevice)
{
      //call function here to draw on top
        return pEndScene(pDevice);
}
12/19/2017 19:38 Decrypted#3
Quote:
Originally Posted by elmarcia View Post
I think your code is OK..

Shouldn't u call this function in:
Code:
HRESULT WINAPI EndScene(LPDIRECT3DDEVICE9 pDevice)
{
      //call function here to draw on top
        return pEndScene(pDevice);
}

Like Elmarcia already said, you can't render 3D stuff after the scene has been rendered (BeginScene => EndScene (Processes all the stuff left in the render queue(flushes it)).
The rendered image is now the backbuffer of your device. Present takes the backbuffer and draws it as a simple image on the window. (The text only works because the text framework writes on the backbuffer regardless of the scene drawing).
12/24/2017 13:38 Ende!#4
It’s been ages since I last did D3D9 hooks, but IIRC it was possible to just call BeginScene before doing your stuff in Present and finish off with an EndScene call.

Also, check your return values.