sdl-gpu icon indicating copy to clipboard operation
sdl-gpu copied to clipboard

Issues on Catalina with High DPI (retina)

Open NODESPLIT opened this issue 4 years ago • 7 comments

Hey there, I'm having some issues getting high dpi to work using SDL_WINDOW_ALLOW_HIGHDPI and GPU_SetVirtualResolution. I might just be missing something as I can't find an example of this.

Do I need to manually scale all my geometry by the pixel density after setting the virtual resolution to double the window size / the drawable size? As this is the only way I can get the right pixel density but it feels wrong.

Thanks for the great library and apologies if this is just me getting it wrong.

NODESPLIT avatar Aug 21 '20 21:08 NODESPLIT

Note that, as per SDL's docs [1], SDL_WINDOW_ALLOW_HIGHDPI by itself is not enough on MacOS:

On Apple's OS X you must set the NSHighResolutionCapable Info.plist property to YES, otherwise you will not receive a High DPI OpenGL canvas.

[1] https://wiki.libsdl.org/SDL_WindowFlags

albertvaka avatar Aug 24 '20 09:08 albertvaka

@albertvaka That's interesting because I definitely can achieve a high DPI window without fitting the binary into an app package, it's just that I have to scale all my coordinates and sizes to achieve a normal render with just extra depth.

I'm just wondering if that's how I have to do it or if the virtual coordinates system should handle that stuff? I'm a little lost as I can't find any examples or tutorials on it.

NODESPLIT avatar Aug 25 '20 11:08 NODESPLIT

I'm not up-to-date on it myself, since my test Mac is too old now.

grimfang4 avatar Aug 25 '20 13:08 grimfang4

@grimfang4 I can take a look into it myself when I get some time, is what I said about virtual resolution true though? Is the scaling done automatically?

NODESPLIT avatar Sep 01 '20 12:09 NODESPLIT

You're supposed to be able to pretend that the virtual resolution you set is the resolution you're rendering to. For example, if I use a physical resolution of 1920x1080 and a virtual (logical) resolution of 800x600, drawing a 100x100 image at (800, 600) should stretch my image to make it appear larger and draw it at the lower right corner.

The intention with the high DPI settings is to make it seamless and you shouldn't have to care about what the actual resolution is. The real, "retina" resolution should be reported as the "physical" dimensions of the window.

grimfang4 avatar Sep 01 '20 13:09 grimfang4

Hey sorry for the late reply. okay I figured it was supposed to be seamless. Do I need to set SDL_WINDOW_ALLOW_HIGHDPI on the window to achieve this?

The way I've set up composition in my engine might be confusing things for me, but I'm pretty sure I've tried every angle with the window init to get it to render an image with the virtual coords over the real ones but they always end up rendering in the bottom left corner without scaling to fit to the virtual resolution.

I'll try to get some time to do a deep dive into it at some point soon, It's not on the top of my priorities for this engine right now, but it's on there.

NODESPLIT avatar Jan 31 '21 21:01 NODESPLIT

Do I need to set the virtual resolution myself on window resize? That's half of what I'm doing now. Talking this out now I think my composition setup needs tweaking and that's about it but I'll get back to you on that.

NODESPLIT avatar Jan 31 '21 21:01 NODESPLIT