persist module render commands
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Archimedes {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Window* window;
|
Window* window;
|
||||||
|
//Renderer* renderer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,16 @@ namespace Archimedes {
|
|||||||
|
|
||||||
void render();
|
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:
|
private:
|
||||||
std::list<renderCmd*> rc;
|
std::list<renderCmd*> rc;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace Archimedes {
|
|||||||
|
|
||||||
for(auto* f : cmdList)
|
for(auto* f : cmdList)
|
||||||
f();
|
f();
|
||||||
cmdList.clear();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ TestImgui::TestImgui(void* h, Archimedes::App* a) : Archimedes::GuiModule(h, a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestImgui::~TestImgui() {
|
TestImgui::~TestImgui() {
|
||||||
|
window->getRenderer().removeRenderCmd(rcmd);
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
@@ -40,6 +41,17 @@ void TestImgui::onLoad() {
|
|||||||
ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true);
|
ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 130");
|
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() {
|
void TestImgui::run() {
|
||||||
@@ -51,15 +63,6 @@ void TestImgui::run() {
|
|||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
window->getRenderer().addRenderCmd([](){
|
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
||||||
|
|
||||||
/*if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
|
||||||
{
|
|
||||||
ImGui::UpdatePlatformWindows();
|
|
||||||
ImGui::RenderPlatformWindowsDefault();
|
|
||||||
}*/
|
|
||||||
});
|
|
||||||
|
|
||||||
if(window->shouldClose())
|
if(window->shouldClose())
|
||||||
app->end();
|
app->end();
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ class TestImgui : public Archimedes::GuiModule {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool demo = true;
|
bool demo = true;
|
||||||
|
std::list<Archimedes::Renderer::renderCmd*>::iterator rcmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef TESTIMGUI_STATIC
|
#ifndef TESTIMGUI_STATIC
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
Archimedes::Module* create(void* handle, Archimedes::App* app) {
|
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