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

sf::VideoMode::getDesktopMode() returning the monitor resolution on macOS #2906

Open
3 tasks done
alihakankurt opened this issue Feb 15, 2024 · 2 comments
Open
3 tasks done

Comments

@alihakankurt
Copy link

Prerequisite Checklist

Describe your issue here

My monitor resolution is 3420x2224 and my screen resolution is set to 1720x1112. The sf::VideoMode::getDesktopMode() is returning the correct screen resolution on Windows but it's returning the monitor resolution on macOS (in my case 3420x2224). I think it's related to the scaleOutXY function in the cf_sf_conversion.mm file because the CGDisplayModeGetWidth() and CGDisplayModeGetWidth() functions returning the correct screen resolution values.

Your Environment

  • OS / distro / window manager: macOS Ventura 13.5.1
  • SFML version: 3.0.0
  • Compiler / toolchain: Apple clang version 15..0.0 (clang-1500.1.0.2.5)
  • Special compiler / CMake flags:

Steps to reproduce

#include <SFML/Graphics.hpp>

int main()
{
    const sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
    const unsigned int width = desktop.size.x / 2;
    const unsigned int height = desktop.size.y / 2;

    // The windows goes out of screen because of wrong screen resolution.
    sf::RenderWindow window(sf::VideoMode({width, height}), "Minimal, complete and verifiable example");
    window.setFramerateLimit(60);

    while (window.isOpen())
    {
        for (sf::Event event; window.pollEvent(event);)
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.display();
    }
}

Expected behavior

The sf::VideoMode::getDesktopMode() should have return the screen resolution which is set by user.

Actual behavior

The sf::VideoMode::getDesktopMode() returned the monitor resolution independently from screen resolution.

@ChrisThrasher
Copy link
Member

ChrisThrasher commented Feb 15, 2024

Have you read #2300 yet? If not then please read through that thread so you can get caught up with our progress on fixing this problem. I'm the SFML maintainer who uses macOS so I'm the one to talk to about fixing this. I'm eager to fix it but so far nobody is totally sure what the right fix is.

@alihakankurt
Copy link
Author

I checked the current issues to prevent duplication. I saw that issue and I don't think it's related to the my problem. The sf::VideoMode::getFullscreenModes() also returning empty and causing segfault but my problem is inconsistency between Windows and macOS platforms. sf:: VideoMode::getDesktopMode() returning the user set screen resolution on Windows, but on macOS it's returning the monitor resolution (or the full screen resolution). I as described above, when I remove the scaleOutXY function from source code, it's returning the correct values of my custom screen resolution.

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

No branches or pull requests

3 participants