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