From 104f089cd0a89af1cbbaafd789223de38f8e7658 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 22 Oct 2023 09:19:55 -0700 Subject: [PATCH 1/5] Compile fixes --- extern/dawn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/dawn b/extern/dawn index db82c79..07dd261 160000 --- a/extern/dawn +++ b/extern/dawn @@ -1 +1 @@ -Subproject commit db82c79db65e502dd226f5cb4e2c03d85f8ffd2d +Subproject commit 07dd2619e4a036fc8d3762e0d7b5017b0e5ac6a6 From 365cea46dae3bc35070842580d565eeb2c39b1e5 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 22 Oct 2023 17:15:06 -0700 Subject: [PATCH 2/5] Update dawn --- extern/dawn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/dawn b/extern/dawn index 07dd261..0ee5f8b 160000 --- a/extern/dawn +++ b/extern/dawn @@ -1 +1 @@ -Subproject commit 07dd2619e4a036fc8d3762e0d7b5017b0e5ac6a6 +Subproject commit 0ee5f8b4214ba0844011babf119daf05ba8869ff From 23b9ccb2ccda123a19b060b73495b3ba4e55988f Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 27 Oct 2023 13:14:42 -0700 Subject: [PATCH 3/5] Upgrade to Imgui 1.89.9-docking --- extern/imgui | 2 +- include/aurora/math.hpp | 2 +- lib/imgui.cpp | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/extern/imgui b/extern/imgui index 9aae45e..1d8e48c 160000 --- a/extern/imgui +++ b/extern/imgui @@ -1 +1 @@ -Subproject commit 9aae45eb4a05a5a1f96be1ef37eb503a12ceb889 +Subproject commit 1d8e48c161370c37628c4f37f3f87cb19fbcb723 diff --git a/include/aurora/math.hpp b/include/aurora/math.hpp index 4991859..7d51bad 100644 --- a/include/aurora/math.hpp +++ b/include/aurora/math.hpp @@ -23,7 +23,7 @@ #define __has_builtin(x) 0 #endif #if __has_attribute(vector_size) -//#define USE_GCC_VECTOR_EXTENSIONS +#define USE_GCC_VECTOR_EXTENSIONS #endif namespace aurora { diff --git a/lib/imgui.cpp b/lib/imgui.cpp index 4820ce8..7928064 100644 --- a/lib/imgui.cpp +++ b/lib/imgui.cpp @@ -7,8 +7,8 @@ #include #include -#include "../imgui/backends/imgui_impl_sdl.cpp" // NOLINT(bugprone-suspicious-include) -#include "../imgui/backends/imgui_impl_sdlrenderer.cpp" // NOLINT(bugprone-suspicious-include) +#include "../imgui/backends/imgui_impl_sdl2.cpp" // NOLINT(bugprone-suspicious-include) +#include "../imgui/backends/imgui_impl_sdlrenderer2.cpp" // NOLINT(bugprone-suspicious-include) // #include "../imgui/backends/imgui_impl_wgpu.cpp" // NOLINT(bugprone-suspicious-include) // TODO: Transition back to imgui-provided backend when it uses WGSL #include "imgui_impl_wgpu.cpp" // NOLINT(bugprone-suspicious-include) @@ -34,14 +34,14 @@ void create_context() noexcept { void initialize() noexcept { SDL_Renderer* renderer = window::get_sdl_renderer(); - ImGui_ImplSDL2_Init(window::get_sdl_window(), renderer); + ImGui_ImplSDL2_Init(window::get_sdl_window(), renderer, NULL); #ifdef __APPLE__ // Disable MouseCanUseGlobalState for scaling purposes ImGui_ImplSDL2_GetBackendData()->MouseCanUseGlobalState = false; #endif g_useSdlRenderer = renderer != nullptr; if (g_useSdlRenderer) { - ImGui_ImplSDLRenderer_Init(renderer); + ImGui_ImplSDLRenderer2_Init(renderer); } else { const auto format = webgpu::g_graphicsConfig.swapChainDescriptor.format; ImGui_ImplWGPU_Init(webgpu::g_device.Get(), 1, static_cast(format)); @@ -50,7 +50,7 @@ void initialize() noexcept { void shutdown() noexcept { if (g_useSdlRenderer) { - ImGui_ImplSDLRenderer_Shutdown(); + ImGui_ImplSDLRenderer2_Shutdown(); } else { ImGui_ImplWGPU_Shutdown(); } @@ -77,7 +77,7 @@ void process_event(const SDL_Event& event) noexcept { void new_frame(const AuroraWindowSize& size) noexcept { if (g_useSdlRenderer) { - ImGui_ImplSDLRenderer_NewFrame(); + ImGui_ImplSDLRenderer2_NewFrame(); } else { if (g_scale != size.scale) { if (g_scale > 0.f) { @@ -106,9 +106,9 @@ void render(const wgpu::RenderPassEncoder& pass) noexcept { // io.DisplayFramebufferScale is informational; we're rendering at full DPI data->FramebufferScale = {1.f, 1.f}; if (g_useSdlRenderer) { - SDL_Renderer* renderer = ImGui_ImplSDLRenderer_GetBackendData()->SDLRenderer; + SDL_Renderer* renderer = ImGui_ImplSDLRenderer2_GetBackendData()->SDLRenderer; SDL_RenderClear(renderer); - ImGui_ImplSDLRenderer_RenderDrawData(data); + ImGui_ImplSDLRenderer2_RenderDrawData(data); SDL_RenderPresent(renderer); } else { ImGui_ImplWGPU_RenderDrawData(data, pass.Get()); @@ -117,7 +117,7 @@ void render(const wgpu::RenderPassEncoder& pass) noexcept { ImTextureID add_texture(uint32_t width, uint32_t height, const uint8_t* data) noexcept { if (g_useSdlRenderer) { - SDL_Renderer* renderer = ImGui_ImplSDLRenderer_GetBackendData()->SDLRenderer; + SDL_Renderer* renderer = ImGui_ImplSDLRenderer2_GetBackendData()->SDLRenderer; SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, width, height); SDL_UpdateTexture(texture, nullptr, data, width * 4); SDL_SetTextureScaleMode(texture, SDL_ScaleModeLinear); From 5589b24df6f59bba0df8191f9f1f81478269cd99 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 27 Oct 2023 14:31:57 -0700 Subject: [PATCH 4/5] Add AURORA_WINDOW_MOVED event and add ability to set window position at launch --- include/aurora/aurora.h | 7 +++++++ include/aurora/event.h | 2 ++ lib/window.cpp | 20 ++++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/aurora/aurora.h b/include/aurora/aurora.h index 1cc9877..1bd6af9 100644 --- a/include/aurora/aurora.h +++ b/include/aurora/aurora.h @@ -31,6 +31,11 @@ typedef enum { LOG_FATAL, } AuroraLogLevel; +typedef struct { + int32_t x; + int32_t y; +} AuroraWindowPos; + typedef struct { uint32_t width; uint32_t height; @@ -52,6 +57,8 @@ typedef struct { uint32_t msaa; uint16_t maxTextureAnisotropy; bool startFullscreen; + int32_t windowPosX; + int32_t windowPosY; uint32_t windowWidth; uint32_t windowHeight; void* iconRGBA8; diff --git a/include/aurora/event.h b/include/aurora/event.h index 0cb7146..3af13f0 100644 --- a/include/aurora/event.h +++ b/include/aurora/event.h @@ -17,6 +17,7 @@ typedef enum { AURORA_NONE, AURORA_EXIT, AURORA_SDL_EVENT, + AURORA_WINDOW_MOVED, AURORA_WINDOW_RESIZED, AURORA_CONTROLLER_ADDED, AURORA_CONTROLLER_REMOVED, @@ -28,6 +29,7 @@ struct AuroraEvent { AuroraEventType type; union { SDL_Event sdl; + AuroraWindowPos windowPos; AuroraWindowSize windowSize; int32_t controller; }; diff --git a/lib/window.cpp b/lib/window.cpp index 1292742..1f1a7d8 100644 --- a/lib/window.cpp +++ b/lib/window.cpp @@ -59,6 +59,13 @@ const AuroraEvent* poll_events() { }); break; } + case SDL_WINDOWEVENT_MOVED: { + g_events.push_back(AuroraEvent{ + .type = AURORA_WINDOW_MOVED, + .windowPos = {.x = event.window.data1, .y = event.window.data2}, + }); + break; + } case SDL_WINDOWEVENT_SIZE_CHANGED: { resize_swapchain(false); g_events.push_back(AuroraEvent{ @@ -154,8 +161,16 @@ bool create_window(AuroraBackend backend) { width = 1280; height = 960; } + + int32_t x = g_config.windowPosX; + int32_t y = g_config.windowPosY; + if (x < 0 || y < 0) { + x = SDL_WINDOWPOS_UNDEFINED; + y = SDL_WINDOWPOS_UNDEFINED; + } + #endif - g_window = SDL_CreateWindow(g_config.appName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags); + g_window = SDL_CreateWindow(g_config.appName, x, y, width, height, flags); if (g_window == nullptr) { Log.report(LOG_WARNING, FMT_STRING("Failed to create window: {}"), SDL_GetError()); return false; @@ -196,7 +211,8 @@ void show_window() { bool initialize() { /* We don't want to initialize anything input related here, otherwise the add events will get lost to the void */ - ASSERT(SDL_Init(SDL_INIT_EVERYTHING & ~(SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)) == 0, "Error initializing SDL: {}", SDL_GetError()); + ASSERT(SDL_Init(SDL_INIT_EVERYTHING & ~(SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)) == 0, + "Error initializing SDL: {}", SDL_GetError()); #if !defined(_WIN32) && !defined(__APPLE__) SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); From 6f6861215150abc4fa00197de43754525cac07a6 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 15 Dec 2023 14:34:18 -0800 Subject: [PATCH 5/5] Add `allowJoystickBackgroundEvents` to config --- include/aurora/aurora.h | 1 + lib/window.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/aurora/aurora.h b/include/aurora/aurora.h index 1bd6af9..10a04ac 100644 --- a/include/aurora/aurora.h +++ b/include/aurora/aurora.h @@ -57,6 +57,7 @@ typedef struct { uint32_t msaa; uint16_t maxTextureAnisotropy; bool startFullscreen; + bool allowJoystickBackgroundEvents; int32_t windowPosX; int32_t windowPosY; uint32_t windowWidth; diff --git a/lib/window.cpp b/lib/window.cpp index 1f1a7d8..8965baa 100644 --- a/lib/window.cpp +++ b/lib/window.cpp @@ -225,8 +225,9 @@ bool initialize() { #endif SDL_DisableScreenSaver(); - /* TODO: Make this an option rather than hard coding it */ - SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); + if (g_config.allowJoystickBackgroundEvents) { + SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); + } return true; }