Files
XCSDD/docs/api/rhi/factory/factory.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

48 lines
1.3 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.
# RHIFactory
**命名空间**: `XCEngine::RHI`
**类型**: `class` (static)
**描述**: RHI 设备工厂,用于创建不同图形 API 后端的渲染设备。
## 概述
`RHIFactory` 是静态工厂类,提供统一的接口来创建不同后端的 `RHIDevice` 实例。通过 `RHIType` 枚举指定要创建的后端类型。
## 公共方法
| 方法 | 描述 |
|------|------|
| [`CreateRHIDevice(RHIType)`](create-rhi-device-type.md) | 使用枚举类型创建 RHI 设备 |
| [`CreateRHIDevice(std::string)`](create-rhi-device-string.md) | 使用字符串创建 RHI 设备 |
## 类型映射
| RHIType | typeName 参数值 |
|----------|-----------------|
| `RHIType::D3D12` | `"D3D12"` |
| `RHIType::OpenGL` | `"OpenGL"` |
| `RHIType::Vulkan` | `"Vulkan"` |
| `RHIType::Metal` | `"Metal"` |
## 使用示例
```cpp
// 方法1使用枚举创建
RHIDevice* d3d12Device = RHIFactory::CreateRHIDevice(RHIType::D3D12);
// 方法2使用字符串创建
RHIDevice* glDevice = RHIFactory::CreateRHIDevice("OpenGL");
// 方法3根据配置选择
std::string backend = "D3D12";
RHIDevice* device = RHIFactory::CreateRHIDevice(backend);
```
## 相关文档
- [../rhi/rhi.md](../rhi.md) - RHI 模块总览
- [RHIDevice](../device/device.md) - 渲染设备
- [RHIEnums](../enums/enums.md) - RHIType 枚举定义