// // Created by darman on 9/24/26. // #include "Window.h" #include #include namespace SiegeDeck::Engine { Window::Window(const SdlContext& /*sdl*/, const WindowDesc& desc) { // No SDL_WINDOW_VULKAN etc.: SDL_ClaimWindowForGPUDevice picks the backend later. SDL_WindowFlags flags = SDL_WINDOW_HIGH_PIXEL_DENSITY; if (desc.Resizable) flags |= SDL_WINDOW_RESIZABLE; if (desc.Fullscreen) flags |= SDL_WINDOW_FULLSCREEN; handle.reset(SDL_CreateWindow(desc.Title.c_str(), desc.Width, desc.Height, flags)); if (!handle) throw std::runtime_error(std::format("SDL_CreateWindow failed: {}", SDL_GetError())); glm::ivec2 pixels = PixelSize(); spdlog::info("Window {}x{} ({}x{} px, scale {:.2f})", desc.Width, desc.Height, pixels.x, pixels.y, DisplayScale()); } SDL_WindowID Window::Id() const { return SDL_GetWindowID(handle.get()); } glm::ivec2 Window::Size() const { glm::ivec2 size { 0 }; SDL_GetWindowSize(handle.get(), &size.x, &size.y); return size; } glm::ivec2 Window::PixelSize() const { glm::ivec2 size { 0 }; SDL_GetWindowSizeInPixels(handle.get(), &size.x, &size.y); return size; } float Window::DisplayScale() const { float scale = SDL_GetWindowDisplayScale(handle.get()); return scale > 0.0f ? scale : 1.0f; // 0 means SDL couldn't tell } void Window::SetTitle(const string& title) { SDL_SetWindowTitle(handle.get(), title.c_str()); } }