当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECT3DDEVICE7::GetViewport方法代码示例

本文整理汇总了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 );
}
开发者ID:UIKit0,项目名称:Chicken-Tournament,代码行数:39,代码来源:Shadows.cpp


注:本文中的LPDIRECT3DDEVICE7::GetViewport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。