feat: add editor viewport host service

This commit is contained in:
2026-03-28 17:04:14 +08:00
parent 6fcb6ac8fb
commit 3b652ac1db
12 changed files with 492 additions and 2 deletions

View File

@@ -68,6 +68,9 @@ void Application::InitializeImGui(HWND hwnd) {
m_imguiBackend,
m_windowRenderer.GetDevice(),
m_windowRenderer.GetCommandQueue());
m_viewportHostService.Initialize(m_imguiBackend, m_windowRenderer.GetRHIDevice());
static_cast<EditorContext*>(m_editorContext.get())->SetViewportHostService(&m_viewportHostService);
}
void Application::AttachEditorLayer() {
@@ -94,10 +97,18 @@ void Application::ShutdownEditorContext() {
void Application::RenderEditorFrame() {
static constexpr float kClearColor[4] = { 0.22f, 0.22f, 0.22f, 1.0f };
m_imguiBackend.BeginFrame();
m_viewportHostService.BeginFrame();
m_layerStack.onImGuiRender();
UpdateWindowTitle();
ImGui::Render();
m_windowRenderer.Render(m_imguiBackend, kClearColor);
m_windowRenderer.Render(
m_imguiBackend,
kClearColor,
[this](const Rendering::RenderContext& renderContext) {
if (m_editorContext) {
m_viewportHostService.RenderRequestedViewports(*m_editorContext, renderContext);
}
});
}
bool Application::Initialize(HWND hwnd) {
@@ -135,6 +146,10 @@ bool Application::Initialize(HWND hwnd) {
void Application::Shutdown() {
m_renderReady = false;
DetachEditorLayer();
if (m_editorContext) {
static_cast<EditorContext*>(m_editorContext.get())->SetViewportHostService(nullptr);
}
m_viewportHostService.Shutdown();
UI::ShutdownBuiltInIcons();
m_imguiBackend.Shutdown();
m_imguiSession.Shutdown();