This commit is contained in:
2025-05-02 10:35:11 -05:00
parent 74b82845b5
commit 2ef95d6e90
6 changed files with 85 additions and 10 deletions

View File

@@ -39,7 +39,11 @@ void ImguiModule::onLoad() {
std::abort();
}
std::cout << "onLoad: " << name << "1\n";
window = wm->aquireWindow();
std::cout << "onLoad: " << name << "2\n";
IMGUI_CHECKVERSION();
context = ImGui::CreateContext();
@@ -57,13 +61,19 @@ void ImguiModule::onLoad() {
ImGui::StyleColorsDark();
//ImGui::StyleColorsLight();
std::cout << "onLoad: " << name << "3\n";
// Setup Platform/Renderer backends
if(!ImGui_ImplGlfw_InitForOpenGL(window->getWindowImpl().getWindow(), true))
std::cout << "GLFWImpl failed\n";
std::cout << "onLoad: " << name << "3.5\n";
if(!ImGui_ImplOpenGL3_Init("#version 330")) {
std::cout << "ImGui_ImplOpenGL3_Init failed!\n" << std::endl;
}
std::cout << "onLoad: " << name << "4\n";
wm->getRenderer()->getCmdList().push_back([](){
ImGui::Render();
@@ -75,12 +85,16 @@ void ImguiModule::onLoad() {
ImGui::NewFrame();
});
std::cout << "onLoad: " << name << "5\n";
rcmd_it = --wm->getRenderer()->getCmdList().end()++;
std::cout << "onLoad: " << name << "6\n";
//Compute first frame ahead of first WindowModule->run()
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
std::cout << "ImguiModule loaded\n";
}
bool ImguiModule::onEvent(const Archimedes::Event &event) {

View File

@@ -20,7 +20,7 @@ WindowModule::~WindowModule() {
}
if(window)
delete window;
releaseWindow(window);
}
}

View File

@@ -1,3 +1,8 @@
#include "modules/ImguiModule/src/ImguiModule.h"
#include "modules/ClientModule/src/ClientModule.h"
#include "ChatClient.h"
@@ -5,6 +10,8 @@ ChatClient::ChatClient(Archimedes::App* a, void* h) : Module(a, h) {
name = "ChatClient";
std::cout << name;
ClientModule* cm = new ClientModule(a, h);
deps[*cm] = cm;
cm->shouldHandleEvents(ClientModule::CMEventEnum::ConnectionStatusChanged | ClientModule::CMEventEnum::DataSent);
@@ -12,6 +19,8 @@ ChatClient::ChatClient(Archimedes::App* a, void* h) : Module(a, h) {
ImguiModule* im = new ImguiModule(a, h);
deps[*im] = im;
std::cout << " created!\n";
}
ChatClient::~ChatClient() {
@@ -30,12 +39,18 @@ void ChatClient::onLoad() {
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
if(!im) {
std::cout << "No ClientModule for ChatClient!\n";
std::cout << "No ImguiModule for ChatClient!\n";
std::abort();
}
ImGui::SetCurrentContext(im->aquireContext());
ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; }
if(!cm) {
std::cout << "No ClientModule for ChatClient!\n";
std::abort();
}
}
void ChatClient::run() {

View File

@@ -1,8 +1,5 @@
#include "Archimedes.h"
#include "modules/ClientModule/src/ClientModule.h"
#include "modules/ImguiModule/src/ImguiModule.h"
class ChatClient : public Archimedes::Module {
@@ -14,11 +11,11 @@ class ChatClient : public Archimedes::Module {
~ChatClient();
void onLoad();
void onLoad() override;
void run();
void run() override;
bool onEvent(const Archimedes::Event&);
bool onEvent(const Archimedes::Event&) override;
private:
std::string messages = "";