I have a hooked DirectX used in C++ code that draws text and sprite. I tested it and it drew well onto 2D application. However, when I tried it with 3D application (some complex game actually), only text was visible. From that I deduced the sprite is not being overdrawn by something else, hence the text would be too. I set flags
SetVertexShader(0);
SetPixelShader(0);
SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
//SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
SetRenderState(D3DRS_ZENABLE, false);
SetRenderState(D3DRS_LIGHTING, FALSE);
SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
For some reason, ALPHABLEND
caused the sprite not to be visible at all in any application, so I didn't enable it and it's commented out.
Does any fail-proof way to draw sprites over D3D exist? Otherwise, should I use different flags/values for them?
Also, which z-index should I set for the sprite in case it's really "under" some other sprites/objects?
(I'm not author of anything drawn to the device, I only have the hooked DirectX API and don't even know the code of application I draw over).