Issues rendering to texture in D3D9

0

I'm trying to render the world to a texture inside a hook for a game, but the image ends up this. Since it's rendering distant objects in front of near ones, it looks like an issue with incorrect z-buffer render states, but nothing changes even when I set them before it draws.

The code inside the hook looks like this:

    IDirect3DSurface9 *pOrigRT;

    g_pDevice->GetRenderTarget(0, &pOrigRT);
    g_pDevice->SetRenderTarget(0, pSurf[0]);

    g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000088, 1.0f, 0.0f);
    g_pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
    g_pDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
    g_pDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);

    ZGameDraw(pThis);

    g_pDevice->SetRenderTarget(0, pOrigRT);

    g_pDevice->StretchRect(pSurf[0], 0, pOrigRT, 0, D3DTEXF_NONE);

    SAFE_RELEASE(pOrigRT);

What else could cause this effect?

c++
directx-9
asked on Stack Overflow Jan 20, 2015 by Asunaya

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0