-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimgui-render.cpp
More file actions
53 lines (45 loc) · 1.25 KB
/
imgui-render.cpp
File metadata and controls
53 lines (45 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <backends/imgui_impl_sdl3.h>
#include <backends/imgui_impl_sdlrenderer3.h>
#include <engine/imgui-render.hpp>
#include <imgui.h>
namespace Engine {
void ImGuiRender::Init(SDL_Window *window, SDL_Renderer *renderer) {
if (m_initialized)
return;
m_window = window;
m_renderer = renderer;
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGui_ImplSDL3_InitForSDLRenderer(m_window, m_renderer);
ImGui_ImplSDLRenderer3_Init(m_renderer);
m_initialized = true;
}
void ImGuiRender::ShutDown() {
if (!m_initialized)
return;
ImGui_ImplSDLRenderer3_Shutdown();
ImGui_ImplSDL3_Shutdown();
ImGui::DestroyContext();
m_window = nullptr;
m_renderer = nullptr;
m_initialized = false;
}
void ImGuiRender::BeginFrame() {
if (!m_initialized) return;
ImGui_ImplSDL3_NewFrame();
ImGui_ImplSDLRenderer3_NewFrame();
ImGui::NewFrame();
}
void ImGuiRender::EndFrame() {
if (!m_initialized)
return;
ImGui::Render();
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), m_renderer);
}
void ImGuiRender::ProcessEvent(const SDL_Event *e) {
if (!m_initialized || !e)
return;
ImGui_ImplSDL3_ProcessEvent(e);
}
} // namespace Engine