本文整理汇总了C++中LPDIRECT3DDEVICE7::GetViewport方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE7::GetViewport方法的具体用法?C++ LPDIRECT3DDEVICE7::GetViewport怎么用?C++ LPDIRECT3DDEVICE7::GetViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE7
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE7::GetViewport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawShadow
void DrawShadow(LPDIRECT3DDEVICE7 lpDevice)
{
lpDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, FALSE );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILENABLE, TRUE );
// Turn on alphablending
lpDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
lpDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA );
lpDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA );
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
// Only write where the stencil value == 1
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILREF, 0x1 );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILFUNC, D3DCMP_EQUAL );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILPASS, D3DSTENCILOP_KEEP );
// Get viewport dimensions for big, gray square
D3DVIEWPORT7 vp;
lpDevice->GetViewport(&vp);
FLOAT sx = (FLOAT)vp.dwWidth;
FLOAT sy = (FLOAT)vp.dwHeight;
D3DCOLOR color=D3DRGBA(0,0,0,0.5f);
// Draw a big, gray square
D3DTLVERTEX vBigGraySquare[4];
vBigGraySquare[0] = D3DTLVERTEX( D3DVECTOR( 0,sy,0.0f),1.0f,color,0,0,0 );
vBigGraySquare[1] = D3DTLVERTEX( D3DVECTOR( 0, 0,0.0f),1.0f,color,0,0,0 );
vBigGraySquare[2] = D3DTLVERTEX( D3DVECTOR(sx,sy,0.0f),1.0f,color,0,0,0 );
vBigGraySquare[3] = D3DTLVERTEX( D3DVECTOR(sx, 0,0.0f),1.0f,color,0,0,0 );
lpDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX,
vBigGraySquare, 4, NULL );
// Restore render states
lpDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, TRUE );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILENABLE, FALSE );
lpDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE );
}