Skip to content

Commit

Permalink
- select correct imgui framescript depending on if editor is used
Browse files Browse the repository at this point in the history
  • Loading branch information
kaffeewolf committed Nov 24, 2024
1 parent e49fe18 commit f88c651
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
42 changes: 20 additions & 22 deletions code/addons/dynui/imguicontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ ImguiDrawFunction(const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<
CoreGraphics::CmdSetGraphicsPipeline(cmdBuf, ImguiContext::state.editorPipeline);
}
else
#endif
{
CoreGraphics::CmdSetGraphicsPipeline(cmdBuf, ImguiContext::state.pipeline);
}
#else
CoreGraphics::CmdSetGraphicsPipeline(cmdBuf, ImguiContext::state.pipeline);
#endif

// setup input buffers
CoreGraphics::CmdSetVertexLayout(cmdBuf, ImguiContext::state.vlo);
Expand Down Expand Up @@ -355,25 +353,7 @@ ImguiContext::Create()
components.Append(VertexComponent(1, VertexComponent::Float2, 0));
components.Append(VertexComponent(2, VertexComponent::UByte4N, 0));
state.vlo = CoreGraphics::CreateVertexLayout({ .name = "ImGui"_atm, .comps = components });

/*
FrameScript_default::RegisterSubgraphPipelines_ImGUI_Pass([](const CoreGraphics::PassId pass, uint subpass)
{
CoreGraphics::InputAssemblyKey inputAssembly{ CoreGraphics::PrimitiveTopology::TriangleList, false };
if (state.pipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(state.pipeline);
state.pipeline = CoreGraphics::CreateGraphicsPipeline({ state.prog, pass, subpass, inputAssembly });
});
FrameScript_default::RegisterSubgraph_ImGUI_Pass([](const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<int>& viewport, const IndexT frame, const IndexT bufferIndex)
{
#ifdef NEBULA_NO_DYNUI_ASSERTS
ImguiContext::RecoverImGuiContextErrors();
#endif
ImGui::Render();
ImguiDrawFunction(cmdBuf, viewport);
});
*/


#if WITH_NEBULA_EDITOR
if (App::GameApplication::IsEditorEnabled())
{
Expand All @@ -394,7 +374,25 @@ ImguiContext::Create()
ImguiDrawFunction(cmdBuf, viewport);
});
}
else
#endif
{
FrameScript_default::RegisterSubgraphPipelines_ImGUI_Pass([](const CoreGraphics::PassId pass, uint subpass)
{
CoreGraphics::InputAssemblyKey inputAssembly{ CoreGraphics::PrimitiveTopology::TriangleList, false };
if (state.pipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(state.pipeline);
state.pipeline = CoreGraphics::CreateGraphicsPipeline({ state.prog, pass, subpass, inputAssembly });
});
FrameScript_default::RegisterSubgraph_ImGUI_Pass([](const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<int>& viewport, const IndexT frame, const IndexT bufferIndex)
{
#ifdef NEBULA_NO_DYNUI_ASSERTS
ImguiContext::RecoverImGuiContextErrors();
#endif
ImGui::Render();
ImguiDrawFunction(cmdBuf, viewport);
});
}

SizeT numBuffers = CoreGraphics::GetNumBufferedFrames();

Expand Down
17 changes: 13 additions & 4 deletions code/addons/graphicsfeature/graphicsfeatureunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ GraphicsFeatureUnit::OnActivate()
FrameScript_shadows::Initialize(1024, 1024);
FrameScript_default::Initialize(mode.GetWidth(), mode.GetHeight());
#if WITH_NEBULA_EDITOR
FrameScript_editorframe::Initialize(mode.GetWidth(), mode.GetHeight());
if (App::GameApplication::IsEditorEnabled())
{
FrameScript_editorframe::Initialize(mode.GetWidth(), mode.GetHeight());
}
#endif
this->defaultView = gfxServer->CreateView("mainview", FrameScript_default::Run, Math::rectangle<int>(0, 0, mode.GetWidth(), mode.GetHeight()));
this->defaultStage = gfxServer->CreateStage("defaultStage", true);
Expand Down Expand Up @@ -269,8 +272,11 @@ GraphicsFeatureUnit::OnActivate()
FrameScript_default::Initialize(windowWidth, windowHeight);
FrameScript_default::SetupPipelines();
#if WITH_NEBULA_EDITOR
FrameScript_editorframe::Initialize(windowWidth, windowHeight);
FrameScript_editorframe::SetupPipelines();
if (App::GameApplication::IsEditorEnabled())
{
FrameScript_editorframe::Initialize(windowWidth, windowHeight);
FrameScript_editorframe::SetupPipelines();
}
#endif
});

Expand Down Expand Up @@ -354,7 +360,10 @@ GraphicsFeatureUnit::OnActivate()
FrameScript_default::SetupPipelines();
FrameScript_shadows::SetupPipelines();
#if WITH_NEBULA_EDITOR
FrameScript_editorframe::SetupPipelines();
if (App::GameApplication::IsEditorEnabled())
{
FrameScript_editorframe::SetupPipelines();
}
#endif
this->defaultViewHandle = CameraManager::RegisterView(this->defaultView);
}
Expand Down

0 comments on commit f88c651

Please sign in to comment.