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

UIScale by rendering to offscreen texture in SDL2? #6511

Open
dacobi opened this issue Jun 12, 2023 · 2 comments
Open

UIScale by rendering to offscreen texture in SDL2? #6511

dacobi opened this issue Jun 12, 2023 · 2 comments
Labels

Comments

@dacobi
Copy link

dacobi commented Jun 12, 2023

This isn't really an issue, but more of a question.

I've been wanting to implement UI scaling in my app for High DPI monitors and I thought the simplest approach would be to just render the entire program to an offscreen render texture and then scale that.

I've been looking at ScaleAllSizes/FontsGlobalScale/ScaleWindowsInViewport but can't get anything to work.

The problem seems to be that no matter what I do there's problems with ImGui and mouse cursor pos/window pos's/sizes, when the offscreen render texture has a different size than the window.

So my question is simply if this is at all possible?
Or if I should just bite the bullet and scale everything manually.

I'm sorry if this is not the correct place to ask.

@ocornut ocornut added the dpi label Jun 12, 2023
@ocornut
Copy link
Owner

ocornut commented Jun 12, 2023

There are dozens of same issue tagged with dpi.
I don’t have time to answer again, I’ll work on adjusting examples and perhaps backends to make this easier. But there are many answers scattered around.

MacOS is a little trickier, and multi-monitor with varying dpI + multi-viewports trickier too.

@dacobi
Copy link
Author

dacobi commented Jun 12, 2023

I know you've answered this many times, but I just wanted to ask if there's a correct way to set up UI scale where the mouse cursor pos is scaled?

Right now I have something working using SDL_RenderSetScale, but I had to apply this fix #6065

And then manually scale the output from ImGui::GetMainViewport()->GetCenter();

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

No branches or pull requests

2 participants