added onrender function to use sdl render in client, enabled multiviewports in imgui

This commit is contained in:
2026-04-06 15:06:14 +02:00
parent 5b40377d04
commit fd319405e5
3 changed files with 13 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
#include "Layer.h" #include "Layer.h"
#include "Log.h" #include "Log.h"
#include "SDL3/SDL_events.h" #include "SDL3/SDL_events.h"
#include "SDL3/SDL_hints.h"
#include "SDL3/SDL_main.h" #include "SDL3/SDL_main.h"
#include "SDL3/SDL_render.h" #include "SDL3/SDL_render.h"
#include "SDL3/SDL_stdinc.h" #include "SDL3/SDL_stdinc.h"
@@ -136,6 +137,11 @@ void Application::Run() {
} }
// Rendering // Rendering
for (auto &layer : m_LayerStack) {
layer->OnRender();
}
m_ImGui->Begin(); m_ImGui->Begin();
SDL_SetRenderScale(m_Renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); SDL_SetRenderScale(m_Renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
@@ -148,6 +154,11 @@ void Application::Run() {
m_ImGui->End(); m_ImGui->End();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
SDL_RenderPresent(m_Renderer); SDL_RenderPresent(m_Renderer);
} }
} }

View File

@@ -17,6 +17,7 @@ public:
virtual void OnAttach() {} virtual void OnAttach() {}
virtual void OnDetach() {} virtual void OnDetach() {}
virtual void OnImGuiRender() {} virtual void OnImGuiRender() {}
virtual void OnRender() {}
virtual void Suspend() { m_isActive = false; } virtual void Suspend() { m_isActive = false; }
virtual void Activate() { m_isActive = true; } virtual void Activate() { m_isActive = true; }

View File

@@ -17,6 +17,7 @@ void ImGuiInit::Init() {
ImGuiIO &io = ImGui::GetIO(); ImGuiIO &io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();