Files
XCEngine/docs/api/rhi/command-list/set-viewport.md

37 lines
762 B
Markdown
Raw Normal View History

# RHICommandList::SetViewport
```cpp
virtual void SetViewport(const Viewport& viewport) = 0;
```
2026-03-20 02:35:45 +08:00
设置渲染区域视口。视口定义了渲染输出到目标区域的映射变换。
**参数:**
2026-03-20 02:35:45 +08:00
- `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) - 返回类总览
2026-03-20 02:35:45 +08:00
- [SetViewports](set-viewports.md) - 设置多个视口
- [SetScissorRect](set-scissor-rect.md) - 设置裁剪矩形