This commit is contained in:
2025-04-09 22:07:41 -05:00
parent 6db62591c4
commit e3bc75dea8
3 changed files with 17 additions and 4 deletions

View File

@@ -1,6 +1,5 @@
#include "ImguiModule.h" #include "ImguiModule.h"
#include "imgui.h"
#include "backends/imgui_impl_glfw.h" #include "backends/imgui_impl_glfw.h"
#include "backends/imgui_impl_opengl3.h" #include "backends/imgui_impl_opengl3.h"
@@ -27,7 +26,7 @@ void ImguiModule::onLoad() {
} }
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
ImGui::CreateContext(); context = ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls

View File

@@ -6,6 +6,8 @@
#include "utils/Window/Window.h" #include "utils/Window/Window.h"
#include "imgui.h"
class ImguiModule : public Archimedes::GuiModule { class ImguiModule : public Archimedes::GuiModule {
public: public:
@@ -19,9 +21,11 @@ class ImguiModule : public Archimedes::GuiModule {
void run(); void run();
ImGuiContext* getContext() { return context; }
private: private:
ImGuiContext* context;
}; };
#ifdef IMGUIMODULE_DYNAMIC #ifdef IMGUIMODULE_DYNAMIC

View File

@@ -28,6 +28,16 @@ void TestImgui::onLoad() {
std::cout << "No WindowModule for TestImgui!\n"; std::cout << "No WindowModule for TestImgui!\n";
std::abort(); std::abort();
} }
ImguiModule* im = (ImguiModule*) moduleInstances["ImguiModule"];
if(!im) {
std::cout << "No ImguiModule for TestImgui!\n";
std::abort();
}
ImGui::SetCurrentContext(im->getContext());
} }
void TestImgui::run() { void TestImgui::run() {
@@ -41,7 +51,7 @@ void TestImgui::run() {
static float f = 0.0f; static float f = 0.0f;
static int counter = 0; static int counter = 0;
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. ImGui::Begin("TestImgui Module"); // Create a window called "Hello, world!" and append into it.
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)