diff --git a/.gitmodules b/.gitmodules
index c16587c..b6c1697 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "extlibs/googletest"]
path = extlibs/googletest
url = https://github.com/google/googletest.git
+[submodule "extlibs/glm"]
+ path = extlibs/glm
+ url = https://github.com/g-truc/glm.git
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index adc159a..edda590 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,7 @@
+
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 72ca0fb..b2d004b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,10 +23,10 @@ if(OMATH_BUILD_TESTS)
add_subdirectory(tests)
endif()
-if (WIN32 AND OMATH_THREAT_WARNING_AS_ERROR)
+if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND OMATH_THREAT_WARNING_AS_ERROR)
target_compile_options(omath PRIVATE /W4 /WX)
-elseif(UNIX AND OMATH_THREAT_WARNING_AS_ERROR)
- target_compile_options(omath PRIVATE -Wall -Wextra -Wpedantic)
+elseif(OMATH_THREAT_WARNING_AS_ERROR)
+ target_compile_options(omath PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
target_include_directories(omath
diff --git a/CMakePresets.json b/CMakePresets.json
index d67436b..74671b4 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -8,8 +8,8 @@
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
"installDir": "${sourceDir}/cmake-build/install/${presetName}",
"cacheVariables": {
- "CMAKE_C_COMPILER": "cl.exe",
- "CMAKE_CXX_COMPILER": "cl.exe"
+ "CMAKE_C_COMPILER": "clang.exe",
+ "CMAKE_CXX_COMPILER": "clang++.exe"
},
"condition": {
"type": "equals",
diff --git a/extlibs/CMakeLists.txt b/extlibs/CMakeLists.txt
index bf73c7a..caca17c 100644
--- a/extlibs/CMakeLists.txt
+++ b/extlibs/CMakeLists.txt
@@ -1 +1,2 @@
-add_subdirectory(googletest)
\ No newline at end of file
+add_subdirectory(googletest)
+add_subdirectory(glm)
\ No newline at end of file
diff --git a/extlibs/glm b/extlibs/glm
new file mode 160000
index 0000000..33b4a62
--- /dev/null
+++ b/extlibs/glm
@@ -0,0 +1 @@
+Subproject commit 33b4a621a697a305bc3a7610d290677b96beb181
diff --git a/include/omath/engines/opengl.hpp b/include/omath/engines/opengl.hpp
new file mode 100644
index 0000000..6b70756
--- /dev/null
+++ b/include/omath/engines/opengl.hpp
@@ -0,0 +1,35 @@
+//
+// Created by Orange on 11/23/2024.
+//
+#pragma once
+#include "omath/Vector3.hpp"
+#include "omath/Mat.hpp"
+
+
+namespace omath::opengl
+{
+ constexpr Vector3 kAbsUp = {0, 1, 0};
+ constexpr Vector3 kAbsRight = {1, 0, 0};
+ constexpr Vector3 kAbsForward = {0, 0, -1};
+
+ template requires std::is_floating_point_v || std::is_integral_v
+ [[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix()
+ {
+
+ }
+
+ template requires std::is_floating_point_v || std::is_integral_v
+ [[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix(
+ const float fieldOfView, const Type &aspectRatio, const Type &near, const Type &far)
+ {
+ const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2);
+
+ return
+ {
+ {static_cast(1) / (aspectRatio * fovHalfTan), 0, 0, 0},
+ {0, static_cast(1) / (fovHalfTan), 0, 0},
+ {0, 0, -(far + near) / (far - near), -(static_cast(2) * far * near) / (far - near)},
+ {0, 0, -1, 0},
+ };
+ }
+}
diff --git a/include/omath/engines/source.hpp b/include/omath/engines/source.hpp
new file mode 100644
index 0000000..24308fc
--- /dev/null
+++ b/include/omath/engines/source.hpp
@@ -0,0 +1,28 @@
+//
+// Created by Orange on 11/24/2024.
+//
+#pragma once
+
+
+namespace omath::source
+{
+ constexpr Vector3 kAbsUp = {0, 0, 1};
+ constexpr Vector3 kAbsRight = {0, -1, 0};
+ constexpr Vector3 kAbsForward = {1, 0, 0};
+
+
+ template requires std::is_floating_point_v || std::is_integral_v
+ [[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix(
+ const float fieldOfView, const Type &aspectRatio, const Type &near, const Type &far)
+ {
+ const float fovHalfTan = std::tan(angles::DegreesToRadians(fieldOfView) / 2);
+
+ return
+ {
+ {static_cast(1) / (aspectRatio * fovHalfTan), 0, 0, 0},
+ {0, static_cast(1) / (fovHalfTan), 0, 0},
+ {0, 0, (far + near) / (far - near), -(static_cast(2) * far * near) / (far - near)},
+ {0, 0, 1, 0},
+ };
+ }
+}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1c604c1..3b9b056 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -15,8 +15,9 @@ add_executable(unit-tests
UnitTestColor.cpp
UnitTestVector4.cpp
UnitTestLineTrace.cpp
+ UnitTestOpenGL.cpp
)
-target_link_libraries(unit-tests PRIVATE gtest gtest_main omath)
+target_link_libraries(unit-tests PRIVATE gtest gtest_main omath glm)
gtest_discover_tests(unit-tests)
\ No newline at end of file
diff --git a/tests/UnitTestOpenGL.cpp b/tests/UnitTestOpenGL.cpp
new file mode 100644
index 0000000..e4f1561
--- /dev/null
+++ b/tests/UnitTestOpenGL.cpp
@@ -0,0 +1,48 @@
+//
+// Created by Orange on 11/23/2024.
+//
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "glm/ext/matrix_clip_space.hpp"
+#include "glm/ext/matrix_transform.hpp"
+
+
+TEST(UnitTestOpenGL, Projection)
+{
+
+ const auto proj_glm = glm::perspective(glm::radians(90.f), 16.f / 9.f, 0.1f, 1000.f);
+ const auto proj_glm2 = glm::perspectiveLH_NO(glm::radians(90.f), 16.f / 9.f, 0.1f, 1000.f);
+ // const auto proj_omath = omath::Mat<4, 4, float, omath::MatStoreType::COLUMN_MAJOR>((const float*)&proj_glm);
+ // EXPECT_EQ(omath::opengl::PerspectiveProjectionMatrix(90, 16.f / 9.f, 0.1f, 1000.f), proj_omath);
+
+
+ glm::vec4 ndc_glm2 = proj_glm * glm::vec4(300.f, 0.f, -1000.f, 1.f);
+ ndc_glm2 /= ndc_glm2.w;
+ const omath::Mat<4, 1, float, omath::MatStoreType::COLUMN_MAJOR> cords_omath =
+ {
+ {0},
+ {0},
+ {-0.2f},
+ {1}
+ };
+
+ //auto ndc_omath = proj_omath * cords_omath;
+ // ndc_omath /= ndc_omath.At(3, 0);
+
+}
+TEST(UnitTestOpenGL, Projection2)
+{
+ const auto orient = omath::Mat<>::OrientationMat(omath::opengl::kAbsForward, omath::opengl::kAbsRight, omath::opengl::kAbsUp);
+
+ const omath::Mat<4, 1> cords_omath =
+ {
+ {0}, {0}, {10}, {1}
+ };
+ std::cout << (orient.Transposed() * cords_omath).ToString();
+}
\ No newline at end of file