mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Calculate HighDPI scaling ourselves for UserInterface init.
This commit is contained in:
@@ -64,6 +64,7 @@ Rendering::Rendering()
|
||||
{
|
||||
main_window_ = nullptr;
|
||||
request_screenshot_ = false;
|
||||
dpi_scale_ = 1.f;
|
||||
}
|
||||
|
||||
bool Rendering::Init()
|
||||
@@ -128,6 +129,9 @@ bool Rendering::Init()
|
||||
glViewport(0, 0, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
|
||||
main_window_attributes_.clear_color = glm::vec4(COLOR_BGROUND, 1.0);
|
||||
|
||||
// DPI scaling (retina)
|
||||
dpi_scale_ = float(main_window_attributes_.viewport.y) / float(winset.h);
|
||||
|
||||
// Gstreamer link to context
|
||||
g_setenv ("GST_GL_API", "opengl3", FALSE);
|
||||
gst_init (NULL, NULL);
|
||||
|
||||
@@ -24,6 +24,7 @@ class Rendering
|
||||
// GLFW integration in OS window management
|
||||
class GLFWwindow* main_window_;
|
||||
std::string glsl_version;
|
||||
float dpi_scale_;
|
||||
|
||||
// Private Constructor
|
||||
Rendering();
|
||||
@@ -86,6 +87,7 @@ public:
|
||||
|
||||
float MonitorWidth();
|
||||
float MonitorHeight();
|
||||
inline float DPIScale() const { return dpi_scale_; }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -149,13 +149,12 @@ bool UserInterface::Init()
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplGlfw_InitForOpenGL(Rendering::manager().main_window_, true);
|
||||
ImGui_ImplOpenGL3_Init(Rendering::manager().glsl_version.c_str());
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
// Setup Dear ImGui style
|
||||
ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color));
|
||||
|
||||
// Load Fonts (using resource manager, NB: a temporary copy of the raw data is necessary)
|
||||
float base_font_size = (Rendering::manager().MonitorHeight() * ImGui::GetIO().DisplayFramebufferScale.y) / 100.f ;
|
||||
float base_font_size = (Rendering::manager().MonitorHeight() * Rendering::manager().DPIScale()) / 100.f ;
|
||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_DEFAULT, "Roboto-Regular", int(base_font_size) );
|
||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_BOLD, "Roboto-Bold", int(base_font_size) );
|
||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_ITALIC, "Roboto-Italic", int(base_font_size) );
|
||||
@@ -165,8 +164,8 @@ bool UserInterface::Init()
|
||||
|
||||
// info
|
||||
Log::Info("Monitor (%.1f,%.1f)", Rendering::manager().MonitorWidth(), Rendering::manager().MonitorHeight());
|
||||
Log::Info("DPI Scale (%.1f,%.1f)", ImGui::GetIO().DisplayFramebufferScale.x, ImGui::GetIO().DisplayFramebufferScale.y);
|
||||
Log::Info("Font size %d", base_font_size);
|
||||
Log::Info("DPI Scale %.1f", Rendering::manager().DPIScale());
|
||||
Log::Info("Font size %.1f", base_font_size);
|
||||
|
||||
// Style
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
Reference in New Issue
Block a user