heavy refactoring
This commit is contained in:
@@ -12,14 +12,24 @@ TestImgui::TestImgui(void* h, Archimedes::App* a) : Archimedes::GuiModule(h, a)
|
||||
}
|
||||
|
||||
TestImgui::~TestImgui() {
|
||||
windowModule->removeRenderCmd(rcmd);
|
||||
|
||||
std::list<Archimedes::Renderer::renderCmd*>* cmdList =
|
||||
std::any_cast<std::list<Archimedes::Renderer::renderCmd*>*>(depsInstances["WindowModule"]->getData("renderCmdList"));
|
||||
cmdList->erase(rcmd);
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
void TestImgui::onLoad() {
|
||||
|
||||
|
||||
Archimedes::Module* wm = depsInstances["WindowModule"];
|
||||
|
||||
if(!wm) {
|
||||
std::cout << "No WindowModule for TestImgui!\n";
|
||||
std::abort();
|
||||
}
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
@@ -27,26 +37,45 @@ void TestImgui::onLoad() {
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||
|
||||
// Setup Dear ImGui style
|
||||
// Setup Dear ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsLight();
|
||||
|
||||
std::cout << "init backends\n";
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplGlfw_InitForOpenGL(windowModule->getWindowImpl().getWindow(), true);
|
||||
ImGui_ImplOpenGL3_Init("#version 330");
|
||||
|
||||
rcmd = windowModule->addRenderCmd([](){
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
std::cout << wm->getName() << std::endl;
|
||||
GLFWwindow* w = std::any_cast<GLFWwindow*>(wm->getData("window"));
|
||||
|
||||
/*if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
}*/
|
||||
});
|
||||
std::cout << "TestImgui GLFWwindow*: " << w << std::endl;
|
||||
|
||||
if(!ImGui_ImplGlfw_InitForOpenGL(w, true))
|
||||
std::cout << "GLFWImpl failed\n";
|
||||
if(!ImGui_ImplOpenGL3_Init("#version 330")) {
|
||||
std::cout << "ImGui_ImplOpenGL3_Init failed!\n" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "register renderCmd\n";
|
||||
|
||||
|
||||
|
||||
std::list<Archimedes::Renderer::renderCmd*>* cmdList =
|
||||
std::any_cast<std::list<Archimedes::Renderer::renderCmd*>*>(wm->getData("renderCmdList"));
|
||||
|
||||
cmdList->push_back([](){
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
});
|
||||
|
||||
rcmd = --cmdList->end();
|
||||
cmdList->end()++;
|
||||
|
||||
//Compute first frame ahead of first WindowModule->run()
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::Render();
|
||||
}
|
||||
|
||||
void TestImgui::run() {
|
||||
@@ -60,5 +89,4 @@ void TestImgui::run() {
|
||||
app->end();
|
||||
|
||||
ImGui::Render();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user