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

Constrain window aspect ratio in SDL version #1264

Open
ryandesign opened this issue Dec 11, 2023 · 1 comment
Open

Constrain window aspect ratio in SDL version #1264

ryandesign opened this issue Dec 11, 2023 · 1 comment

Comments

@ryandesign
Copy link
Contributor

I've built the SDL/OpenGL version of CLK on macOS for comparison with the usual Cocoa/Metal version, and I've noticed that the Cocoa/Metal version ensures the window's aspect ratio stays the same when it is resized. This constraint should be added to the SDL/OpenGL version, because currently it is possible to resize the SDL/OpenGL version's window so that it is either too wide (black bars appear on the left and right of the emulated screen) or too narrow (the left and right of the emulated screen are cut off).

This problem occurs with frustrating regularity because I frequently use Rectangle to put my text editor window on the left half of the screen and the CLK window on the right half of the screen. What I want when I do this is for the CLK window to take up half the width of the screen and however much of the height as would befit the correct aspect ratio, and that is what happens with the Cocoa/Metal version, but with the SDL/OpenGL version, it takes up the full height so emulated screen content is cut off so it's not usable and I have to adjust the window height manually every single time I launch it.

@ryandesign
Copy link
Contributor Author

Frustratingly SDL doesn't have the ability to constrain a window's aspect ratio yet despite a patch being provided nine years ago:

libsdl-org/SDL#1573

In the absence of this feature, someone suggested that it could be implemented with various platform-specific code, providing an example of how to do it on macOS:

https://stackoverflow.com/questions/28587643/sdl2-how-to-keep-aspect-ratio-when-resizing-the-window#answer-58499572

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

1 participant