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

Author Topic: SFML and Raspberry PI 3  (Read 6640 times)

0 Members and 1 Guest are viewing this topic.

FromageChaud

  • Newbie
  • *
  • Posts: 2
    • View Profile
SFML and Raspberry PI 3
« on: January 19, 2017, 07:42:13 pm »
Hi everyone !

I have used SFML for many years. This is my first time posting here though, I think I have really tried everything and I cannot find similar problems on the web...

I recently successfully compiled SFML on RPI 3 (with Raspbian) following the instructions here : https://github.com/mickelson/sfml-pi

I then tested the basic code at the end of this tutorial (my include files are located in /usr/include/SFML)
http://www.sfml-dev.org/tutorials/2.4/start-vc.php

I successfully compile on my RPI without any warning with this line :
Code: [Select]
g++ main.cpp -o prgrm -lsfml-graphics -lsfml-window -lsfml-system(my .so files are located in /usr/lib)

When executing prgrm, the result is visually as expected, but the 200*200 squared image has no title bar. When I click on it, I am actually clicking on whatever application is "under" the image. So I cannot move the "window" nor interact with it nor close it (I have not found any other solution than killing the app in Task Manager).

Also I tested 2 solutions to this : adding the option sf::Style::Titlebar or sf::Style::Default do not help.

I have tested some looping animations on the image, those work.

I hope this kind of symptom is known by somebody here, please let me know !

FromageChaud

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML and Raspberry PI 3
« Reply #1 on: January 20, 2017, 01:23:30 am »
Well finally my problem is solved !

It was quite dumb (as always :p) : I just uninstalled completely SFML from my RPI, then reinstalled using sudo apt-get install libsfml-dev and not using https://github.com/mickelson/sfml-pi (it probably was a problem of version of SFML). The code of my first post now works.

Now on my project, it has almost nothing to do with SFML but I had to modify some parts of the code that were working on windows but not on RPI : std::to_string and std::vector of many objects with complex member attributes (like sf::RectangleShape) make the app crash. About the std::vector<sf::RectangleShape>, I just had to replace everything to make it a std::vector<sf::RectangleShape*>. I have found no solution for std::to_string but I don't actually need it anyway.

I hope this will help someone !

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: SFML and Raspberry PI 3
« Reply #2 on: January 20, 2017, 02:03:33 am »
How will it crash? Sounds odd that general usage of C++ containers would cause a crash - unless you're running out of memory some how.

std::to_string is a C++11 feature and is most likely provided with your compiler, you might have to add the -std=c++11 flag for GCC or CLang.
Alternatively you can use std::stringstream to convert things into strings.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/