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

Author Topic: Window creation trouble on SMFL-Pi  (Read 1402 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
Window creation trouble on SMFL-Pi
« on: September 05, 2018, 04:59:11 am »
I'm using SFML for a project on my Raspberry Pi running Raspbian Stretch (Library gotten from https://github.com/mickelson/sfml-pi), and the window positioning isn't working (the window decoration isn't working, either, but that's a secondary concern). I used this example code from the getting started tutorial:

    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);

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


This is supposed to make a typical window with a green circle fitting completely inside the borders. I'm not sure where on the screen it would normally appear, but since the default window position is <0,0>, I would guess that would be the upper left corner of the screen. What I actually see is a green circle in the upper left of the screen but positioned such that the top and left side are off the screen (I estimate that about 15-20% of the expected width/height of the window is cut off). It seems like the window position variables are negative compared to the desktop origin. I've tried setting the window position to something else after creating it, but it doesn't move at all. Also noteworthy is that it lacks any decorations. I've tried running the program before starting the desktop, but the results are the same. Does anyone know what's going on?

One more piece of information is that I'm doing a remote build and run over ssh, but I don't see how that would affect it since the pi is still doing the building and running.


  • Sr. Member
  • ****
  • Posts: 459
  • Buns.
    • View Profile
    • Trederia
Re: Window creation trouble on SMFL-Pi
« Reply #1 on: September 05, 2018, 10:49:21 am »
I used the pi version in a project a while back and I remember some similar problems (I can't check the project any more because it went to a client). I was running without an x session, that I do remember, and to stop the cropping I think I had to adjust the overscan settings for the pi itself, which can be done with config.txt


Window creation looked something like:

    const sf::Vector2f ScreenArea(1920.f, 1080.f);

    auto mode = sf::VideoMode::getDesktopMode();
    sf::RenderWindow window;
    window.create(mode, "Buns.");

    //fix the view at 1080p
    auto vModeWidth = static_cast<float>(mode.width);
    auto vModeHeight = static_cast<float>(mode.height);

    if(mode.width == 720)
        //we're using composite output so the display handles letterboxing
        //we just need to adjust the pixel aspect ratio
        sf::View view({0.f, 0.f, ScreenArea.x, ScreenArea.y});
        view.setCenter(ScreenArea / 2.f);
        float windowRatio = vModeWidth / vModeHeight;
        float viewRatio = 16.f / 9.f;
        float sizeY = windowRatio / viewRatio;
        float top = (1.f - sizeY) / 2.f;

        sf::View view({0.f, 0.f, ScreenArea.x, ScreenArea.y});
        view.setCenter(ScreenArea / 2.f);
        view.setViewport({ { 0.f, top }, { 1.f, sizeY } });

Hope this is some help


  • SFML Team
  • Hero Member
  • *****
  • Posts: 10191
    • View Profile
    • development blog
    • Email
Re: Window creation trouble on SMFL-Pi
« Reply #2 on: September 05, 2018, 10:54:07 am »
Isn't the point of not using X11 to not have windows with decorations and custom size? If you want to operate with a normal window etc, you should be able to just install X11 and compile the official SFML for ARM/Pi, I think.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/