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

[Windows 11/SDL_Render] Pixel are wrong in FULLSCREEN only on High-DPI screen when hint SDL_WINDOWS_DPI_AWARENESS is set #12229

Open
l-t-m-f opened this issue Feb 9, 2025 · 4 comments

Comments

@l-t-m-f
Copy link
Contributor

l-t-m-f commented Feb 9, 2025

Hello guys,

I'm going to post an example later but I noticed on all my projects with the SDL_Render API, if I toggled full screen, the pixels are looking weird and smaller than they should on high-DPI screen. I am noticing this on a new laptop with a 3840x2400 screen which needs to run applications are 200% scaling otherwise everything is microscopic.

I hadn't noticed before because I'm working on a game where the pixel art is very small and thus it was merely making it "fuzzy" (like if there were a bi-linear filter over everything). However, I was working on a new project tonight with a basic 1-bit style, and it became particularly egregious.

I would post a screenshot, but the weirdest thing happens... When I take the screenshot, the pixels in the image are back to normal.

Let me know if I can provide more info while in the meantime I prepare some example.

Also, I noticed that the hint for SDL_Render "SDL_WINDOWS_DPI_AWARENESS" isn't needed now?
I remember having to use it before on this display. I toggled it on or off and see no difference in the main branch.

@l-t-m-f
Copy link
Contributor Author

l-t-m-f commented Feb 9, 2025

Ok, I figured out the problem while coding the minimal reproduce. I had DPI awareness On when it should have been/and I thought it were set to Off. The reason is bellow...

Both the following set the hint to true, is this intended?
SDL_SetHint ("SDL_WINDOWS_DPI_AWARENESS", "0");
SDL_SetHint ("SDL_WINDOWS_DPI_AWARENESS", "1");

I was doing something like this in my framework:
if (params->b_is_DPI_aware == false)
{
SDL_SetHint ("SDL_WINDOWS_DPI_AWARENESS", "0");
}
else
{
SDL_SetHint ("SDL_WINDOWS_DPI_AWARENESS", "1");
}

I just won't call the hint at all now on the false case.

I noticed that if the hint is on and fullscreen is toggled on, pixel will be distorted. Therefore I think there is still an issue with the hint when fullscreen is active, which is why I keep this issue open for now.

@l-t-m-f l-t-m-f changed the title [Windows 11] Pixel are wrong in FULLSCREEN only on High-DPI screen (200% scaled) [Windows 11/SDL_Render] Pixel are wrong in FULLSCREEN only on High-DPI screen when hint SDL_WINDOWS_DPI_AWARENESS is set Feb 9, 2025
@l-t-m-f
Copy link
Contributor Author

l-t-m-f commented Feb 9, 2025

I made a search in the history of the commits around that hint but failed to see anything significant.
So I made an example if you want to test the problem: https://pastecode.io/s/5v010ixg
It uses the following art:

Image

Disable the line SDL_SetRenderLogicalPresentation(r, 480, 480, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE); and the problem will appear different.

Which makes the problem very stark and apparent on my end.
If you want to try on a High DPI display on Windows 11.

@slime73
Copy link
Contributor

slime73 commented Feb 9, 2025

Which version of SDL are you using?

@l-t-m-f
Copy link
Contributor Author

l-t-m-f commented Feb 9, 2025

I'm using the project's main. I tried checking out a few commit backs and saw no difference.

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

No branches or pull requests

2 participants