Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Kalicliq

Pages: [1]
1
Window / mouse position relative to window
« on: February 06, 2021, 10:50:50 pm »
Hi i want to center the mouse on the previously created window. But something went wrong and i dont know why.
you can see where the mouse is positioned on the screenshot.

Edit: Im on Fedora 33.

void Window::create(const std::string windowName, const sf::VideoMode resolution, const bool fullScreen)
{
    sf::VideoMode screenSize = sf::VideoMode::getDesktopMode();

    _window.create(resolution, windowName, fullScreen ? 8 : 7);
    _window.setVerticalSyncEnabled(true);
    if (!fullScreen)
        _window.setPosition(sf::Vector2i((screenSize.width / 2) - (resolution.width / 2), (screenSize.height / 2) - (resolution.height / 2)));

    sf::Mouse::setPosition(sf::Vector2i(_window.getSize().x / 2, _window.getSize().y / 2), _window);
}
 

Pages: [1]