mirror of https://github.com/encounter/aurora.git
Upgrade to Imgui 1.89.9-docking
This commit is contained in:
parent
365cea46da
commit
23b9ccb2cc
|
@ -1 +1 @@
|
||||||
Subproject commit 9aae45eb4a05a5a1f96be1ef37eb503a12ceb889
|
Subproject commit 1d8e48c161370c37628c4f37f3f87cb19fbcb723
|
|
@ -23,7 +23,7 @@
|
||||||
#define __has_builtin(x) 0
|
#define __has_builtin(x) 0
|
||||||
#endif
|
#endif
|
||||||
#if __has_attribute(vector_size)
|
#if __has_attribute(vector_size)
|
||||||
//#define USE_GCC_VECTOR_EXTENSIONS
|
#define USE_GCC_VECTOR_EXTENSIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace aurora {
|
namespace aurora {
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
|
|
||||||
#include "../imgui/backends/imgui_impl_sdl.cpp" // NOLINT(bugprone-suspicious-include)
|
#include "../imgui/backends/imgui_impl_sdl2.cpp" // NOLINT(bugprone-suspicious-include)
|
||||||
#include "../imgui/backends/imgui_impl_sdlrenderer.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)
|
// #include "../imgui/backends/imgui_impl_wgpu.cpp" // NOLINT(bugprone-suspicious-include)
|
||||||
// TODO: Transition back to imgui-provided backend when it uses WGSL
|
// TODO: Transition back to imgui-provided backend when it uses WGSL
|
||||||
#include "imgui_impl_wgpu.cpp" // NOLINT(bugprone-suspicious-include)
|
#include "imgui_impl_wgpu.cpp" // NOLINT(bugprone-suspicious-include)
|
||||||
|
@ -34,14 +34,14 @@ void create_context() noexcept {
|
||||||
|
|
||||||
void initialize() noexcept {
|
void initialize() noexcept {
|
||||||
SDL_Renderer* renderer = window::get_sdl_renderer();
|
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__
|
#ifdef __APPLE__
|
||||||
// Disable MouseCanUseGlobalState for scaling purposes
|
// Disable MouseCanUseGlobalState for scaling purposes
|
||||||
ImGui_ImplSDL2_GetBackendData()->MouseCanUseGlobalState = false;
|
ImGui_ImplSDL2_GetBackendData()->MouseCanUseGlobalState = false;
|
||||||
#endif
|
#endif
|
||||||
g_useSdlRenderer = renderer != nullptr;
|
g_useSdlRenderer = renderer != nullptr;
|
||||||
if (g_useSdlRenderer) {
|
if (g_useSdlRenderer) {
|
||||||
ImGui_ImplSDLRenderer_Init(renderer);
|
ImGui_ImplSDLRenderer2_Init(renderer);
|
||||||
} else {
|
} else {
|
||||||
const auto format = webgpu::g_graphicsConfig.swapChainDescriptor.format;
|
const auto format = webgpu::g_graphicsConfig.swapChainDescriptor.format;
|
||||||
ImGui_ImplWGPU_Init(webgpu::g_device.Get(), 1, static_cast<WGPUTextureFormat>(format));
|
ImGui_ImplWGPU_Init(webgpu::g_device.Get(), 1, static_cast<WGPUTextureFormat>(format));
|
||||||
|
@ -50,7 +50,7 @@ void initialize() noexcept {
|
||||||
|
|
||||||
void shutdown() noexcept {
|
void shutdown() noexcept {
|
||||||
if (g_useSdlRenderer) {
|
if (g_useSdlRenderer) {
|
||||||
ImGui_ImplSDLRenderer_Shutdown();
|
ImGui_ImplSDLRenderer2_Shutdown();
|
||||||
} else {
|
} else {
|
||||||
ImGui_ImplWGPU_Shutdown();
|
ImGui_ImplWGPU_Shutdown();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ void process_event(const SDL_Event& event) noexcept {
|
||||||
|
|
||||||
void new_frame(const AuroraWindowSize& size) noexcept {
|
void new_frame(const AuroraWindowSize& size) noexcept {
|
||||||
if (g_useSdlRenderer) {
|
if (g_useSdlRenderer) {
|
||||||
ImGui_ImplSDLRenderer_NewFrame();
|
ImGui_ImplSDLRenderer2_NewFrame();
|
||||||
} else {
|
} else {
|
||||||
if (g_scale != size.scale) {
|
if (g_scale != size.scale) {
|
||||||
if (g_scale > 0.f) {
|
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
|
// io.DisplayFramebufferScale is informational; we're rendering at full DPI
|
||||||
data->FramebufferScale = {1.f, 1.f};
|
data->FramebufferScale = {1.f, 1.f};
|
||||||
if (g_useSdlRenderer) {
|
if (g_useSdlRenderer) {
|
||||||
SDL_Renderer* renderer = ImGui_ImplSDLRenderer_GetBackendData()->SDLRenderer;
|
SDL_Renderer* renderer = ImGui_ImplSDLRenderer2_GetBackendData()->SDLRenderer;
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
ImGui_ImplSDLRenderer_RenderDrawData(data);
|
ImGui_ImplSDLRenderer2_RenderDrawData(data);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
} else {
|
} else {
|
||||||
ImGui_ImplWGPU_RenderDrawData(data, pass.Get());
|
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 {
|
ImTextureID add_texture(uint32_t width, uint32_t height, const uint8_t* data) noexcept {
|
||||||
if (g_useSdlRenderer) {
|
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_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, width, height);
|
||||||
SDL_UpdateTexture(texture, nullptr, data, width * 4);
|
SDL_UpdateTexture(texture, nullptr, data, width * 4);
|
||||||
SDL_SetTextureScaleMode(texture, SDL_ScaleModeLinear);
|
SDL_SetTextureScaleMode(texture, SDL_ScaleModeLinear);
|
||||||
|
|
Loading…
Reference in New Issue