mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added example
This commit is contained in:
@@ -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)
|
option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" ON)
|
||||||
|
|
||||||
if (OMATH_BUILD_AS_SHARED_LIBRARY)
|
if (OMATH_BUILD_AS_SHARED_LIBRARY)
|
||||||
add_library(omath SHARED source/Vector3.cpp)
|
add_library(omath SHARED source/Matrix.cpp)
|
||||||
else()
|
else()
|
||||||
add_library(omath STATIC source/Matrix.cpp)
|
add_library(omath STATIC source/Matrix.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
project(examples)
|
||||||
|
|
||||||
|
add_executable(ExampleProjectionMatrixBuilder ExampleProjMatBuilder.cpp)
|
||||||
|
target_link_libraries(ExampleProjectionMatrixBuilder PRIVATE omath::omath)
|
||||||
40
examples/ExampleProjMatBuilder.cpp
Normal file
40
examples/ExampleProjMatBuilder.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// Created by Vlad on 3/19/2025.
|
||||||
|
//
|
||||||
|
#include <iostream>
|
||||||
|
#include <omath/engines/opengl_engine/Camera.hpp>
|
||||||
|
#include <omath/engines/opengl_engine/Formulas.hpp>
|
||||||
|
#include <omath/projection/Camera.hpp>
|
||||||
|
#include <print>
|
||||||
|
|
||||||
|
|
||||||
|
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());
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user