mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 19:29:58 +01:00
Bugfix highDPI screen for Project function and UserInterfaceManager
This commit is contained in:
@@ -323,9 +323,13 @@ glm::vec3 Rendering::unProject(glm::vec2 screen_coordinate, glm::mat4 modelview)
|
||||
}
|
||||
|
||||
|
||||
glm::vec2 Rendering::project(glm::vec3 scene_coordinate, glm::mat4 modelview)
|
||||
glm::vec2 Rendering::project(glm::vec3 scene_coordinate, glm::mat4 modelview, bool to_framebuffer)
|
||||
{
|
||||
glm::vec4 viewport = glm::vec4( 0.f, 0.f, main_.width() / main_.dpiScale(), main_.height() / main_.dpiScale());
|
||||
glm::vec4 viewport;
|
||||
if (to_framebuffer)
|
||||
viewport= glm::vec4( 0.f, 0.f, main_.width(), main_.height());
|
||||
else
|
||||
viewport= glm::vec4( 0.f, 0.f, main_.width() / main_.dpiScale(), main_.height() / main_.dpiScale());
|
||||
glm::vec3 P = glm::project( scene_coordinate, modelview, Projection(), viewport );
|
||||
|
||||
return glm::vec2(P.x, viewport.w - P.y);
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
// unproject from window coordinate to scene
|
||||
glm::vec3 unProject(glm::vec2 screen_coordinate, glm::mat4 modelview = glm::mat4(1.f));
|
||||
// project from scene coordinate to window
|
||||
glm::vec2 project(glm::vec3 scene_coordinate, glm::mat4 modelview = glm::mat4(1.f));
|
||||
glm::vec2 project(glm::vec3 scene_coordinate, glm::mat4 modelview = glm::mat4(1.f), bool to_framebuffer = true);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ void UserInterface::handleMouse()
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
glm::vec2 mousepos(io.MousePos.x * io.DisplayFramebufferScale.y, io.MousePos.y* io.DisplayFramebufferScale.x);
|
||||
mousepos = glm::clamp(mousepos, glm::vec2(0.f), glm::vec2(io.DisplaySize.x, io.DisplaySize.y));
|
||||
mousepos = glm::clamp(mousepos, glm::vec2(0.f), glm::vec2(io.DisplaySize.x * io.DisplayFramebufferScale.x, io.DisplaySize.y * io.DisplayFramebufferScale.y));
|
||||
static glm::vec2 mouseclic[2];
|
||||
mouseclic[ImGuiMouseButton_Left] = glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Left].x * io.DisplayFramebufferScale.y, io.MouseClickedPos[ImGuiMouseButton_Left].y* io.DisplayFramebufferScale.x);
|
||||
mouseclic[ImGuiMouseButton_Right] = glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Right].x * io.DisplayFramebufferScale.y, io.MouseClickedPos[ImGuiMouseButton_Right].y* io.DisplayFramebufferScale.x);
|
||||
|
||||
2
View.cpp
2
View.cpp
@@ -970,7 +970,7 @@ void TransitionView::draw()
|
||||
scene.accept(dv2);
|
||||
|
||||
// display interface duration
|
||||
glm::vec2 P = Rendering::manager().project(glm::vec3(-0.03f, -0.14f, 0.f), scene.root()->transform_);
|
||||
glm::vec2 P = Rendering::manager().project(glm::vec3(-0.03f, -0.14f, 0.f), scene.root()->transform_, false);
|
||||
ImGui::SetNextWindowPos(ImVec2(P.x, P.y), ImGuiCond_Always);
|
||||
if (ImGui::Begin("##Transition", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBackground
|
||||
| ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings
|
||||
|
||||
Reference in New Issue
Block a user