Issue
Im trying to build an application on SFML and decided to build it myself instead of using apt package manager. Im also using cmake but i don't think that matters much for my question:
In my file UserInterface.h i have #include <SFML/Graphics.hpp> which worked fine before when i used SFML-dev from apt. Compiler tells that a lot of SFML methods that take in (int x, int y) does not exist (while finding the version taking in sf::Vector2f). These overloaded methods worked fine before.
Now i looked into the source code of SFML and can't actually find the overloaded functions? even though they are in the Documentation:
void sf::Transformable::setOrigin(float x, float y)
I don't understand where i went wrong. The rest of SFML seems to be fine. How does SFML even support these overloaded methods if they are not declared?
This is the output i get when building:
error: no matching function for call to ‘sf::RectangleShape::setOrigin(int, int)’
103 | background.setOrigin(0, 0);
| ^
In file included from /usr/local/include/SFML/Graphics/Shape.hpp:33,
from /usr/local/include/SFML/Graphics/CircleShape.hpp:32,
from /usr/local/include/SFML/Graphics.hpp:34,
from /home/bonkt/dev/digitus/src/UserInterface/UserInterface.h:1,
from /home/bonkt/dev/digitus/src/UserInterface/UserInterface.cpp:1:
/usr/local/include/SFML/Graphics/Transformable.hpp:115:10: note: candidate: ‘void sf::Transformable::setOrigin(const Vector2f&)’
115 | void setOrigin(const Vector2f& origin);
edit: When casting the arguments (int) to float it won't work, so that's not the problem. It also occurs for many other similar methods: window.setPosition() window.setScale()
sf::FloatRect()
Solution
Found my answer: The apt SFML package i used earlier must have been an older version of SFML. I found these merged pull requests at their github just a couple of weeks ago. SFML decided that numerical pairs are not needed, as usage of sf::Vector2T is more consistent with the rest of the API. - So i'll just change my code to use SF::Vector2f
I just had really unlucky timing as the new pullrequests was merged just 5 days ago.
Answered By - bonkt Answer Checked By - David Goodson (WPSolving Volunteer)