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

Issues on Catalina with High DPI (retina) #201

Open
NODESPLIT opened this issue Aug 21, 2020 · 7 comments
Open

Issues on Catalina with High DPI (retina) #201

NODESPLIT opened this issue Aug 21, 2020 · 7 comments

Comments

@NODESPLIT
Copy link

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.

@albertvaka
Copy link
Contributor

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

@NODESPLIT
Copy link
Author

@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.

@grimfang4
Copy link
Owner

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

@NODESPLIT
Copy link
Author

@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?

@grimfang4
Copy link
Owner

grimfang4 commented Sep 1, 2020

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.

@NODESPLIT
Copy link
Author

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
Copy link
Author

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.

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

3 participants