Hi,
I am trying to implement a first person shooter game in which I need to make view for the sniper rifle. I thought stencil buffer can be useful to implement the sniper view. I am trying to make that but I am not able to get it. I went through lots of tutorials, but they just talk shadowing using stencil buffer, and are not understandable.
What I have tried to do is this:
1) disable the z buffer and color buffer
2) enable the stencil buffer
3) given the stencil fun val and other things
pd3dDevice->(SetRenderState(D3DRS_ZWRITEENABLE, false);
pd3dDevice->(SetRenderState(D3DRS_COLORWRITEENABLE, false);
pd3dDevice->(SetRenderState(D3DRS_STENCILENABLE, true);
pd3dDevice->(SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
pd3dDevice->(SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
pd3dDevice->(SetRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
pd3dDevice->(SetRenderState(D3DRS_STENCILREF, 5);
pd3dDevice->(SetRenderState(D3DRS_STENCILMASK, 0);
Then I am drawing my stencil shape (which is a quad- quad I am drawing is screen aliened:
pd3dDevice->renderQuad();
Then I am enabling the color and the z buffer. Please help me out and if possible give some reference code.