From e49fcfcd3c0c507022472f8b3befa4b16f14fb71 Mon Sep 17 00:00:00 2001 From: TuNiMan1 Date: Sun, 19 Mar 2023 18:36:36 +0200 Subject: [PATCH] added primitive types --- .gitignore | 2 +- .vscode/settings.json | 3 +- Build.cpp | 61 +++++++++++++++++++++++++++++ Build.h | 0 Primitives.h | 89 +++++++++++++++++++++++++++++++++++++++++++ math/Matrix3.h | 3 ++ math/Quaternion.inl | 0 7 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 Build.cpp create mode 100644 Build.h create mode 100644 Primitives.h create mode 100644 math/Matrix3.h create mode 100644 math/Quaternion.inl diff --git a/.gitignore b/.gitignore index 120cfdc..643fc71 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ *.out *.app -.vscode +.vscode/* diff --git a/.vscode/settings.json b/.vscode/settings.json index bfd7745..cfc5911 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,5 +33,6 @@ "**/.vscode", "**/.vscode/**" ], - "C_Cpp_Runner.useAddressSanitizer": false + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp.errorSquiggles": "enabled" } \ No newline at end of file diff --git a/Build.cpp b/Build.cpp new file mode 100644 index 0000000..9376753 --- /dev/null +++ b/Build.cpp @@ -0,0 +1,61 @@ +#pragma once +#pragma warning(disable : 4251) + +#include "Platform.h" +#include "Compiler.h" + +extern "C" void flmain(); + +namespace FL +{ + + extern void runtimeAssert(bool condition); + extern void runtimeAssert(bool condition, const char *message); + +} + +#ifdef _DEBUG +#define FL_DEBUG +#else +#define FL_RELEASE +#endif + +#define FL_ASSERT(condition) FL::runtimeAssert(condition) +#define FL_ASSERT_M(condition, message) FL::runtimeAssert(condition, message) +#define FL_STATIC_ASSERT(condition) static_assert(condition) + +#ifdef FL_DEBUG +#define FL_DEBUG_ASSERT(condition) FL_ASSERT(condition) +#define FL_DEBUG_ASSERT_M(condition, message) FL_ASSERT_M(condition, message) +#define FL_RELEASE_ASSERT(condition) +#define FL_RELEASE_ASSERT_M(condition) +#else +#define FL_DEBUG_ASSERT(condition) +#define FL_DEBUG_ASSERT_M(condition, message) +#define FL_RELEASE_ASSERT(condition) FL_ASSERT(condition) +#define FL_RELEASE_ASSERT_M(condition, message) FL_ASSERT_M(condition, message) +#endif + +#ifdef FL_PLATFORM_WINDOWS +#ifdef FL_DLL_EXPORT +#define FL_API __declspec(dllexport) +#elif defined(FL_DLL_IMPORT) +#define FL_API __declspec(dllimport) +#else +#define FL_API +#endif +#else +#define FL_API +#endif + +#define FL_CONSTEXPR constexpr + +#define FL_COPY_MEMORY(source, destination, size) memcpy(destination, source, size) + +#define FL_ZERO_MEMORY(block, size) memset(block, 0, size) + +#ifdef FL_VISUAL_C_PLUS_PLUS +#define FL_FORCE_INLINE __forceinline +#else +#define FL_FORCE_INLINE inline +#endif \ No newline at end of file diff --git a/Build.h b/Build.h new file mode 100644 index 0000000..e69de29 diff --git a/Primitives.h b/Primitives.h new file mode 100644 index 0000000..78ba685 --- /dev/null +++ b/Primitives.h @@ -0,0 +1,89 @@ +#pragma once + +#include + +typedef const char *cString; + +// Signed integer types. + +// 1 byte +typedef int8_t i8; +// 2 bytes +typedef int16_t i16; +// 4 bytes +typedef int32_t i32; +// 8 bytes +typedef int64_t i64; + +// Fastest signed integer types. + +// At least 1 byte +typedef int_fast8_t i8f; +// At least 2 bytes +typedef int_fast16_t i16f; +// At least 4 bytes +typedef int_fast32_t i32f; +// At least 8 bytes +typedef int_fast64_t i64f; + +// Smallest signed integer types. + +// At least 1 byte +typedef int_least8_t i8l; +// At least 2 bytes +typedef int_least16_t i16l; +// At least 4 bytes +typedef int_least32_t i32l; +// At least 8 bytes +typedef int_fast64_t i64l; + +// Unsigned integer types. + +// 1 byte +typedef uint8_t ui8; +// 2 bytes +typedef uint16_t ui16; +// 4 bytes +typedef uint32_t ui32; +// 8 bytes +typedef uint64_t ui64; + +// Fastest unsigned integer types. + +// At least 1 byte +typedef uint_fast8_t ui8f; +// At least 2 bytes +typedef uint_fast16_t ui16f; +// At least 4 bytes +typedef uint_fast32_t ui32f; +// At lease 8 bytes +typedef uint_fast64_t ui64f; + +// Smallest unsigned integer types. + +// At least 1 byte +typedef uint_least8_t ui8l; +// At least 2 bytes +typedef uint_least16_t ui16l; +// At least 4 bytes +typedef uint_least32_t ui32l; +// At least 8 bytes +typedef uint_least64_t ui64l; + +// Floating types + +typedef float f32; + +#ifdef FL_REQUIRE_F32 +static_assert(sizeof(f32) == 4, "Floats have to be 32 bit since FL_REQUIRE_F32 is defined"); +#endif + +typedef double f64; +#ifdef FL_REQUIRE_F64 +static_assert(sizeof(f64) == 8, "Doubles have to be 64 bit since FL_REQUIRE_F64 is defined"); +#endif + +typedef long double f128; +#ifdef FL_REQUIRE_f128 +static_assert(sizeof(f128) == 16, "Long doubles have to be 128 bit since FL_REQUIRE_F128 is defined"); +#endif \ No newline at end of file diff --git a/math/Matrix3.h b/math/Matrix3.h new file mode 100644 index 0000000..919cb41 --- /dev/null +++ b/math/Matrix3.h @@ -0,0 +1,3 @@ +#pragma once + +#include "../Build.h" \ No newline at end of file diff --git a/math/Quaternion.inl b/math/Quaternion.inl new file mode 100644 index 0000000..e69de29