mirror of
https://github.com/brunoherbelin/vimix.git
synced 2026-06-16 04:27:23 +02:00
Fixed resolution issue with different monitor DPI.
This commit is contained in:
+19
-2
@@ -503,6 +503,8 @@ GLFWmonitor *RenderingWindow::monitor()
|
||||
int x, y;
|
||||
glfwGetWindowPos(window_, &x, &y);
|
||||
|
||||
Log::Info("testing window monitor at %d %d", x, y );
|
||||
|
||||
return monitorAt(x, y);
|
||||
}
|
||||
|
||||
@@ -554,9 +556,18 @@ int RenderingWindow::height()
|
||||
return window_attributes_.viewport.y;
|
||||
}
|
||||
|
||||
int RenderingWindow::maxHeight()
|
||||
int RenderingWindow::pixelsforRealHeight(float milimeters)
|
||||
{
|
||||
return static_cast<int>( static_cast<float>(glfwGetVideoMode(monitor())->height) * dpi_scale_);
|
||||
GLFWmonitor *mo = monitor();
|
||||
|
||||
int mm_w = 0;
|
||||
int mm_h = 0;
|
||||
glfwGetMonitorPhysicalSize(mo, &mm_w, &mm_h);
|
||||
|
||||
float pixels = milimeters * static_cast<float>(glfwGetVideoMode(mo)->height) / static_cast<float>(mm_h);
|
||||
pixels *= dpi_scale_;
|
||||
|
||||
return static_cast<int>( pixels );
|
||||
}
|
||||
|
||||
float RenderingWindow::aspectRatio()
|
||||
@@ -583,10 +594,14 @@ bool RenderingWindow::init(int id, GLFWwindow *share)
|
||||
Log::Error("Failed to create GLFW Window %d", id_);
|
||||
return false;
|
||||
}
|
||||
Log::Info("Window size %d %d", winset.w, winset.h);
|
||||
|
||||
|
||||
// set position
|
||||
glfwSetWindowPos(window_, winset.x, winset.y);
|
||||
|
||||
Log::Info("Window position %d %d", winset.x, winset.y);
|
||||
|
||||
/// CALLBACKS
|
||||
// store global ref to pointers (used by callbacks)
|
||||
GLFW_window_[window_] = this;
|
||||
@@ -616,6 +631,8 @@ bool RenderingWindow::init(int id, GLFWwindow *share)
|
||||
// DPI scaling (retina)
|
||||
dpi_scale_ = float(window_attributes_.viewport.y) / float(winset.h);
|
||||
|
||||
Log::Info("Window Frame Buffer sixe %d %d", window_attributes_.viewport.x, window_attributes_.viewport.y);
|
||||
|
||||
// This hint can improve the speed of texturing when perspective-correct texture coordinate interpolation isn't needed
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
//
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ public:
|
||||
int height();
|
||||
// get aspect ratio of rendering area
|
||||
float aspectRatio();
|
||||
// get total height available in monitor
|
||||
int maxHeight();
|
||||
// get number of pixels to render X milimeters in height
|
||||
int pixelsforRealHeight(float milimeters);
|
||||
|
||||
inline float dpiScale() const { return dpi_scale_; }
|
||||
|
||||
|
||||
+26
-20
@@ -178,7 +178,7 @@ bool UserInterface::Init()
|
||||
ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color));
|
||||
|
||||
// Estalish the base size from the resolution of the monitor
|
||||
float base_font_size = float(Rendering::manager().mainWindow().maxHeight()) / 100.f ;
|
||||
float base_font_size = float(Rendering::manager().mainWindow().pixelsforRealHeight(4.f)) ;
|
||||
// Load Fonts (using resource manager, NB: a temporary copy of the raw data is necessary)
|
||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_DEFAULT, "Roboto-Regular", int(base_font_size) );
|
||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_BOLD, "Roboto-Bold", int(base_font_size) );
|
||||
@@ -2336,27 +2336,33 @@ void Navigator::RenderMainPannel()
|
||||
if (b || o || g)
|
||||
ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color));
|
||||
|
||||
// Bottom aligned Logo & About
|
||||
static unsigned int vimixicon = Resource::getTextureImage("images/vimix_256x256.png");
|
||||
static float h = 4.f * ImGui::GetTextLineHeightWithSpacing();
|
||||
if ( ImGui::GetCursorPosY() + h + 128.f < height_ ) {
|
||||
ImGui::SetCursorPos(ImVec2(pannel_width_ / 2.f - 64.f, height_ -h - 128.f));
|
||||
ImGui::Image((void*)(intptr_t)vimixicon, ImVec2(128, 128));
|
||||
static float height_about = 3.f * ImGui::GetTextLineHeightWithSpacing();
|
||||
bool show_icon = ImGui::GetCursorPosY() + height_about + 128.f < height_ ;
|
||||
bool show_about = ImGui::GetCursorPosY() + height_about < height_ ;
|
||||
|
||||
// Bottom aligned About buttons
|
||||
if ( show_about) {
|
||||
// Bottom aligned Logo
|
||||
if ( show_icon ) {
|
||||
ImGui::SetCursorPos(ImVec2(pannel_width_ / 2.f - 64.f, height_ -height_about - 128.f));
|
||||
ImGui::Image((void*)(intptr_t)vimixicon, ImVec2(128, 128));
|
||||
}
|
||||
else {
|
||||
ImGui::SetCursorPosY(height_ -height_about);
|
||||
}
|
||||
ImGui::Spacing();
|
||||
if ( ImGui::Button( ICON_FA_CROW " vimix", ImVec2(ImGui::GetContentRegionAvail().x, 0)) )
|
||||
UserInterface::manager().show_vimix_config = true;
|
||||
if ( ImGui::Button(" ImGui "))
|
||||
UserInterface::manager().show_imgui_about = true;
|
||||
ImGui::SameLine();
|
||||
if ( ImGui::Button(" GStreamer "))
|
||||
UserInterface::manager().show_gst_about = true;
|
||||
ImGui::SameLine();
|
||||
if ( ImGui::Button("OpenGL", ImVec2(ImGui::GetContentRegionAvail().x, 0)))
|
||||
UserInterface::manager().show_opengl_about = true;
|
||||
}
|
||||
else {
|
||||
ImGui::SetCursorPosY(height_ -h);
|
||||
}
|
||||
ImGui::Spacing();
|
||||
if ( ImGui::Button( ICON_FA_CROW " vimix", ImVec2(ImGui::GetContentRegionAvail().x, 0)) )
|
||||
UserInterface::manager().show_vimix_config = true;
|
||||
if ( ImGui::Button(" ImGui "))
|
||||
UserInterface::manager().show_imgui_about = true;
|
||||
ImGui::SameLine();
|
||||
if ( ImGui::Button(" GStreamer "))
|
||||
UserInterface::manager().show_gst_about = true;
|
||||
ImGui::SameLine();
|
||||
if ( ImGui::Button("OpenGL", ImVec2(ImGui::GetContentRegionAvail().x, 0)))
|
||||
UserInterface::manager().show_opengl_about = true;
|
||||
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
Reference in New Issue
Block a user