DPI awareness, TODO: handle moving to different monitors

This commit is contained in:
CocoSimone
2022-12-09 05:40:32 +01:00
parent da25baccad
commit bbcc453ae2

View File

@@ -5,6 +5,7 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <filesystem> #include <filesystem>
#include <SDL.h> #include <SDL.h>
#include <SDL_vulkan.h>
VkInstance instance{}; VkInstance instance{};
using json = nlohmann::json; using json = nlohmann::json;
@@ -116,6 +117,17 @@ void Window::InitImgui(const n64::Core& core) {
uiFont = io.Fonts->AddFontFromFileTTF("resources/OpenSans.ttf", 15.f); uiFont = io.Fonts->AddFontFromFileTTF("resources/OpenSans.ttf", 15.f);
codeFont = io.Fonts->AddFontFromFileTTF("resources/Sweet16.ttf", 15.f); codeFont = io.Fonts->AddFontFromFileTTF("resources/Sweet16.ttf", 15.f);
int displayIndex = SDL_GetWindowDisplayIndex(window);
float ddpi, hdpi, vdpi;
SDL_GetDisplayDPI(displayIndex, &ddpi, &hdpi, &vdpi);
ddpi /= 96.f;
uiFont = io.Fonts->AddFontFromFileTTF("resources/OpenSans.ttf", 16.f * ddpi);
codeFont = io.Fonts->AddFontFromFileTTF("resources/Sweet16.ttf", 16.f * ddpi);
ImGui::GetStyle().ScaleAllSizes(ddpi);
{ {
VkCommandBuffer commandBuffer = GetVkCommandBuffer(); VkCommandBuffer commandBuffer = GetVkCommandBuffer();
ImGui_ImplVulkan_CreateFontsTexture(commandBuffer); ImGui_ImplVulkan_CreateFontsTexture(commandBuffer);