imgui wip

This commit is contained in:
Asuro
2025-02-19 01:53:28 +01:00
parent ad064112e6
commit 916677a190
3 changed files with 36 additions and 11 deletions

View File

@@ -2,9 +2,10 @@
#include "SDL3/SDL_mouse.h"
#include "Shared.h"
#include "Window.h"
#include "bx/timer.h"
#include <SDL3/SDL.h>
#include <backends/imgui_impl_sdl3.h>
#include <cstdio>
#include <imgui.h>
void EngineWindow::Startup(SharedWindowData& shared)
{
@@ -13,7 +14,7 @@ void EngineWindow::Startup(SharedWindowData& shared)
printf("Failed to init SDL!\n");
return;
}
Window = SDL_CreateWindow("SDL", shared.WindowWidth, shared.WindowHeight, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
Window = SDL_CreateWindow("SDL", shared.WindowWidth, shared.WindowHeight, SDL_WINDOW_RESIZABLE);
if (Window == nullptr)
{
printf("Failed to init SDL Window!\n");
@@ -29,6 +30,19 @@ void EngineWindow::Startup(SharedWindowData& shared)
return;
}
SDL_SetWindowRelativeMouseMode(Window, true);
IMGUI_CHECKVERSION();
auto* imguiCtx = ImGui::CreateContext();
if (imguiCtx == nullptr)
{
printf("Failed to set up imgui context!\n");
return;
}
if (!ImGui_ImplSDL3_InitForVulkan(Window))
{
printf("Failed to set up imgui implementation!\n");
return;
}
}
void EngineWindow::Update(SharedWindowData& shared)
@@ -37,6 +51,7 @@ void EngineWindow::Update(SharedWindowData& shared)
SDL_Event evt;
while (SDL_PollEvent(&evt))
{
ImGui_ImplSDL3_ProcessEvent(&evt);
switch (evt.type)
{
case SDL_EVENT_WINDOW_RESIZED: