persist module render commands
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Archimedes {
|
||||
|
||||
protected:
|
||||
Window* window;
|
||||
//Renderer* renderer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,16 @@ namespace Archimedes {
|
||||
|
||||
void render();
|
||||
|
||||
void addRenderCmd(renderCmd* cmd) { rc.push_back(cmd); }
|
||||
std::list<renderCmd*>::iterator addRenderCmd(renderCmd* cmd) {
|
||||
|
||||
auto it = rc.end();
|
||||
rc.push_back(cmd);
|
||||
return it;
|
||||
}
|
||||
|
||||
void removeRenderCmd(std::list<renderCmd*>::iterator cmd) {
|
||||
rc.erase(cmd);
|
||||
}
|
||||
|
||||
private:
|
||||
std::list<renderCmd*> rc;
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Archimedes {
|
||||
|
||||
for(auto* f : cmdList)
|
||||
f();
|
||||
cmdList.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user