Open inhahe opened 23 hours ago
So this bug only occurs with SDL_WINDOW_ALLOW_HIGHDPI
?
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: https://github.com/emscripten-ports/SDL2/issues/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 https://github.com/emscripten-ports/SDL2/issues/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?
Looking at this more closely, it seems that the framebuffer is correctly sized now and switching width
/height
for context->surface->w
/->h
in the loop fills the entire canvas.
(That ended up at the correct scale (1.5x) but goes through a 2x scale in the middle because devicePixelRatio
is 2 for some reason. That seems like a browser thing outside of SDL's control though...)
@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) But this is a great find, I should have realized it.
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: