From 50c336e0442419480c630a08e4998136de7e0fbe Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 19 Mar 2025 19:16:22 +0300 Subject: [PATCH] added example --- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 4 +++ examples/ExampleProjMatBuilder.cpp | 40 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 examples/ExampleProjMatBuilder.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d5e8b5..c435075 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ option(OMATH_IMGUI_INTEGRATION "Omath will define method to convert omath types option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" ON) if (OMATH_BUILD_AS_SHARED_LIBRARY) - add_library(omath SHARED source/Vector3.cpp) + add_library(omath SHARED source/Matrix.cpp) else() add_library(omath STATIC source/Matrix.cpp) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e69de29..11580f0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -0,0 +1,4 @@ +project(examples) + +add_executable(ExampleProjectionMatrixBuilder ExampleProjMatBuilder.cpp) +target_link_libraries(ExampleProjectionMatrixBuilder PRIVATE omath::omath) \ No newline at end of file diff --git a/examples/ExampleProjMatBuilder.cpp b/examples/ExampleProjMatBuilder.cpp new file mode 100644 index 0000000..f06cc3c --- /dev/null +++ b/examples/ExampleProjMatBuilder.cpp @@ -0,0 +1,40 @@ +// +// Created by Vlad on 3/19/2025. +// +#include +#include +#include +#include +#include + + +int main() +{ + std::println("OMATH Projection Matrix Builder"); + + float fov = 0; + float near = 0; + float far = 0; + float viewPortWidth = 0; + float viewPortHeight = 0; + + std::print("Enter camera fov: "); + std::cin >> fov; + + std::print("Enter camera z near: "); + std::cin >> near; + + std::print("Enter camera z far: "); + std::cin >> far; + + std::print("Enter camera screen width: "); + std::cin >> viewPortWidth; + + std::print("Enter camera screen height: "); + std::cin >> viewPortHeight; + + const auto mat = + omath::opengl_engine::CalcPerspectiveProjectionMatrix(fov, viewPortWidth / viewPortHeight, near, far); + + std::print("{}", mat.ToString()); +};