Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix high DPI issue on macOS #1648

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/driver/src/VideoDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ VideoDriver::VideoDriver(VideoDriverLoaderInterface* CallBack)

Position VideoDriver::GetMousePos() const
{
return mouse_xy.pos;
return mouse_xy.pos * (int)dpiScale_;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions libs/s25main/drivers/VideoDriverWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,19 @@
if(!videodriver->IsOpenGL() || !renderer_)
return;

const Extent renderSize = videodriver->GetRenderSize();
const Extent renderSize = getGuiScale().viewToScreen<Extent>(videodriver->GetRenderSize());

Check warning on line 308 in libs/s25main/drivers/VideoDriverWrapper.cpp

View check run for this annotation

Codecov / codecov/patch

libs/s25main/drivers/VideoDriverWrapper.cpp#L308

Added line #L308 was not covered by tests
const VideoMode windowSize = videodriver->GetWindowSize();

// Set the viewport and scissor area to the entire window
glViewport(0, 0, windowSize.width, windowSize.height);
glScissor(0, 0, windowSize.width, windowSize.height);
glViewport(0, 0, renderSize.x, renderSize.y);
glScissor(0, 0, renderSize.x, renderSize.y);

Check warning on line 313 in libs/s25main/drivers/VideoDriverWrapper.cpp

View check run for this annotation

Codecov / codecov/patch

libs/s25main/drivers/VideoDriverWrapper.cpp#L312-L313

Added lines #L312 - L313 were not covered by tests

// Orthogonale Matrix erstellen
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// 0,0 should be top left corner
glOrtho(0, renderSize.x, renderSize.y, 0, -100, 100);
glOrtho(0, windowSize.width, windowSize.height, 0, -100, 100);

Check warning on line 320 in libs/s25main/drivers/VideoDriverWrapper.cpp

View check run for this annotation

Codecov / codecov/patch

libs/s25main/drivers/VideoDriverWrapper.cpp#L320

Added line #L320 was not covered by tests

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Expand Down
Loading