- Updated Coding Standards and adjusted code to fit.

- Restructured test for organization purposes
This commit is contained in:
Medusa Slockbower 2025-06-12 13:03:50 -04:00
parent b7e1b1ff62
commit e50cfb6e64
35 changed files with 384 additions and 163 deletions

View File

@ -4,9 +4,15 @@ project(fennec)
set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD 26)
set(CMAKE_C_STANDARD 26) set(CMAKE_C_STANDARD 26)
# find dependencies
find_package(Doxygen)
# any necessary include directories # any necessary include directories
include_directories(include) include_directories(include)
# Metaprogramming is a dependency for generating various type info before compilation of the engine.
add_subdirectory(metaprogramming)
add_library(fennec STATIC add_library(fennec STATIC
# CORE ================================================================================================================= # CORE =================================================================================================================
@ -74,10 +80,12 @@ add_library(fennec STATIC
include/fennec/lang/lang.h include/fennec/lang/lang.h
) )
add_subdirectory(metaprogramming)
# add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled # add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled
add_dependencies(fennec fennecdocs metaprogramming) if(DOXYGEN_FOUND)
add_dependencies(fennec fennecdocs metaprogramming)
else()
add_dependencies(fennec metaprogramming)
endif()
# Compiler Warning Flags # Compiler Warning Flags
if(MSVC) if(MSVC)
@ -103,8 +111,6 @@ add_subdirectory(test)
file(COPY logo DESTINATION docs/logo) file(COPY logo DESTINATION docs/logo)
find_package(Doxygen)
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
set(DOXY_OUTPUT_DIR "${PROJECT_SOURCE_DIR}/docs") set(DOXY_OUTPUT_DIR "${PROJECT_SOURCE_DIR}/docs")
get_filename_component(DOXYGEN_PROJECT_NAME ${PROJECT_SOURCE_DIR} NAME) # Set Doxy Project name to the name of the root dir get_filename_component(DOXYGEN_PROJECT_NAME ${PROJECT_SOURCE_DIR} NAME) # Set Doxy Project name to the name of the root dir

View File

@ -11,12 +11,13 @@
## Table of Contents ## Table of Contents
1. [Introduction](#introduction) 1. [Introduction](#introduction)
1. [Coding Standards](#coding-standards)
2. [Building from Source](#building-from-source) 2. [Building from Source](#building-from-source)
1. [Building from Terminal](#building-from-terminal) 1. [Building from Terminal](#building-from-terminal)
2. [Building on Windows](#building-on-windows) 2. [Building on Windows](#building-on-windows)
3. [Running the Test Suite](#running-the-test-suite) 3. [Running the Test Suite](#running-the-test-suite)
3. [Usage](#usage) 4. [Usage](#usage)
4. [Contribution](#contribution) 5. [Contribution](#contribution)
<br> <br>
<br> <br>
@ -26,22 +27,42 @@
## Introduction ## Introduction
fennec is designed to be a general purpose, educational game engine. fennec is designed to be a general purpose, educational game engine.
fennec may be used through the provided editor application, or as a standalone
library to link against your application.
<br>
<a id="coding-standards"></a>
### Coding Standards
Interfacing with the API in C++ follows the [GNU Coding Standards](https://www.gnu.org/prep/standards/html_node/index.html). Interfacing with the API in C++ follows the [GNU Coding Standards](https://www.gnu.org/prep/standards/html_node/index.html).
fennec may be used both through the provided editor application, or as a standalone Some main areas where the engine strays from the GNU standard includes the following:
library link against your application. Some main areas where the engine strays from
the GNU standard includes the following:
- [Section 4.7, Standards for Graphical Interfaces](https://www.gnu.org/prep/standards/html_node/Graphical-Interfaces.html). * [Section 4.7, Standards for Graphical Interfaces](https://www.gnu.org/prep/standards/html_node/Graphical-Interfaces.html).
fennec provides an implementation for X11, however it does not use the GTK toolkit. fennec provides an implementation for X11, however it does not use the GTK toolkit.
- [Section 6.1, GNU Manuals](https://www.gnu.org/prep/standards/html_node/GNU-Manuals.html) - [Section 6.1, GNU Manuals](https://www.gnu.org/prep/standards/html_node/GNU-Manuals.html)
fennec does not use Texinfo and instead uses Doxygen. Otherwise, it follows the other standards of this section. fennec does not use Texinfo and instead uses Doxygen. Otherwise, it follows the other standards of this section.
- [Section 7, The Release Process](https://www.gnu.org/prep/standards/html_node/Managing-Releases.html) * [Section 7, The Release Process](https://www.gnu.org/prep/standards/html_node/Managing-Releases.html)
fennec follows most of the conventions in this section, however the build system used is CMake and not fennec follows most of the conventions in this section, however the build system used is CMake and not
Makefile. CMake, although overwhelming at first, is much more friendly to those who are learning build systems for the first time. Makefile. CMake, although overwhelming at first, is much more friendly to those who are learning build systems for the first time.
<br> <br>
fennec Standards:
* As per the GNU standard, macros should be `SCREAMING_SNAKE_CASE`. Additionally, Macros should be preceded by `<APP_NAME>_`.
Macros that wrap C-Style functions may use normal `snake_case`.
- Header Guards should be implemented using `#ifndef`, `#define`, and `#endif` for portability.
The naming convention for Header Guards is as follows: `<APP_NAME>_<DIRECTORY_PATH>_<FILE_NAME>_H`.
I.E. the engine file `fennec/lang/utility.h` has the Header Guard `FENNEC_LANG_UTILITY_H`.
* Helper Functions, in the case of classes, should be private.
In the case of global functions, helpers should be placed in a similarly named file in a subdirectory and namespace called `detail`.
Helper functions should be documented with C-Style comments, however it is not necessary to provide Doxygen documentation.
<br>
The C++ stdlib is reimplemented in the fennec engine. The C++ stdlib is reimplemented in the fennec engine.
There are a few reasons for this: There are a few reasons for this:
@ -58,9 +79,13 @@ There are a few reasons for this:
<a id="building-from-source"></a> <a id="building-from-source"></a>
## Building from Source ## Building from Source
fennec uses the CMake build system. The CMake build script provides several fennec uses the CMake build manager. The CMake build script provides several
targets for building parts of the engine. targets for building parts of the engine.
Using an IDE will streamline the build process for you and add additional configuration
options. Eclipse, Visual Studio, and CLion provide built-in support for CMake. VSCode
is also a viable IDE but involves some extra setup.
| Target | Description | | Target | Description |
|------------------------|----------------------------------------------------------------------------------------| |------------------------|----------------------------------------------------------------------------------------|
| fennec | The main engine target. | | fennec | The main engine target. |
@ -69,11 +94,16 @@ targets for building parts of the engine.
| fennecdocs-clean | Cleans the generated html documentation files. | | fennecdocs-clean | Cleans the generated html documentation files. |
| fennec-test | Test suite for verifying engine functionality. | | fennec-test | Test suite for verifying engine functionality. |
<br> <a id="dependencies"></a>
Using an IDE will streamline the build process for you and add additional configuration | Dependency | Notes |
options. Eclipse, Visual Studio, and CLion provide built-in support for CMake. VSCode |-------------------|----------------------------------------------------------------------------------------------------------|
is also a viable IDE but involves some extra setup. | C/C++ Compiler | GCC/G++ is the compiler that fennec is designed around, however, Clang, MSVC, and MinGW may also be used |
| CMake | The build manager used by the engine |
| A build system | Any build system will work, however, `build.sh` uses Ninja by default. |
| A memory debugger | Any memory debugger will work, however, `test.sh` uses Valgrind by default. |
| Doxygen | Doxygen is required for building the documentation for fennec. This is an optional dependency |
| Graphviz | Graphviz is a required dependency for Doxygen |
<br> <br>
@ -84,22 +114,19 @@ is also a viable IDE but involves some extra setup.
for more info. for more info.
By default, the CMake generator By default, the CMake generator
used is Ninja, which requires Ninja to be installed. You can modify the used is Ninja, which requires Ninja to be installed.
build scripts to use another build manager, see the [CMake documentation You can modify the build scripts to use another build manager, see the [CMake documentation for available generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html).
for available generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html).
<br> <br>
<a id="building-on-windows"></a> <a id="building-on-windows"></a>
### Building on Windows ### Building on Windows
The bash script can be run natively on Windows when WSL is enabled. You do not The bash script can be run natively on Windows when WSL is enabled.
need to run the script in WSL, simply use the "bash" command in Command Prompt You do not need to run the script in WSL, simply use the "bash" command in Command Prompt or PowerShell.
or PowerShell. It requires CMake and a C/C++ compiler to be installed and The script will require the build [dependencies](#dependencies) installed and configured to be available on the `PATH` environment variable.
configured in the PATH environment variable.
Fore more details, [see this blog post](https://blogs.windows.com/windows-insider/2016/04/06/announcing-windows-10-insider-preview-build-14316/) Fore more details, [see this blog post](https://blogs.windows.com/windows-insider/2016/04/06/announcing-windows-10-insider-preview-build-14316/) for Windows Build 14316.
for Windows Build 14316.
Otherwise, follow the sequence of commands provided in the bash script. Otherwise, follow the sequence of commands provided in the bash script.
@ -159,4 +186,4 @@ whether the information displayed is correct.
There are some principles to keep in mind when contributing to fennec. There are some principles to keep in mind when contributing to fennec.
1. You must follow the style guide provided by the [GNU Coding Standard](https://www.gnu.org/prep/standards/html_node/Writing-C.html). 1. You must follow the style guide provided by the [GNU Coding Standard](https://www.gnu.org/prep/standards/html_node/Writing-C.html).
2. Any changes must allow all projects to be forward compatible with newer engine verisons. 2. Any changes must allow all projects to be forward compatible with newer engine verisons.

Binary file not shown.

View File

@ -784,7 +784,7 @@ SHOW_USED_FILES = YES
# (if specified). # (if specified).
# The default value is: YES. # The default value is: YES.
SHOW_FILES = YES SHOW_FILES = NO
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
# page. This will remove the Namespaces entry from the Quick Index and from the # page. This will remove the Namespaces entry from the Quick Index and from the
@ -1306,7 +1306,7 @@ CLANG_DATABASE_PATH =
# classes, structs, unions or interfaces. # classes, structs, unions or interfaces.
# The default value is: YES. # The default value is: YES.
ALPHABETICAL_INDEX = YES ALPHABETICAL_INDEX = NO
# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) # The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes)
# that should be ignored while generating the index headers. The IGNORE_PREFIX # that should be ignored while generating the index headers. The IGNORE_PREFIX

View File

@ -784,7 +784,7 @@ SHOW_USED_FILES = YES
# (if specified). # (if specified).
# The default value is: YES. # The default value is: YES.
SHOW_FILES = YES SHOW_FILES = NO
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
# page. This will remove the Namespaces entry from the Quick Index and from the # page. This will remove the Namespaces entry from the Quick Index and from the
@ -1306,7 +1306,7 @@ CLANG_DATABASE_PATH =
# classes, structs, unions or interfaces. # classes, structs, unions or interfaces.
# The default value is: YES. # The default value is: YES.
ALPHABETICAL_INDEX = YES ALPHABETICAL_INDEX = NO
# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) # The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes)
# that should be ignored while generating the index headers. The IGNORE_PREFIX # that should be ignored while generating the index headers. The IGNORE_PREFIX

View File

@ -38,21 +38,21 @@
namespace fennec namespace fennec
{ {
template<class T, class Alloc> template<class TypeT, class Alloc>
class dynarray class dynarray
{ {
public: public:
using element_t = T; using element_t = TypeT;
using alloc_t = Alloc; using alloc_t = Alloc;
/// ///
/// \brief Default Constructor, initializes an empty allocation. /// \brief Default Constructor, initializes an empty allocation.
dynarray() : _alloc(), _size(0) {} dynarray() : _alloc(8), _size(0) {}
/// ///
/// \breif Alloc Constructor, initalize empty allocation with allocator instance. /// \breif Alloc Constructor, initalize empty allocation with allocator instance.
/// \param alloc An allocator object to copy, for instances where the allocator needs to be initialized with some data. /// \param alloc An allocator object to copy, for instances where the allocator needs to be initialized with some data.
dynarray(const alloc_t& alloc) : _alloc(alloc), _size(0) {} dynarray(const alloc_t& alloc) : _alloc(8, alloc), _size(0) {}
/// ///
/// \brief Create an allocation with a size of `n` elements. All elements are initialized with the default constructor. /// \brief Create an allocation with a size of `n` elements. All elements are initialized with the default constructor.
@ -62,10 +62,16 @@ public:
for(; n > 0; --n, ++addr) { fennec::construct(addr); } for(; n > 0; --n, ++addr) { fennec::construct(addr); }
} }
dynarray(size_t n, const alloc_t& alloc) : _alloc(n, alloc), _size(n)
{
element_t* addr = _alloc.data();
for(; n > 0; --n, ++addr) { fennec::construct(addr); }
}
/// ///
/// \brief Create an allocation of size `n`, with each element constructed using the copy constructor /// \brief Create an allocation of size `n`, with each element constructed using the copy constructor
/// \brief n the number of elements /// \brief n the number of elements
dynarray(size_t n, const element_t& val) dynarray(size_t n, const TypeT& val)
{ {
element_t* addr = _alloc.data(); element_t* addr = _alloc.data();
for(; n > 0; --n, ++addr) { fennec::construct(addr, val); } for(; n > 0; --n, ++addr) { fennec::construct(addr, val); }
@ -84,7 +90,73 @@ public:
for(; n > 0; --n, ++addr) { fennec::destruct(addr); } for(; n > 0; --n, ++addr) { fennec::destruct(addr); }
} }
size_t size() const { return _size; }
size_t capacity() const { return _alloc.capacity(); }
TypeT& operator[](size_t i) { return _alloc.data()[i]; }
const TypeT& operator[](size_t i) const { return _alloc.data()[i]; }
void insert(size_t i, const TypeT& val)
{
// Grow if the size has reached the capacity of the allocation
if(_size == capacity()) _grow();
// Move the data if we are not inserting at the end of the array
if((i = fennec::min(i, _size) < _size) {
fennec::memmove(
_alloc.data() + i
, _alloc.data() + i + 1
, (_size - i) * sizeof(TypeT));
}
// Insert the element
fennec::construct(_alloc.data() + i, val);
}
void insert(size_t i, TypeT&& val)
{
// Grow if the size has reached the capacity of the allocation
if(_size == capacity()) _grow();
// Move the data if we are not inserting at the end of the array
if((i = fennec::min(i, _size) < _size) {
fennec::memmove(
_alloc.data() + i
, _alloc.data() + i + 1
, (_size - i) * sizeof(TypeT));
}
// Insert the element
fennec::construct(_alloc.data() + i, fennec::forward(val));
}
template<typename...ArgsT>
void emplace(size_t i, ArgsT...args)
{
// Grow if the size has reached the capacity of the allocation
if(_size == capacity()) _grow();
// Move the data if we are not inserting at the end of the array
if((i = fennec::min(i, _size) < _size) {
fennec::memmove(
_alloc.data() + i
, _alloc.data() + i + 1
, (_size - i) * sizeof(TypeT));
}
// Insert the element
fennec::construct(_alloc.data() + i, fennec::forward<ArgsT>(args)...);
}
void push_back(const TypeT& val) { insert(_size, val); }
void push_back(TypeT&& val) { insert(_size, fennec::forward(val)); }
template<typename...ArgsT> void emplace_back(ArgsT...args) { emplace(_size, fennec::forward<ArgsT>(args)...); }
private: private:
void _grow() const { _alloc.reallocate(_alloc.capacity() * 2); }
allocation<element_t, alloc_t> _alloc; allocation<element_t, alloc_t> _alloc;
size_t _size; size_t _size;
}; };

View File

@ -31,23 +31,30 @@
/// ///
/// \page page_fennec_documentation Documentation /// \page page_fennec_documentation Documentation
/// ///
/// \section page_documentation_contents Main Page /// \section page_fennec_documentation_pages Pages
/// 1. \ref introduction "Introduction" /// 1. \ref introduction "Introduction"
/// 2. \ref introduction "Building from Source" /// 1. \ref coding-standards "Coding Standards"
/// 1. \ref building-from-source "Building from Source" /// 2. \ref building-from-source "Building from Source"
/// 2. \ref building-from-terminal "Building from Terminal" /// 1. \ref building-from-terminal "Building from Terminal"
/// 3. \ref running-the-test-suite "Running the Test Suite" /// 2. \ref building-on-windows "Building on Windows"
/// 3. \ref usage "Usage" /// 3. \ref running-the-test-suite "Running the Test Suite"
/// 4. \ref contribution "Contribution" /// 4. \ref usage "Usage"
/// /// 5. \ref contribution "Contribution"
/// \section Libraries /// 6. \subpage page_fennec_libraries
/// \anchor libraries /// 1. \ref page_fennec_lang "C++ Language Library"
/// - \subpage page_fennec_lang /// 2. \ref page_fennec_math "Math Library"
/// - \subpage page_fennec_math
/// ///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) /// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
/// ///
///
/// \page page_fennec_libraries Libraries
///
/// | Library | Brief |
/// | :------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
/// | \subpage page_fennec_lang | Implementation for functions and classes related to the C++ Language, including base types, common utility functions, and metaprogramming templates |
/// | \subpage page_fennec_math | Implementation of math functions according to the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). Additional extensions are provided for other common math functions. |
#ifndef FENNEC_CORE_ENGINE_H #ifndef FENNEC_CORE_ENGINE_H
#define FENNEC_CORE_ENGINE_H #define FENNEC_CORE_ENGINE_H

View File

@ -29,8 +29,8 @@
/// ///
#ifndef CONDITIONAL_TYPES_H #ifndef FENNEC_LANG_CONDITIONAL_TYPES_H
#define CONDITIONAL_TYPES_H #define FENNEC_LANG_CONDITIONAL_TYPES_H
#include <fennec/lang/type_transforms.h> #include <fennec/lang/type_transforms.h>
#include <fennec/lang/types.h> #include <fennec/lang/types.h>
@ -106,4 +106,4 @@ using detect_t
} }
#endif //CONDITIONAL_TYPES_H #endif // FENNEC_LANG_CONDITIONAL_TYPES_H

View File

@ -29,7 +29,6 @@ namespace detail
{ {
// Nothing interesting to note here // Nothing interesting to note here
template<typename> struct __is_void : false_type {}; template<typename> struct __is_void : false_type {};
template<> struct __is_void<void> : true_type {}; template<> struct __is_void<void> : true_type {};

View File

@ -27,6 +27,9 @@
/// ///
/// ///
#ifndef FENNEC_LANG_FLOAT_H
#define FENNEC_LANG_FLOAT_H
#include <fennec/memory/bits.h> #include <fennec/memory/bits.h>
#define FLT_HAS_INFINITY 1 #define FLT_HAS_INFINITY 1
@ -80,3 +83,5 @@
#define DBL_SIGNALING_NAN fennec::bit_cast<double>(0x7ff4000000000000l) #define DBL_SIGNALING_NAN fennec::bit_cast<double>(0x7ff4000000000000l)
#define DBL_DENORM_MIN fennec::bit_cast<double>(0x1l) #define DBL_DENORM_MIN fennec::bit_cast<double>(0x1l)
#define DBL_ROUND_ERR fennec::bit_cast<double>(0x3fe0000000000000l) #define DBL_ROUND_ERR fennec::bit_cast<double>(0x3fe0000000000000l)
#endif // FENNEC_LANG_FLOAT_H

View File

@ -28,8 +28,8 @@
/// ///
/// ///
#ifndef LANG_H #ifndef FENNEC_LANG_H
#define LANG_H #define FENNEC_LANG_H
/// ///
/// \page page_fennec_lang C++ Language Library /// \page page_fennec_lang C++ Language Library
@ -38,4 +38,4 @@
/// ///
/// ///
#endif //LANG_H #endif // FENNEC_LANG_H

View File

@ -28,8 +28,8 @@
/// ///
/// ///
#ifndef UTILITY_H #ifndef FENNEC_LANG_UTILITY_H
#define UTILITY_H #define FENNEC_LANG_UTILITY_H
#include <fennec/lang/type_transforms.h> #include <fennec/lang/type_transforms.h>
@ -78,4 +78,4 @@ template<typename T> constexpr const remove_reference_t<T>& copy(T&& x) noexcept
} }
#endif //UTILITY_H #endif // FENNEC_LANG_UTILITY_H

View File

@ -16,8 +16,8 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FWD_H #ifndef FENNEC_MATH_DETAIL_FWD_H
#define FWD_H #define FENNEC_MATH_DETAIL_FWD_H
#include <fennec/math/detail/__types.h> #include <fennec/math/detail/__types.h>
@ -36,4 +36,4 @@ template<typename ScalarT, size_t RowsV, size_t ColsV> using mat
} }
#endif //FWD_H #endif // FENNEC_MATH_DETAIL_FWD_H

View File

@ -37,8 +37,8 @@
/// ///
/// ///
#ifndef MATRIX_H #ifndef FENNEC_MATH_MATRIX_H
#define MATRIX_H #define FENNEC_MATH_MATRIX_H
#include <fennec/math/detail/__fwd.h> #include <fennec/math/detail/__fwd.h>
@ -378,4 +378,4 @@ private:
} }
#endif //MATRIX_H #endif // FENNEC_MATH_MATRIX_H

View File

@ -30,6 +30,7 @@
#ifndef FENNEC_MATH_RELATIONAL_H #ifndef FENNEC_MATH_RELATIONAL_H
#define FENNEC_MATH_RELATIONAL_H #define FENNEC_MATH_RELATIONAL_H
#include <fennec/lang/types.h> #include <fennec/lang/types.h>
// TODO: Document // TODO: Document

View File

@ -67,4 +67,4 @@ using uint = unsigned int;
} }
#endif //TYPES_H #endif // FENNEC_MATH_SCALAR_H

View File

@ -28,8 +28,8 @@
/// ///
/// ///
#ifndef SWIZZLE_H #ifndef FENNEC_MATH_SWIZZLE_H
#define SWIZZLE_H #define FENNEC_MATH_SWIZZLE_H
#include <fennec/lang/sequences.h> #include <fennec/lang/sequences.h>
#include <fennec/math/swizzle_storage.h> #include <fennec/math/swizzle_storage.h>
@ -82,4 +82,4 @@ private:
} }
#endif //SWIZZLE_H #endif // FENNEC_MATH_SWIZZLE_H

View File

@ -17,8 +17,8 @@
// ===================================================================================================================== // =====================================================================================================================
#ifndef SWIZZLE_STORAGE_H #ifndef FENNEC_MATH_SWIZZLE_STORAGE_H
#define SWIZZLE_STORAGE_H #define FENNEC_MATH_SWIZZLE_STORAGE_H
namespace fennec namespace fennec
{ {
@ -54,4 +54,4 @@ struct swizzle_storage
} }
#endif //SWIZZLE_STORAGE_H #endif // FENNEC_MATH_SWIZZLE_STORAGE_H

View File

@ -17,8 +17,8 @@
// ===================================================================================================================== // =====================================================================================================================
#ifndef VECTOR_BASE_H #ifndef FENNEC_MATH_VECTOR_BASE_H
#define VECTOR_BASE_H #define FENNEC_MATH_VECTOR_BASE_H
#include <fennec/math/detail/__fwd.h> #include <fennec/math/detail/__fwd.h>
@ -95,4 +95,4 @@ using vector_base_type = typename vector_base_type_helper<ScalarT, SizeV>::Stora
} }
#endif //VECTOR_BASE_H #endif // FENNEC_MATH_VECTOR_BASE_H

View File

@ -17,8 +17,8 @@
// ===================================================================================================================== // =====================================================================================================================
#ifndef VECTOR_STORAGE_H #ifndef FENNEC_MATH_VECTOR_STORAGE_H
#define VECTOR_STORAGE_H #define FENNEC_MATH_VECTOR_STORAGE_H
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic" #pragma GCC diagnostic ignored "-Wpedantic"
@ -633,4 +633,4 @@ struct vector_storage<4, SwizzleGenT, DataT>
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif //VECTOR_STORAGE_H #endif // FENNEC_MATH_VECTOR_STORAGE_H

View File

@ -40,6 +40,12 @@ struct nothrow_t { explicit nothrow_t() noexcept { } };
template<typename TypeT> void construct(TypeT* ptr) template<typename TypeT> void construct(TypeT* ptr)
{ ptr->TypeT(); } { ptr->TypeT(); }
template<typename TypeT> void construct(TypeT* ptr, const TypeT& val)
{ ptr->TypeT(val); }
template<typename TypeT> void construct(TypeT* ptr, TypeT&& val)
{ ptr->TypeT(fennec::forward(val)); }
template<typename TypeT, typename...ArgsT> void construct(TypeT* ptr, ArgsT...args) template<typename TypeT, typename...ArgsT> void construct(TypeT* ptr, ArgsT...args)
{ ptr->TypeT(fennec::forward(args)...); } { ptr->TypeT(fennec::forward(args)...); }

View File

@ -16,8 +16,8 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FENNEC_LANG_POINTERS_H #ifndef FENNEC_MEMORY_POINTERS_H
#define FENNEC_LANG_POINTERS_H #define FENNEC_MEMORY_POINTERS_H
#include <fennec/lang/type_traits.h> #include <fennec/lang/type_traits.h>
@ -132,4 +132,4 @@ private:
} }
#endif // FENNEC_LANG_POINTERS_H #endif // FENNEC_MEMORY_POINTERS_H

View File

@ -55,9 +55,18 @@ int main(int, const char**)
flt << "///" << std::endl; flt << "///" << std::endl;
flt << "" << std::endl; flt << "" << std::endl;
flt << "#include <fennec/memory/bits.h>" << std::endl;
flt << "#ifndef FENNEC_LANG_FLOAT_H" << std::endl;
flt << "#define FENNEC_LANG_FLOAT_H" << std::endl;
flt << "" << std::endl; flt << "" << std::endl;
flt << "#include <fennec/memory/bits.h>" << std::endl;
flt << "" << std::endl;
// TODO: Fix this to generate info without using the c++stdlib for platforms without this available.
flt << "#define FLT_HAS_INFINITY " << std::dec << std::numeric_limits<float>::has_infinity << std::endl; flt << "#define FLT_HAS_INFINITY " << std::dec << std::numeric_limits<float>::has_infinity << std::endl;
flt << "#define FLT_HAS_QUIET_NAN " << std::dec << std::numeric_limits<float>::has_quiet_NaN << std::endl; flt << "#define FLT_HAS_QUIET_NAN " << std::dec << std::numeric_limits<float>::has_quiet_NaN << std::endl;
flt << "#define FLT_HAS_SIGNALING_NAN " << std::dec << std::numeric_limits<float>::has_signaling_NaN << std::endl; flt << "#define FLT_HAS_SIGNALING_NAN " << std::dec << std::numeric_limits<float>::has_signaling_NaN << std::endl;
@ -114,6 +123,10 @@ int main(int, const char**)
flt << "#define DBL_DENORM_MIN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::denorm_min() ) << "l)" << std::endl; flt << "#define DBL_DENORM_MIN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::denorm_min() ) << "l)" << std::endl;
flt << "#define DBL_ROUND_ERR " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::round_error() ) << "l)" << std::endl; flt << "#define DBL_ROUND_ERR " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::round_error() ) << "l)" << std::endl;
flt << "" << std::endl;
flt << "#endif // FENNEC_LANG_FLOAT_H" << std::endl;
flt.close(); flt.close();
return 0; return 0;

View File

@ -41,7 +41,7 @@ Debug()
cd ./build/debug cd ./build/debug
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
./test/fennec-test valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test
cd ../.. cd ../..
} }
@ -51,7 +51,7 @@ Release()
cd ./build/release cd ./build/release
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
./test/fennec-test valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test
cd ../.. cd ../..
} }
@ -61,7 +61,7 @@ RelWithDebInfo()
cd ./build/relwithdebinfo cd ./build/relwithdebinfo
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
./test/fennec-test valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test
cd ../.. cd ../..
} }
@ -71,7 +71,7 @@ MinSizeRel()
cd ./build/minsizerel cd ./build/minsizerel
cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
./test/fennec-test valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test
cd ../.. cd ../..
} }

View File

@ -12,6 +12,7 @@ add_executable(fennec-test main.cpp
tests/test_memory.h tests/test_memory.h
tests/test_math.h tests/test_math.h
tests/test_lang.h tests/test_lang.h
tests/lang/conditional_types.h
) )
target_link_libraries(fennec-test PRIVATE target_link_libraries(fennec-test PRIVATE

View File

@ -18,51 +18,23 @@
#include <iostream> #include <iostream>
#include "tests/test_scalar.h" #include "test.h"
#include "tests/test_vector.h"
#include "tests/test_geometric.h"
#include "tests/math/test_matrix.h"
#include <fennec/memory/bits.h> #include "tests/test_lang.h"
#include "tests/test_math.h"
#include "tests/test_memory.h"
int main(int, char **) int main(int, char **)
{ {
fennec_test_spacer(1); fennec_test_header("fennec-test, a program to execute unit tests for fennec");
fennec_test_section("fennec-test, a program to execute unit tests for fennec");
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_section(scalar tests =================================================================================); fennec_test_header("math library");
fennec_test_spacer(2); fennec_test_spacer(2);
fennec::test::fennec_test_math();
fennec::test::fennec_test_scalar();
fennec_test_spacer(3); fennec_test_spacer(3);
fennec_test_section(vector tests =================================================================================);
fennec_test_spacer(2);
fennec::test::fennec_test_vector();
fennec_test_spacer(3);
fennec_test_section(geometric tests ==============================================================================);
fennec_test_spacer(2);
fennec::test::fennec_test_geometric();
fennec_test_spacer(3);
fennec_test_section(matrix tests =================================================================================);
fennec_test_spacer(2);
fennec::test::fennec_test_matrix();
return 0; return 0;
} }

View File

@ -23,6 +23,7 @@
#include <ostream> #include <ostream>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <fennec/lang/limits.h> #include <fennec/lang/limits.h>
#include <fennec/math/common.h> #include <fennec/math/common.h>
#include <fennec/math/relational.h> #include <fennec/math/relational.h>
@ -90,7 +91,14 @@ inline void __fennec_test_run(const std::string& expression, ResultT result, Res
} }
#define fennec_test_run(Expression, Expected) __fennec_test_run(#Expression, Expression, Expected) #define fennec_test_run(Expression, Expected) __fennec_test_run(#Expression, Expression, Expected)
#define fennec_test_section(Section) std::cout << #Section << std::endl
#define fennec_test_header(Header) std::cout << std::string(80, '=') << std::endl \
<< (Header) << std::endl \
<< std::string(80, '=') << std::endl
#define fennec_test_subheader(Header) std::cout << (Header) << ' ' << std::string(80 - sizeof(Header), '=') << std::endl
#define fennec_test_section(Section) std::cout << (Section) << ' ' << std::string(80 - sizeof(Section), '-') << std::endl
#define fennec_test_spacer(Count) std::cout << std::string(Count, std::cout.widen('\n')) #define fennec_test_spacer(Count) std::cout << std::string(Count, std::cout.widen('\n'))
#endif // FENNEC_TEST_H #endif // FENNEC_TEST_H

View File

@ -0,0 +1,24 @@
// =====================================================================================================================
// fennec-test, a program to execute unit tests for fennec
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
#define FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
#endif // FENNEC_TEST_LANG_CONDITIONAL_TYPES_H

View File

@ -1,6 +1,6 @@
// ===================================================================================================================== // =====================================================================================================================
// fennec, a free and open source game engine // fennec-test, a program to execute unit tests for fennec
// Copyright (C) 2025 Medusa Slockbower // Copyright © 2025 Medusa Slockbower
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -17,8 +17,8 @@
// ===================================================================================================================== // =====================================================================================================================
#ifndef TEST_GEOMETRIC_H #ifndef FENNEC_TEST_GEOMETRIC_H
#define TEST_GEOMETRIC_H #define FENNEC_TEST_GEOMETRIC_H
#include <fennec/math/geometric.h> #include <fennec/math/geometric.h>
#include <fennec/math/trigonometric.h> #include <fennec/math/trigonometric.h>
@ -31,10 +31,8 @@ namespace fennec
namespace test namespace test
{ {
inline void fennec_test_geometric() inline void fennec_test_math_geometric()
{ {
fennec_test_section(geometric functions);
fennec_test_spacer(1); fennec_test_spacer(1);
fennec_test_run(fennec::dot(vec2(1, 2), vec2(1, 2)), 5.0f); fennec_test_run(fennec::dot(vec2(1, 2), vec2(1, 2)), 5.0f);
@ -77,4 +75,4 @@ inline void fennec_test_geometric()
} }
#endif // TEST_GEOMETRIC_H #endif // FENNEC_TEST_GEOMETRIC_H

View File

@ -1,6 +1,6 @@
// ===================================================================================================================== // =====================================================================================================================
// fennec, a free and open source game engine // fennec-test, a program to execute unit tests for fennec
// Copyright (C) 2025 Medusa Slockbower // Copyright © 2025 Medusa Slockbower
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@ namespace fennec
namespace test namespace test
{ {
inline void fennec_test_matrix() inline void fennec_test_math_matrix()
{ {

View File

@ -1,6 +1,6 @@
// ===================================================================================================================== // =====================================================================================================================
// fennec, a free and open source game engine // fennec-test, a program to execute unit tests for fennec
// Copyright (C) 2025 Medusa Slockbower // Copyright © 2025 Medusa Slockbower
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -17,8 +17,8 @@
// ===================================================================================================================== // =====================================================================================================================
#ifndef TEST_SCALAR_H #ifndef FENNEC_TEST_SCALAR_H
#define TEST_SCALAR_H #define FENNEC_TEST_SCALAR_H
#include <fennec/math/vector_traits.h> #include <fennec/math/vector_traits.h>
@ -30,9 +30,9 @@ namespace fennec
namespace test namespace test
{ {
inline void fennec_test_scalar() inline void fennec_test_math_scalar()
{ {
fennec_test_section(component_count); fennec_test_section("component_count");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -71,4 +71,4 @@ inline void fennec_test_scalar()
} }
#endif //TEST_SCALAR_H #endif // FENNEC_TEST_SCALAR_H

View File

@ -1,5 +1,5 @@
// ===================================================================================================================== // =====================================================================================================================
// fennec, a free and open source game engine // fennec-test, a program to execute unit tests for fennec
// Copyright © 2025 Medusa Slockbower // Copyright © 2025 Medusa Slockbower
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
@ -17,8 +17,8 @@
// ===================================================================================================================== // =====================================================================================================================
#ifndef TEST_VECTOR_H #ifndef FENNEC_TEST_VECTOR_H
#define TEST_VECTOR_H #define FENNEC_TEST_VECTOR_H
#include <iostream> #include <iostream>
@ -33,9 +33,9 @@ namespace fennec
namespace test namespace test
{ {
inline void fennec_test_vector() inline void fennec_test_math_vector()
{ {
fennec_test_section(component_count); fennec_test_section("component_count");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -146,7 +146,7 @@ inline void fennec_test_vector()
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_section(vec2 constructors); fennec_test_section("vec2 constructors");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -161,7 +161,7 @@ inline void fennec_test_vector()
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_section(vec2 swizzles); fennec_test_section("vec2 swizzles");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -172,7 +172,7 @@ inline void fennec_test_vector()
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_section(vec3 constructors); fennec_test_section("vec3 constructors");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -187,7 +187,7 @@ inline void fennec_test_vector()
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_section(vec3 swizzles); fennec_test_section("vec3 swizzles");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -233,7 +233,7 @@ inline void fennec_test_vector()
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_section(scalar-vector operations); fennec_test_section("scalar-vector operations");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -249,7 +249,7 @@ inline void fennec_test_vector()
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_section(vector-vector operations); fennec_test_section("vector-vector operations");
fennec_test_spacer(1); fennec_test_spacer(1);
@ -288,4 +288,4 @@ inline void fennec_test_vector()
} }
#endif //TEST_VECTOR_H #endif // FENNEC_TEST_VECTOR_H

View File

@ -1,8 +1,22 @@
// =====================================================================================================================
// fennec-test, a program to execute unit tests for fennec
// Copyright © 2025 Medusa Slockbower
// //
// Created by medusa on 6/8/25. // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef TEST_LANG_H #ifndef FENNEC_TEST_LANG_H
#define TEST_LANG_H #define FENNEC_TEST_LANG_H
#endif //TEST_LANG_H #endif // FENNEC_TEST_LANG_H

View File

@ -1,8 +1,62 @@
// =====================================================================================================================
// fennec-test, a program to execute unit tests for fennec
// Copyright © 2025 Medusa Slockbower
// //
// Created by medusa on 6/8/25. // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef TEST_MATH_H #ifndef FENNEC_TEST_MATH_H
#define TEST_MATH_H #define FENNEC_TEST_MATH_H
#endif //TEST_MATH_H #include "math/test_scalar.h"
#include "math/test_vector.h"
#include "math/test_matrix.h"
#include "math/test_geometric.h"
namespace fennec
{
namespace test
{
inline void fennec_test_math()
{
fennec_test_subheader("scalar tests");
fennec_test_spacer(2);
fennec_test_math_scalar();
fennec_test_spacer(3);
fennec_test_subheader("vector tests");
fennec_test_spacer(2);
fennec_test_math_vector();
fennec_test_spacer(3);
fennec_test_subheader("matrix tests");
fennec_test_spacer(2);
fennec_test_math_matrix();
fennec_test_spacer(3);
fennec_test_subheader("geometric tests");
fennec_test_spacer(2);
fennec_test_math_geometric();
fennec_test_spacer(3);
}
}
}
#endif // FENNEC_TEST_MATH_H

View File

@ -1,8 +1,22 @@
// =====================================================================================================================
// fennec-test, a program to execute unit tests for fennec
// Copyright © 2025 Medusa Slockbower
// //
// Created by medusa on 6/8/25. // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef TEST_MEMORY_H #ifndef FENNEC_TEST_MEMORY_H
#define TEST_MEMORY_H #define FENNEC_TEST_MEMORY_H
#endif //TEST_MEMORY_H #endif // FENNEC_TEST_MEMORY_H