39 lines
886 B
Markdown
39 lines
886 B
Markdown
# D3D12Common::CreateViewport
|
|
|
|
```cpp
|
|
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` 结构
|
|
|
|
**线程安全:** ✅(纯函数)
|
|
|
|
**示例:**
|
|
|
|
```cpp
|
|
D3D12_VIEWPORT viewport = CreateViewport(1280.0f, 720.0f, 0.0f, 0.0f, 0.0f, 1.0f);
|
|
cmdList->RSSetViewports(1, &viewport);
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [D3D12Common 总览](common.md)
|
|
- [CreateScissorRect](create-scissor-rect.md)
|