persist module render commands

This commit is contained in:
2025-03-30 10:44:01 -05:00
parent 64636c2771
commit 03776d16bc
5 changed files with 26 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ TestImgui::TestImgui(void* h, Archimedes::App* a) : Archimedes::GuiModule(h, a)
}
TestImgui::~TestImgui() {
window->getRenderer().removeRenderCmd(rcmd);
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
@@ -39,7 +40,18 @@ void TestImgui::onLoad() {
// Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true);
ImGui_ImplOpenGL3_Init("#version 130");
rcmd = window->getRenderer().addRenderCmd([](){
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
/*if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}*/
});
//cmdlist.push_back(it);
}
void TestImgui::run() {
@@ -51,15 +63,6 @@ void TestImgui::run() {
ImGui::Render();
window->getRenderer().addRenderCmd([](){
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
/*if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}*/
});
if(window->shouldClose())
app->end();

View File

@@ -18,13 +18,14 @@ class TestImgui : public Archimedes::GuiModule {
private:
bool demo = true;
std::list<Archimedes::Renderer::renderCmd*>::iterator rcmd;
};
#ifndef TESTIMGUI_STATIC
extern "C" {
Archimedes::Module* create(void* handle, Archimedes::App* app) {
return new TestImgui(handle, app);
return (Archimedes::Module*) new TestImgui(handle, app);
}
}