# RHICommandList::SetViewport ```cpp virtual void SetViewport(const Viewport& viewport) = 0; ``` 设置渲染区域视口。视口定义了渲染输出到目标区域的映射变换。 **参数:** - `viewport` - 视口结构体(包含 topLeftX、topLeftY、width、height、minDepth、maxDepth) **返回:** `void` **异常:** 无 **线程安全:** ❌ **复杂度:** O(1) **示例:** ```cpp Viewport vp; vp.topLeftX = 0; vp.topLeftY = 0; vp.width = 1280; vp.height = 720; vp.minDepth = 0.0f; vp.maxDepth = 1.0f; cmdList->SetViewport(vp); ``` ## 相关文档 - [RHICommandList 总览](command-list.md) - 返回类总览 - [SetViewports](set-viewports.md) - 设置多个视口 - [SetScissorRect](set-scissor-rect.md) - 设置裁剪矩形