57 lines
2.1 KiB
Markdown
57 lines
2.1 KiB
Markdown
|
|
# Application
|
|||
|
|
|
|||
|
|
**命名空间**: `XCEngine::Editor`
|
|||
|
|
|
|||
|
|
**类型**: `class (singleton)`
|
|||
|
|
|
|||
|
|
**源文件**: `editor/src/Application.h`
|
|||
|
|
|
|||
|
|
**描述**: 编辑器应用主入口,负责窗口渲染器、ImGui 后端、LayerStack 和 `EditorContext` 的初始化、渲染与关闭。
|
|||
|
|
|
|||
|
|
## 概述
|
|||
|
|
|
|||
|
|
`Application` 是当前编辑器应用真正的壳层对象。
|
|||
|
|
|
|||
|
|
它负责把几类本来分散的系统拼成一个可运行编辑器:
|
|||
|
|
|
|||
|
|
- Win32 宿主窗口句柄
|
|||
|
|
- [Platform::D3D12WindowRenderer](../Platform/D3D12WindowRenderer/D3D12WindowRenderer.md)
|
|||
|
|
- [UI::ImGuiSession](../UI/ImGuiSession/ImGuiSession.md)
|
|||
|
|
- ImGui 平台/渲染后端桥
|
|||
|
|
- `LayerStack`
|
|||
|
|
- [Core::EditorContext](../Core/EditorContext/EditorContext.md)
|
|||
|
|
- [Layers::EditorLayer](../Layers/EditorLayer/EditorLayer.md)
|
|||
|
|
|
|||
|
|
## 当前实现说明
|
|||
|
|
|
|||
|
|
- 采用单例入口 `Get()`。
|
|||
|
|
- `Initialize(HWND)` 会安装崩溃过滤器、配置日志、初始化窗口渲染器、创建编辑器上下文、初始化 ImGui,并挂接 `EditorLayer`。
|
|||
|
|
- `Shutdown()` 会按反向顺序关闭 layer、ImGui 和窗口渲染器。
|
|||
|
|
- `Render()` 当前只是执行一帧编辑器 UI 渲染。
|
|||
|
|
- `OnResize()` 会把尺寸变化转发给窗口渲染器。
|
|||
|
|
|
|||
|
|
## 关键公开接口
|
|||
|
|
|
|||
|
|
| 方法 | 作用 |
|
|||
|
|
|------|------|
|
|||
|
|
| `Get()` | 获取全局应用单例。 |
|
|||
|
|
| `Initialize(HWND)` | 初始化编辑器应用。 |
|
|||
|
|
| `Shutdown()` | 关闭编辑器应用。 |
|
|||
|
|
| `Render()` | 绘制一帧编辑器。 |
|
|||
|
|
| `OnResize(int, int)` | 处理窗口尺寸变化。 |
|
|||
|
|
| `GetWindowHandle()` | 获取当前窗口句柄。 |
|
|||
|
|
| `GetEditorContext()` | 获取当前编辑器上下文。 |
|
|||
|
|
|
|||
|
|
## 当前实现边界
|
|||
|
|
|
|||
|
|
- 目前窗口渲染路径绑定到 D3D12 窗口渲染器,不是抽象后端。
|
|||
|
|
- `InitializeEditorContext()` 当前默认把项目路径设为可执行目录。
|
|||
|
|
- `Render()` 当前只走 ImGui 帧,不承载独立游戏循环或模拟步进逻辑。
|
|||
|
|
|
|||
|
|
## 相关文档
|
|||
|
|
|
|||
|
|
- [Editor 模块](../Editor.md)
|
|||
|
|
- [EditorContext](../Core/EditorContext/EditorContext.md)
|
|||
|
|
- [EditorLayer](../Layers/EditorLayer/EditorLayer.md)
|
|||
|
|
- [Win32EditorHost](../Platform/Win32EditorHost/Win32EditorHost.md)
|