imgui
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "../Mesh.h"
|
||||
#include "Rendering.h"
|
||||
|
||||
#include "SDL3/SDL_events.h"
|
||||
#include "backends/imgui_impl_sdl3.h"
|
||||
#include "bgfx/defines.h"
|
||||
#include "bx/filepath.h"
|
||||
#include "bx/math.h"
|
||||
@@ -228,6 +230,21 @@ namespace Game
|
||||
Materials[0] = Material::LoadFromShader("vert", "frag", Textures[0].Handle, Textures[0].SamplerHandle);
|
||||
imguiCreate();
|
||||
|
||||
if (!ImGui_ImplSDL3_InitForOther(shared.Window.SDLWindow))
|
||||
{
|
||||
Log("Failed to set up imgui implementation!");
|
||||
return;
|
||||
}
|
||||
|
||||
// ImGui::GetIO().BackendFlags |= ImGuiBackendFlags_RendererHasViewports;
|
||||
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
// ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||
// auto& platIO = ImGui::GetPlatformIO();
|
||||
// platIO.Renderer_CreateWindow = TODO;
|
||||
// platIO.Platform_DestroyWindow = TODO;
|
||||
// platIO.Platform_SetWindowSize = TODO;
|
||||
// platIO.Platform_RenderWindow = TODO;
|
||||
|
||||
if (!GetInstance().IsInitialized)
|
||||
{
|
||||
GetInstance().Time.StartTime = bx::getHPCounter();
|
||||
@@ -236,10 +253,19 @@ namespace Game
|
||||
|
||||
void GameRendering::Update()
|
||||
{
|
||||
imguiBeginFrame(0, 0, 0, 0, 100, 100);
|
||||
ImGui::ShowDemoWindow();
|
||||
SharedData& shared = GetShared();
|
||||
|
||||
for (uint16_t i = 0; i < shared.Window.SDLEventCount; ++i)
|
||||
{
|
||||
ImGui_ImplSDL3_ProcessEvent(&shared.Window.SDLEvents[i]);
|
||||
}
|
||||
shared.Window.SDLEventCount = 0;
|
||||
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
imguiBeginFrame(0, 0, 0, 0, shared.Window.WindowWidth, shared.Window.WindowHeight);
|
||||
ImGui::DockSpaceOverViewport();
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
// Reload shaders if necessary
|
||||
FileChangeNotification* shaderChange = nullptr;
|
||||
if (shared.Dev.ChangedShaderCount > 0)
|
||||
@@ -305,6 +331,12 @@ namespace Game
|
||||
}
|
||||
imguiEndFrame();
|
||||
|
||||
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
}
|
||||
|
||||
START_PERF();
|
||||
bgfx::frame();
|
||||
END_PERF(shared.Window.PerfCounters, PerfCounterType::Submit, shared.Window.FrameCounter);
|
||||
@@ -312,6 +344,7 @@ namespace Game
|
||||
|
||||
void GameRendering::Shutdown()
|
||||
{
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
imguiDestroy();
|
||||
bgfx::shutdown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user