mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added vcpkg manifest file
This commit is contained in:
@@ -23,6 +23,15 @@ option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build
|
|||||||
option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" OFF)
|
option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" OFF)
|
||||||
option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" OFF)
|
option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" OFF)
|
||||||
|
|
||||||
|
if (CMAKE_TOOLCHAIN_FILE)
|
||||||
|
foreach (omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
||||||
|
if (omath_feature STREQUAL "imgui")
|
||||||
|
set(OMATH_IMGUI_INTEGRATION ON)
|
||||||
|
elseif (omath_feature STREQUAL "avx2")
|
||||||
|
set(OMATH_USE_AVX2 ${COMPILER_SUPPORTS_AVX2})
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
endif ()
|
||||||
if (OMATH_USE_AVX2 AND NOT COMPILER_SUPPORTS_AVX2)
|
if (OMATH_USE_AVX2 AND NOT COMPILER_SUPPORTS_AVX2)
|
||||||
message(WARNING "OMATH_USE_AVX2 requested, but compiler/target does not support AVX2. Disabling.")
|
message(WARNING "OMATH_USE_AVX2 requested, but compiler/target does not support AVX2. Disabling.")
|
||||||
set(OMATH_USE_AVX2 OFF CACHE BOOL "Omath will use AVX2 to boost performance" FORCE)
|
set(OMATH_USE_AVX2 OFF CACHE BOOL "Omath will use AVX2 to boost performance" FORCE)
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ namespace omath
|
|||||||
}
|
}
|
||||||
#ifdef OMATH_IMGUI_INTEGRATION
|
#ifdef OMATH_IMGUI_INTEGRATION
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ImVec2 to_im_vec2() const noexcept
|
constexpr ImVec2 to_im_vec2() const noexcept
|
||||||
{
|
{
|
||||||
return {static_cast<float>(this->x), static_cast<float>(this->y)};
|
return {static_cast<float>(this->x), static_cast<float>(this->y)};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ namespace omath
|
|||||||
|
|
||||||
#ifdef OMATH_IMGUI_INTEGRATION
|
#ifdef OMATH_IMGUI_INTEGRATION
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ImVec4 to_im_vec4() const noexcept
|
constexpr ImVec4 to_im_vec4() const noexcept
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
static_cast<float>(this->x),
|
static_cast<float>(this->x),
|
||||||
|
|||||||
39
tests/general/unit_test_imgui_intergration.cpp
Normal file
39
tests/general/unit_test_imgui_intergration.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// Created by Vlad on 10/23/2025.
|
||||||
|
//
|
||||||
|
#ifdef OMATH_IMGUI_INTEGRATION
|
||||||
|
#include <omath/omath.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using namespace omath;
|
||||||
|
|
||||||
|
TEST(unit_test_imgui_intergration, Vector2ToImVec2)
|
||||||
|
{
|
||||||
|
constexpr Vector2 omath_vector_2d = {1.f, 2.f};
|
||||||
|
constexpr ImVec2 imgui_vector_2d = {1, 2.f};
|
||||||
|
|
||||||
|
constexpr auto converted = omath_vector_2d.to_im_vec2();
|
||||||
|
EXPECT_NEAR(converted.x, imgui_vector_2d.x, 1.e-5f);
|
||||||
|
EXPECT_NEAR(converted.y, imgui_vector_2d.y, 1.e-5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(unit_test_imgui_intergration, Vector4ToImVec4)
|
||||||
|
{
|
||||||
|
constexpr Vector4 omath_vector_2d = {1.f, 2.f, 3.f, 4.f};
|
||||||
|
constexpr ImVec4 imgui_vector_4d = {1, 2.f, 3.f, 4.f};
|
||||||
|
|
||||||
|
constexpr auto converted = omath_vector_2d.to_im_vec4();
|
||||||
|
|
||||||
|
EXPECT_NEAR(converted.x, imgui_vector_4d.x, 1.e-5f);
|
||||||
|
EXPECT_NEAR(converted.y, imgui_vector_4d.y, 1.e-5f);
|
||||||
|
EXPECT_NEAR(converted.z, imgui_vector_4d.z, 1.e-5f);
|
||||||
|
EXPECT_NEAR(converted.w, imgui_vector_4d.w, 1.e-5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
31
vcpkg.json
Normal file
31
vcpkg.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"name": "omath",
|
||||||
|
"version": "3.10.1",
|
||||||
|
"description": "General purpose math library",
|
||||||
|
"homepage": "https://github.com/orange-cpp/omath",
|
||||||
|
"license": "Zlib",
|
||||||
|
"supports": "windows | linux",
|
||||||
|
"dependencies": [
|
||||||
|
{
|
||||||
|
"name": "vcpkg-cmake",
|
||||||
|
"host": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vcpkg-cmake-config",
|
||||||
|
"host": true
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"features": {
|
||||||
|
"avx2": {
|
||||||
|
"description": "Omath will use AVX2 to boost performance",
|
||||||
|
"supports": "!arm"
|
||||||
|
},
|
||||||
|
"imgui": {
|
||||||
|
"description": "Omath will define method to convert omath types to imgui types",
|
||||||
|
"dependencies": [
|
||||||
|
"imgui"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user