imgui
This commit is contained in:
@@ -63,8 +63,14 @@ struct PerfCounter
|
||||
}
|
||||
};
|
||||
|
||||
class SDL_Window;
|
||||
union SDL_Event;
|
||||
|
||||
struct SharedWindowData
|
||||
{
|
||||
SDL_Window* SDLWindow = nullptr;
|
||||
SDL_Event* SDLEvents{nullptr};
|
||||
uint16_t SDLEventCount = 0;
|
||||
void* Handle = nullptr;
|
||||
int32_t WindowWidth = 1920;
|
||||
int32_t WindowHeight = 1080;
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
#include "Shared.h"
|
||||
#include "Window.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <backends/imgui_impl_sdl3.h>
|
||||
#include <cstdio>
|
||||
#include <imgui.h>
|
||||
|
||||
void EngineWindow::Startup(SharedWindowData& shared)
|
||||
{
|
||||
@@ -29,29 +27,28 @@ void EngineWindow::Startup(SharedWindowData& shared)
|
||||
printf("Failed to get window pointer!\n");
|
||||
return;
|
||||
}
|
||||
shared.SDLWindow = Window;
|
||||
// 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)
|
||||
{
|
||||
START_PERF();
|
||||
shared.SDLEvents = &EventBuffer[0];
|
||||
|
||||
SDL_Event evt;
|
||||
while (SDL_PollEvent(&evt))
|
||||
{
|
||||
ImGui_ImplSDL3_ProcessEvent(&evt);
|
||||
if (shared.SDLEventCount < MaxEventBufferSize)
|
||||
{
|
||||
EventBuffer[shared.SDLEventCount] = evt;
|
||||
++shared.SDLEventCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Warning: Skipping SDL event!\n");
|
||||
}
|
||||
|
||||
switch (evt.type)
|
||||
{
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
class EngineWindow
|
||||
{
|
||||
static constexpr uint32_t MaxEventBufferSize = 16;
|
||||
|
||||
public:
|
||||
SDL_Window* Window;
|
||||
bool CloseRequested = false;
|
||||
SDL_Event EventBuffer[MaxEventBufferSize];
|
||||
|
||||
public:
|
||||
void Startup(SharedWindowData& Shared);
|
||||
|
||||
Reference in New Issue
Block a user