Sprite 图像在 SFML window 中得到 clipped/cropped

Sprite Image getting clipped/cropped in SFML window

我正在使用这本名为 "Beginning C++ game programming" 的书来学习游戏编程。 以下是书中的一个片段,它以 SFML window 显示了第一个游戏的背景。 (为我使用命名空间而道歉,我只是在看书)。

#include <SFML/Graphics.hpp>

using namespace sf;

int main() 
{
    RenderWindow window(VideoMode(1920, 1080), "Timber!!", Style::Fullscreen);

    Texture textureBackground;
    textureBackground.loadFromFile("graphics/background.png");
    Sprite spriteBackground;
    spriteBackground.setTexture(textureBackground);
    spriteBackground.setPosition(0,0);

    while (window.isOpen()) 
    {
        if (Keyboard::isKeyPressed(Keyboard::Escape)) {
            window.close();
        }
        window.clear();

        window.draw(spriteBackground);

        window.display();
    }

    return 0;
}

我面临的问题是我在 loadFromFile 中尝试的图像没有完全显示在 window 中。它显示为放大到左上角,即使我使用与图像分辨率相同的 window 大小。

任何 help/advice 表示赞赏。干杯!

编辑:添加图片

我所看到的:(对于糟糕的图片,我的屏幕截图工具在打开时似乎无法正常工作,对此深表歉意)

原图:

您的笔记本电脑没有 1980x1080 分辨率。设置可用分辨率。然后更改 view 以适合整个图片:

Vector2f textureSize(1980, 1080); // or texture.getSize()
VideoMode videomode(1980, 1080);
if (!videomode.isValid()) {
    videomode = VideoMode::getDesktopMode();
}

RenderWindow window(videomode, "Timber!!", Style::Fullscreen);
window.setView(View(FloatRect(0, 0, textureSize.x, textureSize.y)));