Add multiviewport support for SDL (#1275)

This commit is contained in:
David Chavez 2022-08-24 02:12:40 +02:00 committed by GitHub
parent d735616020
commit 70d7d66d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -41,8 +41,10 @@
#if __APPLE__
#include <SDL_hints.h>
#include <SDL_video.h>
#else
#include <SDL2/SDL_hints.h>
#include <SDL2/SDL_video.h>
#endif
#ifdef __SWITCH__
@ -337,6 +339,8 @@ namespace SohImGui {
switch (impl.backend) {
case Backend::DX11:
return true;
case Backend::SDL:
return true;
default:
return false;
}
@ -2398,8 +2402,18 @@ namespace SohImGui {
ImGui::Render();
ImGuiRenderDrawData(ImGui::GetDrawData());
if (UseViewports()) {
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
if (impl.backend == Backend::SDL) {
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
} else {
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
}
}

View File

@ -189,6 +189,7 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen, uint32
}
#endif
SDL_GL_MakeCurrent(wnd, ctx);
SDL_GL_SetSwapInterval(1);
SohImGui::WindowImpl window_impl;