Evo istog i za DX:
Code:
HRESULT Render()
{
D3DVIEWPORT9 vpOld;
D3DVIEWPORT9 vp;
g_pd3dDevice->GetViewport(&vpOld);
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // cistimo crnom
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
DWORD newH = (DWORD)(w * 9.0 / 16.0);
vp.X = 0;
vp.Y = (h - newH) / 2;
vp.Width = w;
vp.Height = newH;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
if( FAILED( g_pd3dDevice->SetViewport(&vp) ) )
return E_FAIL;
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
D3DXMATRIX matrix;
D3DXMatrixPerspectiveFovLH(&matrix, D3DX_PI / 4, (float)16/9, 0.1f, 50.0f );
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matrix);
// crtaj nesto
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
g_pd3dDevice->SetViewport(&vpOld);
g_pd3dDevice->EndScene();
}
if ( FAILED (g_pd3dDevice->Present( NULL, NULL, NULL, NULL ) ) )
{
g_pd3dDevice->Reset(&d3dpp);
}
return S_OK;
}