Files
XCEngine/docs/api/XCEngine/Rendering/RenderSurface/Constructor.md

43 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RenderSurface::RenderSurface
构造一个只描述渲染目标状态的 `RenderSurface`
```cpp
RenderSurface();
RenderSurface(uint32_t width, uint32_t height);
```
## 参数
- `width` - 初始逻辑宽度。
- `height` - 初始逻辑高度。
## 当前语义
- 默认构造得到 `0 x 0` 的空 surface带参构造只写入 `width / height`
- 构造函数不会自动创建颜色附件、深度附件或任何底层 render target 资源。
- 初始状态下:
- 没有颜色附件。
- 深度附件为 `nullptr`
- 未启用自定义 render area。
- 未启用 clear-color override。
- 自动颜色状态切换开关为开启。
- `colorStateBefore``colorStateAfter` 都默认是 `Present`
## 设计说明
- `RenderSurface` 只是一次渲染提交使用的“目标描述”,不是 swap chain、framebuffer 或纹理资源的拥有者。
- 调用方通常先构造 surface再通过 [SetColorAttachment](SetColorAttachment.md)、[SetDepthAttachment](SetDepthAttachment.md)、[SetRenderArea](SetRenderArea.md) 等接口补齐实际目标配置。
## 测试覆盖
- `tests/Rendering/unit/test_camera_scene_renderer.cpp` 验证了仅设置宽高的 surface 也会生成覆盖整张 surface 的默认 render area。
- `tests/Editor/test_viewport_host_surface_utils.cpp` 验证了编辑器辅助函数会基于构造出的 surface 继续注入附件和颜色状态。
## 相关文档
- [RenderSurface](RenderSurface.md)
- [SetSize](SetSize.md)
- [SetColorAttachment](SetColorAttachment.md)
- [SetDepthAttachment](SetDepthAttachment.md)