lamcntt
July 19th, 2007, 05:59 AM
help me! I want to change alpha mask from d3d to ddraw !But I don't know how do?
help me!
D3DCAPS9 caps;
m_pd3dDevice->GetDeviceCaps( &caps );
if ( !caps.AlphaCmpCaps )
return RES_FAILED;
m_pd3dDevice->BeginScene();
//Save the current state
m_pd3dDevice->GetTextureStageState(0, D3DTSS_COLOROP, &oldCOLOROP1);
m_pd3dDevice->GetTextureStageState(0, D3DTSS_ALPHAOP, &oldALPHAOP1);
m_pd3dDevice->GetTextureStageState(1, D3DTSS_COLOROP, &oldCOLOROP2);
m_pd3dDevice->GetTextureStageState(1, D3DTSS_ALPHAOP, &oldALPHAOP2);
//m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_COLORVALUE(0.0f, 0.0f, 0.0f, 1.0f), 1.0f, 0 );
//initialize world based on width & height
SetupMatrics();
// STAGE 0
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
// Set the two textures to be used by our stages...
m_pd3dDevice->SetTexture( 0, ((CD3DSurface*)m_pDestSurface)->GetTexture() );
// Render our quad with two sets of texture coordinates...
m_pd3dDevice->SetStreamSource( 0, m_pVertices, 0, sizeof(Vertex) );
m_pd3dDevice->SetFVF( Vertex::FVF_Flags );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// //STAGE 1
m_pd3dDevice->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetRenderState(D3DRS_ALPHAREF, (DWORD)((t / (float)m_lDuration) * 255));
m_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
m_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
m_pd3dDevice->SetTexture( 0, m_pTexture );
m_pd3dDevice->SetTexture( 1, ((CD3DSurface*)m_pSrcSurface)->GetTexture() );
// Render our quad with two sets of texture coordinates...
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
//Restore the saved state
m_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false);
m_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_ALWAYS);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, oldCOLOROP1);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, oldALPHAOP1);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, oldCOLOROP2);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, oldALPHAOP2);
m_pd3dDevice->EndScene();
RECT srcRect;
D3DVIEWPORT9* pCurViewport = ((CD3DRenderer*)m_pRenderer)->GetCurrentRenderViewport();
srcRect.left = pCurViewport->X;
srcRect.right = pCurViewport->X + pCurViewport->Width;
srcRect.top = pCurViewport->Y;
srcRect.bottom = pCurViewport->Y + pCurViewport->Height;
m_pd3dDevice->Present( &srcRect, NULL, NULL, NULL );
}
to ddraw alpha mask!??????????
help me!
D3DCAPS9 caps;
m_pd3dDevice->GetDeviceCaps( &caps );
if ( !caps.AlphaCmpCaps )
return RES_FAILED;
m_pd3dDevice->BeginScene();
//Save the current state
m_pd3dDevice->GetTextureStageState(0, D3DTSS_COLOROP, &oldCOLOROP1);
m_pd3dDevice->GetTextureStageState(0, D3DTSS_ALPHAOP, &oldALPHAOP1);
m_pd3dDevice->GetTextureStageState(1, D3DTSS_COLOROP, &oldCOLOROP2);
m_pd3dDevice->GetTextureStageState(1, D3DTSS_ALPHAOP, &oldALPHAOP2);
//m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_COLORVALUE(0.0f, 0.0f, 0.0f, 1.0f), 1.0f, 0 );
//initialize world based on width & height
SetupMatrics();
// STAGE 0
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
// Set the two textures to be used by our stages...
m_pd3dDevice->SetTexture( 0, ((CD3DSurface*)m_pDestSurface)->GetTexture() );
// Render our quad with two sets of texture coordinates...
m_pd3dDevice->SetStreamSource( 0, m_pVertices, 0, sizeof(Vertex) );
m_pd3dDevice->SetFVF( Vertex::FVF_Flags );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// //STAGE 1
m_pd3dDevice->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetRenderState(D3DRS_ALPHAREF, (DWORD)((t / (float)m_lDuration) * 255));
m_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
m_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
m_pd3dDevice->SetTexture( 0, m_pTexture );
m_pd3dDevice->SetTexture( 1, ((CD3DSurface*)m_pSrcSurface)->GetTexture() );
// Render our quad with two sets of texture coordinates...
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
//Restore the saved state
m_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false);
m_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_ALWAYS);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, oldCOLOROP1);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, oldALPHAOP1);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, oldCOLOROP2);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, oldALPHAOP2);
m_pd3dDevice->EndScene();
RECT srcRect;
D3DVIEWPORT9* pCurViewport = ((CD3DRenderer*)m_pRenderer)->GetCurrentRenderViewport();
srcRect.left = pCurViewport->X;
srcRect.right = pCurViewport->X + pCurViewport->Width;
srcRect.top = pCurViewport->Y;
srcRect.bottom = pCurViewport->Y + pCurViewport->Height;
m_pd3dDevice->Present( &srcRect, NULL, NULL, NULL );
}
to ddraw alpha mask!??????????