Files
XCEngine/docs/api/rhi/d3d12/common/create-viewport.md
2026-03-20 02:35:45 +08:00

886 B

D3D12Common::CreateViewport

inline D3D12_VIEWPORT CreateViewport(
    float width, 
    float height, 
    float topLeftX = 0.0f, 
    float topLeftY = 0.0f, 
    float minDepth = 0.0f, 
    float maxDepth = 1.0f
)

创建 D3D12 视口结构。

参数:

  • width - 视口宽度(像素)
  • height - 视口高度(像素)
  • topLeftX - 视口左上角 X 坐标,默认为 0
  • topLeftY - 视口左上角 Y 坐标,默认为 0
  • minDepth - 最小深度值,默认为 0
  • maxDepth - 最大深度值,默认为 1

返回: 配置好的 D3D12_VIEWPORT 结构

线程安全: (纯函数)

示例:

D3D12_VIEWPORT viewport = CreateViewport(1280.0f, 720.0f, 0.0f, 0.0f, 0.0f, 1.0f);
cmdList->RSSetViewports(1, &viewport);

相关文档