Hi all,
I'm writing a 2D, top-down game, using ID3DXSprite in object space for drawing. The rendering is going fine, except I can't get an alpha test working. The sprite appears where it's supposed to, but without the surrounding pixels trimmed. Here's some code from my render() function:
// The following code specifies an alpha test and reference value.
gDevice->SetRenderState(D3DRS_ALPHAREF, 10));
gDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER));
...
gDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 0, 255), 1.0f, 0));
gDevice->BeginScene());
mSprite->Begin(D3DXSPRITE_OBJECTSPACE|D3DXSPRITE_DONOTMODIFY_RENDERSTATE));
gDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true));
mSprite->Draw(mTex, 0, 0, 0, D3DCOLOR_XRGB(255, 255, 255)));
gDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false));
mSprite->End());
gDevice->EndScene());
gDevice->Present(0, 0, 0, 0));
Here's the thing: no matter what function I use for the alpha test, nothing changes. For example, the alpha test doesn't seem to kick in with either of these two:
gDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_ALWAYS));
gDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_NEVER));
...even though with D3DCMP_NEVER, the alpha test should prevent everything from being drawn.
Anyone see what I'm doing wrong?