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

Add ability to disable scaling #2457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

manio
Copy link

@manio manio commented Dec 31, 2023

Currently wayland displays can have some scalling applied (it is widely used with HiDPI displays).
It is then handled via a viewporter or fractional-scale protocols.
However it is sometimes desirable to explicitly disable scaling for some GLFW application to have a clear and perfect 1:1 pixel window content (ie. no scaling applied).

This PR adds such a possiblity.
To use it one can eg. set/export a variable like this:
export GLFW_SCALE_TO_MONITOR=1
and then start the application.

Currently wayland displays can have some scalling applied (it is widely
used with HiDPI displays). It is then handled via a `viewporter` or
`fractional-scale` protocols.
However it is sometimes desirable to explicitly disable scaling for some
GLFW application to have a clear and perfect 1:1 pixel window content
(ie. no scaling applied).

This commit adds such a possiblity.
To use it one can eg. set/export a variable like this:
export GLFW_SCALE_TO_MONITOR=1
and then start the application.
@elmindreda elmindreda changed the title Wayland: add possibility to disable scaling Add ability to disable scaling Jan 4, 2024
@elmindreda elmindreda added enhancement Feature suggestions and PRs Wayland labels Jan 4, 2024
@elmindreda
Copy link
Member

With a9cc7c7 there is now the GLFW_SCALE_FRAMEBUFFER window hint that lets you control this scaling per-window on Wayland. Is that sufficient for your needs?

@elmindreda elmindreda added the waiting for reply Issues blocked waiting for information label Feb 15, 2024
@manio
Copy link
Author

manio commented Feb 16, 2024

I'll try to test this ASAP...

@manio
Copy link
Author

manio commented Feb 16, 2024

@elmindreda
Please tell me if I did the change properly:
manio/SDRPlusPlus@599b3d6

I built master branch of glfw and the above application with the above change included but unfortunately it is still ugly/upscaled, while with this PR it is working fine (without scaling).

@elmindreda
Copy link
Member

elmindreda commented Feb 17, 2024

However it is sometimes desirable to explicitly disable scaling for some GLFW application to have a clear and perfect 1:1 pixel window content (ie. no scaling applied).

I think this is the issue.

You seem to be referring to the scaling the compositor performs on the window, over which we have no control.

The GLFW_SCALE_FRAMEBUFFER hint refers to GLFW scaling the framebuffer relative to the window size, so that the window contents (typically) maps 1:1 to output pixels again even if window sizes no longer do.

I think you want to set the hint to true.

@manio
Copy link
Author

manio commented Feb 18, 2024

I tested with GLFW_SCALE_FRAMEBUFFER set to true and false now:
true: https://skyboo.net/temp/glfw/SCALE_FRAMEBUFFER_TRUE.png
false: https://skyboo.net/temp/glfw/SCALE_FRAMEBUFFER_FALSE.png

But this PR is doing something different, which I'd like to have. Disable UI scaling completely. Please take a look how it looks: https://skyboo.net/temp/glfw/SCALE_TO_MONITOR.png
This way the whole UI is not scaled (I can see more details on the screen), and this is done with the changes in this PR.

In fact this scaling is applied only when this env variable is set, so it doesn't affect any user, only those who are aware of this feature... so maybe you're willing to merge this?

@elmindreda elmindreda self-assigned this Feb 18, 2024
@elmindreda elmindreda removed enhancement Feature suggestions and PRs waiting for reply Issues blocked waiting for information labels Feb 18, 2024
@elmindreda
Copy link
Member

This PR essentially adds an option that switches the behaviors of glfwGetWindowSize and glfwGetFramebufferSize. It's not changing the actual size of the window or framebuffer, just what values are retrieved via these functions.

If the changes in this PR makes your program draw correctly, then it is likely using the wrong one of these functions somewhere.

@manio
Copy link
Author

manio commented Feb 18, 2024

@AlexandreRouma
Could you please comment on this? Are you able to adjust sdrpp scalling in the app itself instead of glfw ?

Setting the scale to 200% doesn't help to get the result as in my screenshot.

@AlexandreRouma
Copy link

SDR++ bases the scaling on glfwGetWindowSize()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants