I have successfully built and used SFML with 'slightly' modified Vector2.hpp file:
#ifndef SFML_VECTOR2_HPP
#define SFML_VECTOR2_HPP
#include <glm/vec2.hpp>
namespace sf
{
template<typename T>
using Vector2 = glm::tvec2<T>;
// Define the most common types
typedef glm::tvec2<int> Vector2i;
typedef glm::tvec2<unsigned int> Vector2u;
typedef glm::tvec2<float> Vector2f;
} // namespace sf
#endif // SFML_VECTOR2_HPP
It is pretty small modification to SFML's code and let's you do all you want without additional conversions, especially implicit ones (which areā¦ bad af?). I thought this may be way to go for you.
It is pretty small modification to SFML's code
Pretty small but it is one anyway, which prevents your code from working with official (and all other) SFML builds.
True dat. After all it's just a suggestion, @OP can decide what's the best approach for him.
Btw if I was forced not to modify SFML code, I'd use some proxy class that would inherit from sf::Vector2<T>, but also could be converted to and set by glm::tvec2<T>.
template<class T>
class ProxyVec
: public sf::Vector2<T> {
public:
using sf::Vector2<T>::Vector2;
glm::tvec2<T> glm() {
return {this->x, this->y};
}
ProxyVec& operator=(glm::tvec2<T> v) {
this->x = v.x;
this->y = v.y;
return *this;
}
};