1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0xFFFFFF, 1.0f, 0x0);
pDevice->BeginScene();
// dessin de la scene1 dans la region1
pDevice->Clear(0, NULL, D3DCLEAR_STENCIL, 0xFFFFFF, 1.0f, 0x0);
pDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
pDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCR);
pDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
pDevice->SetTransform(...);
pDevice->SetStreamSOurce(..., pRegion1...);
pDevice->DrawPrimitive(Region1);
scene1->draw(pDevice);
pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0x0000000F);
pDevice->SetRenderState(D3DRS_STENCILPASS, STENCILOP_KEEP);
pDevice->SetRenderState( D3DRS_STENCILREF, 0x1 );
pDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL );
pDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP );
// dessin de la scene2 dans la region 2
pDevice->Clear(0, NULL, D3DCLEAR_STENCIL, 0xFFFFFF, 1.0f, 0x0);
pDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
pDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCR);
pDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
pDevice->SetTransform(...);
pDevice->SetStreamSOurce(..., pRegion2...);
pDevice->DrawPrimitive(....);
scene2->draw(pDevice);
pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0x0000000F);
pDevice->SetRenderState(D3DRS_STENCILPASS, STENCILOP_KEEP);
pDevice->SetRenderState( D3DRS_STENCILREF, 0x1 );
pDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL );
pDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP );
pDevice->EndScene();
pDevice->Present(NULL, NULL, NULL, NULL); |
Partager