Skip to content

Commit

Permalink
fix(tesseratos): fix scale of cursor's coordinates in retina displays
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomsmiranda committed Feb 22, 2024
1 parent 58ff340 commit d96f059
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engine/src/imgui/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ void cubos::engine::imguiBeginFrame()
auto* bd = (ImGuiData*)io.BackendPlatformUserData;
io.DisplaySize.x = static_cast<float>(bd->window->framebufferSize().x);
io.DisplaySize.y = static_cast<float>(bd->window->framebufferSize().y);
// TODO: handle framebuffer scale
io.DisplayFramebufferScale.x = io.DisplaySize.x / static_cast<float>(bd->window->size().x);
io.DisplayFramebufferScale.y = io.DisplaySize.y / static_cast<float>(bd->window->size().y);

Check warning on line 381 in engine/src/imgui/imgui.cpp

View check run for this annotation

Codecov / codecov/patch

engine/src/imgui/imgui.cpp#L380-L381

Added lines #L380 - L381 were not covered by tests

// Setup time step.
double time = bd->window->time();
Expand Down Expand Up @@ -534,7 +535,8 @@ void cubos::engine::imguiEndFrame(const gl::Framebuffer& target)
static bool handle(const io::MouseMoveEvent& event)
{
ImGuiIO& io = ImGui::GetIO();
io.MousePos = ImVec2(static_cast<float>(event.position.x), static_cast<float>(event.position.y));
io.MousePos = ImVec2(static_cast<float>(event.position.x) * io.DisplayFramebufferScale.x,
static_cast<float>(event.position.y) * io.DisplayFramebufferScale.y);

Check warning on line 539 in engine/src/imgui/imgui.cpp

View check run for this annotation

Codecov / codecov/patch

engine/src/imgui/imgui.cpp#L538-L539

Added lines #L538 - L539 were not covered by tests
return io.WantCaptureMouse;
}

Expand Down

0 comments on commit d96f059

Please sign in to comment.