共用方式為


IDirect3DDevice9::SetViewport 方法 (d3d9.h)

設定裝置的檢視區參數。

語法

HRESULT SetViewport(
  [in] const D3DVIEWPORT9 *pViewport
);

參數

[in] pViewport

類型: const D3DVIEWPORT9*

D3DVIEWPORT9結構的指標,指定要設定的檢視區參數。

傳回值

類型: HRESULT

如果方法成功,傳回值會D3D_OK。 如果方法失敗,它會傳回D3DERR_INVALIDCALL。 如果 pViewport 無效,或 pViewport 描述轉譯目標介面中不存在的區域,就會發生這種情況。

備註

Direct3D 會設定檢視區的下列預設值。


D3DVIEWPORT9 vp;
vp.X      = 0;
vp.Y      = 0;
vp.Width  = RenderTarget.Width;
vp.Height = RenderTarget.Height;
vp.MinZ   = 0.0f;
vp.MaxZ   = 1.0f;

IDirect3DDevice9::SetViewport 可用來在畫面的一部分繪製。 請務必在繪製任何幾何之前呼叫它,讓檢視區設定生效。

若要在場景中繪製多個檢視,請針對每個檢視重複 IDirect3DDevice9::SetViewport 和繪製幾何序列。

規格需求

需求
目標平台 Windows
標頭 d3d9.h (包含 D3D9.h)
程式庫 D3D9.lib

另請參閱

IDirect3DDevice9

IDirect3DDevice9::GetViewport