From 3d7a2f7cbc69bcfb5b04d343cb15c3027721b2e7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 16 Jun 2024 12:28:42 +0100 Subject: Integrate ImGUI main calls --- ui/mainApplication.cpp | 7 +++++++ ui/window.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/ui/mainApplication.cpp b/ui/mainApplication.cpp index 08f49a4..d843ef1 100644 --- a/ui/mainApplication.cpp +++ b/ui/mainApplication.cpp @@ -1,6 +1,10 @@ #include "mainApplication.h" #include "game/gamestate.h" #include "game/worldobject.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" +#include "backends/imgui_impl_sdl2.h" +#pragma GCC diagnostic pop void MainApplication::mainLoop() @@ -16,6 +20,8 @@ MainApplication::mainLoop() } windows.apply(&Window::tick, t_passed); windows.apply(&Window::refresh); + ImGui::UpdatePlatformWindows(); + ImGui::RenderPlatformWindowsDefault(); t_start = t_end; } @@ -29,6 +35,7 @@ MainApplication::processInputs() isRunning = false; return; } + ImGui_ImplSDL2_ProcessEvent(&e); windows.applyOne(&Window::handleInput, e); } } diff --git a/ui/window.cpp b/ui/window.cpp index 8ceaf49..732e9ef 100644 --- a/ui/window.cpp +++ b/ui/window.cpp @@ -1,6 +1,11 @@ #include "window.h" #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" +#include "backends/imgui_impl_opengl3.h" +#include "backends/imgui_impl_sdl2.h" +#pragma GCC diagnostic pop Window::Window(size_t width, size_t height, const std::string & title, Uint32 flags) : size {static_cast(width), static_cast(height)}, @@ -48,9 +53,15 @@ Window::refresh() const SDL_GL_MakeCurrent(m_window, glContext); clear(0.0F, 0.0F, 0.0F, 1.0F); + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(); + ImGui::NewFrame(); if (content) { content->render(); + // Render UI stuff here } + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); swapBuffers(); } -- cgit v1.2.3