Skip to content

Commit 8d24192

Browse files
committed
imgui impl
1 parent cc421a5 commit 8d24192

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+41
-0
lines changed

Source/GUI/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ sources += files(
3434
'GUIUtil.cpp',
3535
'GUIWriter.cpp'
3636
)
37+
38+
subdir('imgui')

Source/Main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
#include "RenderTarget.h"
5757
#include "tracy/Tracy.hpp"
5858

59+
#include "imgui_impl_sdl3.h"
60+
5961
#ifdef _WIN32
6062
#include "windows.h"
6163
#endif
@@ -232,6 +234,7 @@ void PollSDLEvents() {
232234
default:
233235
break;
234236
}
237+
ImGui_ImplSDL3_ProcessEvent(&sdlEvent);
235238
if (sdlEvent.type >= SDL_EVENT_WINDOW_FIRST && sdlEvent.type <= SDL_EVENT_WINDOW_LAST) {
236239
g_WindowMan.QueueWindowEvent(sdlEvent);
237240
}

Source/Managers/WindowMan.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include "tracy/Tracy.hpp"
2222
#include "tracy/TracyOpenGL.hpp"
2323

24+
#include "GUI/imgui/imgui.h"
25+
#include "GUI/imgui/backends/imgui_impl_sdl3.h"
26+
#include "GUI/imgui/backends/imgui_impl_opengl3.h"
27+
2428
#ifdef __linux__
2529
#include "Resources/cccp.xpm"
2630
#include <SDL3_image/SDL_image.h>
@@ -81,6 +85,9 @@ WindowMan::WindowMan() {
8185
WindowMan::~WindowMan() = default;
8286

8387
void WindowMan::Destroy() {
88+
ImGui_ImplOpenGL3_Shutdown();
89+
ImGui_ImplSDL3_Shutdown();
90+
ImGui::DestroyContext();
8491
GL_CHECK(glDeleteTextures(1, &m_BackBuffer32Texture));
8592
GL_CHECK(glDeleteBuffers(1, &m_ScreenVBO));
8693
GL_CHECK(glDeleteVertexArrays(1, &m_ScreenVAO));
@@ -105,6 +112,20 @@ void WindowMan::Initialize() {
105112
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
106113
CreatePrimaryWindow();
107114
InitializeOpenGL();
115+
116+
IMGUI_CHECKVERSION();
117+
ImGui::CreateContext();
118+
ImGuiIO& io = ImGui::GetIO();
119+
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
120+
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
121+
122+
ImGui::StyleColorsDark();
123+
ImGui_ImplSDL3_InitForOpenGL(m_PrimaryWindow.get(), m_GLContext.get());
124+
ImGui_ImplOpenGL3_Init("#version 130");
125+
ImGui_ImplOpenGL3_NewFrame();
126+
ImGui_ImplSDL3_NewFrame();
127+
ImGui::NewFrame();
128+
108129
CreateBackBufferTexture();
109130
m_ScreenBlitShader = std::make_unique<Shader>(g_PresetMan.GetFullModulePath("Base.rte/Shaders/ScreenBlit.vert"), g_PresetMan.GetFullModulePath("Base.rte/Shaders/ScreenBlit.frag"));
110131

@@ -760,9 +781,14 @@ void WindowMan::UploadFrame() {
760781
rlDrawRenderBatchActive();
761782
}
762783
}
784+
ImGui::Render();
785+
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
763786
Present();
764787
TracyGpuCollect;
765788
FrameMark;
789+
ImGui_ImplOpenGL3_NewFrame();
790+
ImGui_ImplSDL3_NewFrame();
791+
ImGui::NewFrame();
766792
}
767793

768794
void WindowMan::Present() {
390 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)