-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Canvas is the wrong size for the graphics when writing directly to pixels and using a high DPI and using SDL_WINDOW_ALLOW_HIGHDPI #22944
Comments
So this bug only occurs with I would assume this is an SDL bug. @Daft-Freak WDYT? |
Also, is this a regression? (i.e. did it used to work in the past?) |
I think this is this old issue: emscripten-ports/SDL2#109. Specifically, the combination of framebuffer rendering and HiDPI, which when I looked at it back then was handled in other ports by... basically not doing HiDPI. |
@sbc100 I don't know of it ever working right in the past, but I haven't been using Emscripten for very long. @Daft-Freak I really want HighDPI to work, I dislike the automatic upscaling, at least for the project I'm doing now, which is my only Emscripten project. I would like to see the HighDPI flag work across the board (and correctly), not just with this particular rendering method.. :P (I noticed that any other rendering method just ignores AllowHighDPI..) |
I don't like the two workarounds that are suggested in emscripten-ports/SDL2#109, "As a workaround, you can use SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1"); before you call SDL_Init to force going through the renderer. EDIT: Hmm, since the framebuffer seems to always be non-HiDPI you could just disable HiDPI and use CSS image-rendering on the canvas to control the scaling..." The first one would just have the effect of ignoring allowhighdpi, if I understand correctly, since in my experience all the other rendering methods ignore allowhighdpi. And to the second one, I want a one-to-one pixel correspondence between the rendering and the monitor, and I don't know how to find out exactly how much I'd have to scale it to get that ratio, let alone in a 100% reliable way... |
Sorry to ask in the issue box, but I've been looking and asking everywhere and I can't seem to find answers: how can I write to the pixel data of the canvas without using SDL? |
@Daft-Freak Oh, that helps, but it's still kind of awkward because i wanted a 1000x1000 canvas, not an approximately 1500x1500 canvas. and if i just create my window 66% as large then it will be too small on monitors that don't have a high dpi.. (it'll be 666x666) |
Could you guys update GLFW support to at least version 3.3? I tried switching the program over to GLFW to have a 1-to-1 pixel correspondence, and it upscales the window too! But GPT-4 told me I could use |
Please include the following in your bug report:
Version of emscripten/emsdk:
3.1.71
Full link command and output with
-v
appended:I've made a minimal example that exhibits this behavior.
Ideally, the whole canvas should turn red.
But on a high-DPI screen, the canvas is about 1.5x the size of the graphics (the red square).
Changing the canvas size is CSS only shrinks the whole thing, with the red square still taking only a portion of the canvas.
The parts of the canvas not used show up in black.
Honestly, I'm not sure how this stuff works well enough to know whether this is an Emscripten bug or an SDL bug. But... I have a version of the same program for the desktop instead of the web, and it doesn't have this problem.
Here's a screenshot of how it looks on my display:
The text was updated successfully, but these errors were encountered: