2026-03-26 16:45:24 +08:00
|
|
|
# RenderDocCapture::BeginCapture
|
|
|
|
|
|
2026-03-26 17:21:44 +08:00
|
|
|
开始一次手动 RenderDoc 抓帧。
|
2026-03-26 16:45:24 +08:00
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
bool BeginCapture(const char* title = nullptr);
|
|
|
|
|
```
|
|
|
|
|
|
2026-03-26 17:21:44 +08:00
|
|
|
## 行为说明
|
2026-03-26 16:45:24 +08:00
|
|
|
|
2026-03-26 17:21:44 +08:00
|
|
|
当前实现会在开始抓帧前依次检查:
|
2026-03-26 16:45:24 +08:00
|
|
|
|
2026-03-26 17:21:44 +08:00
|
|
|
1. RenderDoc 是否已加载。
|
|
|
|
|
2. 当前是否已经处于抓帧中。
|
|
|
|
|
3. `m_device` 与 `m_window` 是否都非空。
|
2026-03-26 16:45:24 +08:00
|
|
|
|
2026-03-26 17:21:44 +08:00
|
|
|
任一条件不满足时都会记录警告并返回 `false`。
|
|
|
|
|
|
|
|
|
|
如果检查通过,当前实现会:
|
|
|
|
|
|
|
|
|
|
- 如果 `title` 非空,则调用 `SetCaptureTitle(title)`。
|
|
|
|
|
- 调用 `SetForegroundWindow` 和 `SetFocus`,把目标窗口切到前台。
|
|
|
|
|
- 调用 `SetActiveWindow(m_device, m_window)`。
|
|
|
|
|
- 调用 `StartFrameCapture(m_device, m_window)`。
|
|
|
|
|
|
|
|
|
|
## 参数
|
|
|
|
|
|
|
|
|
|
- `title` - 可选的 capture 标题。
|
|
|
|
|
|
|
|
|
|
## 返回值
|
|
|
|
|
|
|
|
|
|
- `bool` - `true` 表示已向 RenderDoc 发出开始抓帧请求;`false` 表示前置条件不满足。
|
|
|
|
|
|
|
|
|
|
## 线程语义
|
|
|
|
|
|
|
|
|
|
- 建议在拥有目标窗口与图形设备上下文的主线程调用。
|
|
|
|
|
|
|
|
|
|
## 示例
|
2026-03-26 16:45:24 +08:00
|
|
|
|
|
|
|
|
```cpp
|
2026-03-26 17:21:44 +08:00
|
|
|
using namespace XCEngine::Debug;
|
2026-03-26 16:45:24 +08:00
|
|
|
|
2026-03-26 17:21:44 +08:00
|
|
|
if (RenderDocCapture::Get().BeginCapture("D3D12_Triangle_Test")) {
|
|
|
|
|
Logger::Get().Info(LogCategory::RenderDoc, "Capture started");
|
2026-03-26 16:45:24 +08:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
2026-03-26 17:21:44 +08:00
|
|
|
- [返回类型总览](RenderDocCapture.md)
|
|
|
|
|
- [EndCapture](EndCapture.md)
|
|
|
|
|
- [Initialize](Initialize.md)
|