Missing files

This commit is contained in:
Balhau 2025-01-02 17:57:40 +00:00
parent e8e009e42d
commit fb3b7a898c
6 changed files with 112 additions and 0 deletions

20
app/fpointers.cpp Normal file
View file

@ -0,0 +1,20 @@
#include "../src/platform/base.hpp"
int sum(int a, int b) { return a + b; }
int sub(int a, int b) { return a - b; }
int main(void) {
std::cout << "Hello Pointers" << std::endl;
f_pointer(op, int, int, int);
op = sum;
int a = 22;
int b = 11;
std::cout << "Sum: " << op(a, b) << std::endl;
op = sub;
std::cout << "Sub: " << op(a, b) << std::endl;
}

20
premake/fpointers.lua Normal file
View file

@ -0,0 +1,20 @@
project "fpointers"
kind "ConsoleApp"
language "c++"
targetdir "../bin/%{cfg.buildcfg}"
objdir "../obj"
--files {"**.hpp","**.cpp"}
files {
"../app/fpointers.cpp"
}
filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
filter { "system:linux" }

View file

@ -0,0 +1,27 @@
#include "quaternion.hpp"
using namespace engine::math;
quaternion::quaternion(float32 _x, float32 _y, float32 _z, float32 _w) {
x = _x;
y = _y;
z = _z;
w = _w;
};
quaternion::quaternion(const vector3d &v, float32 scalar) {
quaternion(v.x, v.y, v.z, scalar);
};
const vector3d &quaternion::GetVector() const {
return reinterpret_cast<const vector3d &>(x);
};
inline quaternion operator*(const quaternion &q1, const quaternion &q2) {
float32 x = q1.x * q2.w + q1.y * q2.z - q1.z * q2.y + q1.w * q2.x;
float32 y = q1.y * q2.w + q1.z * q2.x + q1.w * q2.y - q1.x * q2.z;
float32 z = q1.z * q2.w + q1.w * q2.z + q1.x * q2.y - q1.y * q2.x;
float32 w = q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z;
return quaternion(x, y, z, w);
};

View file

@ -0,0 +1,18 @@
#pragma once
#include "../../platform/base.hpp"
#include "vector3d.hpp"
namespace engine::math {
struct quaternion {
float32 x, y, z, w;
quaternion() = default;
~quaternion() = default;
quaternion(float32 _x, float32 _y, float32 _z, float32 _w);
quaternion(const vector3d &v, float32 s);
const vector3d &GetVector(void) const;
};
inline quaternion operator*(const quaternion &q1, const quaternion &q2);
}; // namespace engine::math

View file

@ -0,0 +1,9 @@
#pragma once
// Defines a matrix in termos of float32
#define MATRIX(n, d) float32 n[d][d]
// Computes determinant sub block
#define DET(a, b, c, d) (a * d - b * c)
#define INVDET(row, idet) row[0] * idet, row[1] * idet, row[2] * idet

18
src/platform/dsl/pt.h Normal file
View file

@ -0,0 +1,18 @@
/**
* Defines a set of macros to enable us to progam as if C was created by
* portuguese programmers
*/
#define se if
#define senao else
#define enquanto while
#define para for
#define privado private
#define publico public
#define protegido protected
#define estatico static
#define constante const
#define classe class
#define estrutura struct
#define deftipo typedef
#define vazio void