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
Aspect ratio and viewport improvements #3124
Conversation
852a51c
to
0cb35ca
Compare
aspect
and viewport_resolution
modes to support advanced use cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly minor suggestions.
Lots of nice improvements in this, @johnnovak !
Thanks for the early review @kcgen , just checking that you're aware it's still a draft and work-in-progress? It's only about 70% finished yet. There's gonna be lots of force pushes and re-jigging things still, plus not everything in the top comment is implemented yet (and that comment is not finished either; there will be screenshots coming, etc.) |
0cb35ca
to
bca33de
Compare
Yup - might as well nip the easy stuff early. Was only commenting on superficial/rote things. |
Oh - wanted to mention this early on - it would be really slick to combine the Fraction class with |
50dfed5
to
41403b9
Compare
Cool idea, that's something to think about, although in its current iteration things will work a bit differently. You'll see when I'm done, then we can discuss again 👍🏻 Maybe it could be an additional enhancement, yeah, but I'll finish first what I had in mind 😄 |
57073b0
to
02d133e
Compare
Speaking as a normal user, this is an interesting addition but the |
Good to see you're thinking about possible simplifications and taking user friendliness into account @kcgen @Kappa971! To be absolutely crystal clear, I'd also like to make this as simple and intuitive as I can, so I gave your ideas very serious consideration, which means literally spending the last 3 hours (!) sketching out ideas on alternative config implementations based on your suggestions and trying out various things hacking the code. The TL;DR is, I've been going around in circles because the simplifications all break down in some scenarios and/or are unsupportable or rather meaningless. So I'm pretty sure I've hit a local maximum with my current solution that balances flexibility, simplicity, and ease of use. I just can't simplify it any further while catering for all current and foreseeable future needs, and the current solution is already a culmination of a week's thinking, carefully weighing of pros and cons of various possible solutions. This is already about my 4th or 5th iteration of the config options! Believe me, alternative solutions would make things a lot more complex. I've spent about 100+ hours dealing with aspect ratio-related things earlier this year dealing with the VGA code. One side effect of that work is the following huge aspect ratio table of various DOS video modes: I don't want to appear condescending and I'm absolutely saying this in a friendly, amicable manner: understanding how the various rendering options work together with aspect ratio stuff requires a bit of an expert knowledge — it's far more complex than just "yeah, stretch to 4:3 or 16:9", that's not even scratching the surface of understanding the implications and what we're trying to solve here. Just to enter a meaningful discussion about the issue I'm trying to solve, a deep understanding of the below points is required:
I could spend the whole day writing a dissertation about how some of the proposed simplifications would break various things (they are good ideas on the surface, but naive), but just a quick rundown:
I could go on... In the end:
Now, after a 4-hour detour, finishing the feature as I had planned 😎 |
Use the more descriptive Rect methods instead of direct coordinate manipulations.
This is in preparation for introducing additional viewport modes.
It was a bit of a mistake to include it as it's too specific, and currently it's unused anyway.
Error reporting is more accurate now and invalid input such as `80%blah` and `960x720asdf` isn't just silently accepted anymore.
`On` became `Auto` and `Off` became `SquarePixels`.
…er]` At a logical level, that's where it belongs, next to the `aspect` setting it's closely related to. Managing the viewport size has nothing to do with interfacing with the host OS, so it was a mistake to put it into the `[sdl]` section in the first place. Secondly, the name `viewport_resolution` was an unfortunate choice in this age of high-DPI displays as `WxH` settings are interpreted as logical units, and "resolution" implies physical resolution in pixels (as in "display resolution" of a monitor). Lastly, changing `viewport_resolution` triggered re-creating the window and resetting the window size in windowed mode, and flashing and/or delays in fullscreen. This is the current behaviour when changing *any* setting in the `[sdl]` section. While that issue should be addressed separately, moving `viewport_resolution` into `[render]` at least fixes the problem for this single setting only.
This further clarifies the rendering pipeline; the "clip rectangle" concept was actually what we call the "draw rectangle" already everywhere, so it only confused things
52c945b
to
0dab866
Compare
Description
Let's start with the release notes!
Aspect ratio and viewport improvements
Stretching the image to completely fill the screen has been an often requested feature (e.g., to play text adventures without black bars on the sides). Now we're giving you not only that but an entire new mechanism to apply arbitrary aspect ratios, zoom into the DOS content, and even emulate the horizontal and vertical stretch controls of CRT monitors of yore! 😎
The key element of the feature is the new
aspect = stretch
mode which stretches the image to the extents of the viewport. For example, to make a game completely fill the screen, use the following config:The second piece of the puzzle is the new
relative
mode added to theviewport
setting (viewport_resolution
has been renamed toviewport
and moved to the[render]
section). In relative mode, the viewport is a 4:3 aspect ratio rectangle fit into the window or screen as the starting point, which is then scaled by the specified horizontal and vertical stretch factors. The resulting viewport is allowed to extend beyond the edges of the window or the screen, so this can be used to "zoom" into the image while forcing arbitrary aspect ratios.For example, you can aspect ratio correct lazy Hercules conversions that just reused the EGA/VGA assets and make them fill the screen better by zooming in a little. The following example illustrates this on Prince of Persia in Hercules mode:
Captions:
aspect = stretch
andviewport = relative 110% 160%
You can also use the "Strech Axis", "Inc Stretch", and "Dec Stretch" hotkey actions (unbinded by default) to adjust the horizontal and vertical stretch factors in real-time, just like on a real CRT monitor. The current viewport settings are logged, so you can simply copy them into your config.
Note that using 'relative' mode with 'integer_scaling' enabled could lead to surprising (but correct) results. It is recommended to disable integer scaling while you're still getting to grips with 'relative' mode.
Technical notes
This PR extends the
aspect
andviewport
settings to allow for the below advanced use cases:Stretch DOS content to fullscreen to get rid of the left & right black bars on 16:9 flat panels (requested here, by a guy on Discord who had a medical reason for this as the black bars caused him discomfort, and by a couple of people on various forums)
"Zoom into" the DOS content while keeping the correct aspect ratio (requested here)
Apply arbitrary aspect ratios manually (the "anything goes" option—might be handy in some rare situations as this effetively emulates the vsync/hsync controls on a CRT monitor; this was requested for some pinball games here)
Apply arbitrary aspect ratios and "zoom into" the DOS content at the same time (the previous two features combined; on a real CRT, you could enlarge the image so much with the horiz/vert size controls that parts of the image got cut off. This is useful for Hercules games that simply reuse the 320x200 assets in the 720x348 Hercules graphics mode; these games appear overly squashed with authentic Hercules emulation and the graphics don't fill the screen horizontally either (more info))
I wasn't a fan of such requests initially because I thought they would complicate things too much and it would be too hard or even impossible to make them work consistently and logically with our existing features, but I found a way to add support for them cleanly with a minimum set of extra options. These enhancements/changes are:
Changes
Please see the commit messages for the detailed list of changes & further details and justifications, but here are the main things:
aspect
setting: introduceauto
andsquare-pixels
aliases foron
andoff
, respectivelyviewport_resolution
: rename toviewport
and move it torender
aspect
stretch mode (as per above)relative
mode to theviewport
setting (as per above)Related issues
A completely full-screen or filled screen option
#1474
Can I enlarge the screen content from the centre?
#2958
Graphical issues with some Pinball games
#1578
Manual testing
aspect
andviewport
settings.aspect
andviewport
combinations when set from the config, and at runtime in windowed mode (also while resizing the window—this is important!) and in fullscreen. Tested bothopengl
andtexture
output modes.Future work
viewport = relative text 100% 100% graphics 110% 160%
aspect
mode calledauto-and-stretch
that uses the result of theaspect = auto
mode for the further horiz/vert stretching (which is based on VGA timings, not just simply using a 4:3 rectangle as starting point as the currentrelative
mode does).Checklist
Please tick the items as you have addressed them. Don't remove items; leave the ones that are not applicable unchecked.
I have: