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

Request for ability to get display scaling properties from a window #202

Closed
john01dav opened this issue Aug 10, 2020 · 4 comments
Closed

Comments

@john01dav
Copy link
Contributor

It would be very useful to be able to get a display scaling factor for a window, in order to render what is inside it at an appropriate size. Otherwise, when things are rendered on, for example, a 4K display, then they may be quite inappropriately small. I'd imagine that this is as simple as adding a function that wraps a different native function for each platform to return this factor, maybe with some trivial formula to scale it to a common format (e.g. 2.0 vs 200, to represent 200% scaling), although I don't know anything about the native APIs that minifb wraps, so this may be wrong.

@emoon
Copy link
Owner

emoon commented Aug 10, 2020

What you can do is to use this

https://github.com/emoon/rust_minifb/blob/master/src/lib.rs#L18 and pass it as something like this

        WindowOptions {
            scale: Scale::FitScreen,
            ..WindowOptions::default()
        },

So now if you have a 320x200 window on a 4k screen it will resize the window to fit your desktop resolution (but the render area if your window will be still 320x200)

Is that what your are looking for?

@john01dav
Copy link
Contributor Author

john01dav commented Aug 11, 2020

That feature isn't quite what I'm looking for, as I prefer the ability to render the contents of my window at a higher resolution as appropriate in my own code as it has access to a vector graphics representation of the contents, rather than letting minifb do a raster resize, which can only produce inferior results. I just need an API hook like this function from winit (+ a way to know when it changes, ideally but not necessarily, whether that means polling it each frame, or an event). I can't use winit however, as its architecture is not what I need — I need something that enables 100% software rendering, without the involvement of a GPU. I've looked into the Windows and Linux APIs a bit (this winit documentation has a surprising amount of detail on this), and it looks like it wouldn't be too hard to implement this, so I may be able to do a pull request for the Linux and Windows implementations, but I don't have access to an Apple computer to test on.

@emoon
Copy link
Owner

emoon commented Aug 11, 2020

I see. Doing the PR for Linux and Windows would be fine. I can add the macOS support as I don't think it would be much work as you say.

@emoon
Copy link
Owner

emoon commented Feb 19, 2021

Being tracked in #236

@emoon emoon closed this as completed Feb 19, 2021
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

2 participants