本文整理汇总了C++中GraphicsDevice::SetViewport方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsDevice::SetViewport方法的具体用法?C++ GraphicsDevice::SetViewport怎么用?C++ GraphicsDevice::SetViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice::SetViewport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawRay
void CubeMesh::DrawRay(const D3DXVECTOR2& screenPos,
const D3DXMATRIX& matWorld, const D3DXMATRIX& matView, const D3DXMATRIX& matProj)
{
HRESULT hr = S_FALSE;
GraphicsDevice* pGDevice = GraphicsDevice::getInstance();
IDirect3DDevice9* pDevice = pGDevice->m_pD3DDevice;
Ray ray = CalcPickingRay((int)screenPos.x, (int)screenPos.y,
pGDevice->mCubeViewport, matView, matProj );
PCVertex rayLine[] = {
{D3DXVECTOR3(0.0f,0.0f,0.0f), D3DCOLOR_ARGB(255,255,0,0)},
{ray.Origin + 1000*ray.Direction, D3DCOLOR_ARGB(255,255,0,0)},
};
PCVertex intersectPoint[] = {
{p, D3DCOLOR_ARGB(255,0,0,255)},
{p+D3DXVECTOR3(0.5f,0.0f,0.0f), D3DCOLOR_ARGB(255,0,0,255)},
{p+D3DXVECTOR3(0.0f,0.5f,0.0f), D3DCOLOR_ARGB(255,0,0,255)},
{p+D3DXVECTOR3(0.0f,0.0f,0.5f), D3DCOLOR_ARGB(255,0,0,255)},
{p+D3DXVECTOR3(-0.5f,0.0f,0.0f), D3DCOLOR_ARGB(255,0,0,255)},
{p+D3DXVECTOR3(0.0f,-0.5f,0.0f), D3DCOLOR_ARGB(255,0,0,255)},
{p+D3DXVECTOR3(0.0f,0.0f,-0.5f), D3DCOLOR_ARGB(255,0,0,255)},
};
pGDevice->SetViewport(pGDevice->mCubeViewport);
pDevice->SetVertexShader(NULL);
pDevice->SetPixelShader(NULL);
V(pDevice->SetTransform(D3DTS_WORLD, &matWorld));
V(pDevice->SetTransform(D3DTS_VIEW, &matView));
V(pDevice->SetTransform(D3DTS_PROJECTION, &matProj));
V(pDevice->SetRenderState(D3DRS_LIGHTING, FALSE));
V(pDevice->SetRenderState(D3DRS_ZENABLE, FALSE));
V(pDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE));
V(pDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, rayLine, sizeof(PCVertex)));
V(pDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 7, intersectPoint, sizeof(PCVertex)));
V(pDevice->SetFVF(NULL));
V(pDevice->SetRenderState(D3DRS_ZENABLE, TRUE));
V(pDevice->SetRenderState(D3DRS_LIGHTING, TRUE));
pGDevice->ResetViewport();
}