Skip to content

Commit

Permalink
Fix ImVec2 implicit conversion to non-float sf::Vector2s
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Oct 23, 2023
1 parent 56b256c commit d75897c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions imconfig-SFML.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

#include "imgui-SFML_export.h"

#define IM_VEC2_CLASS_EXTRA \
template<typename T> \
ImVec2(const sf::Vector2<T>& v) { \
x = static_cast<float>(v.x); \
y = static_cast<float>(v.y); \
} \
\
template<typename T> \
operator sf::Vector2<T>() const { \
return sf::Vector2<T>(x, y); \
#define IM_VEC2_CLASS_EXTRA \
template<typename T> \
ImVec2(const sf::Vector2<T>& v) { \
x = static_cast<float>(v.x); \
y = static_cast<float>(v.y); \
} \
\
template<typename T> \
operator sf::Vector2<T>() const { \
return sf::Vector2<T>(static_cast<T>(x), static_cast<T>(y)); \
}

#define IM_VEC4_CLASS_EXTRA \
Expand Down
2 changes: 1 addition & 1 deletion tests/imconfig-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST_CASE("IM_VEC2_CLASS_EXTRA") {
}

SECTION("To sf::Vector2f") {
// TODO Fix for other sf::Vector2 specializations
CHECK(sf::Vector2i(ImVec2(1.1f, 2.2f)) == sf::Vector2i(1, 2));
CHECK(sf::Vector2f(ImVec2(1.1f, 2.2f)) == sf::Vector2f(1.1f, 2.2f));
}
}
Expand Down

0 comments on commit d75897c

Please sign in to comment.