Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vscode/
.idea/

bits/
cmake-build-*/
bin/
build/

CMakeUserPresets.json
5 changes: 5 additions & 0 deletions CMakeGraphVizOptions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(GRAPHVIZ_GRAPH_NAME "Draconic Engine dependency graph")
set(GRAPHVIZ_GRAPH_HEADER "node [ fontsize = \"10\" ];")
set(GRAPHVIZ_EXECUTABLES FALSE)
set(GRAPHVIZ_EXTERNAL_LIBS FALSE)
set(GRAPHVIZ_IGNORE_TARGETS "CMAKE_.*;test_.*|.*_test$")
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 4.2)
#4.0: set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
#4.2: set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
project(DraconicEngine LANGUAGES C CXX)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

include(CTest)

add_subdirectory(engine/native)
50 changes: 50 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"version": 10,
"cmakeMinimumRequired": {
"major": 4,
"minor": 0,
"patch": 3
},
"configurePresets": [
{
"name": "default",
"hidden": true,
"displayName": "Default Config",
"description": "Base configuration",
"generator": "Ninja",
"graphviz": "graph/deps.dot",
"warnings": {
"unusedCli": false,
"dev": false
},
"cacheVariables": {
"CMAKE_EXPERIMENTAL_CXX_IMPORT_STD": "d0edc3af-4c50-42ea-a356-e2862fe7a444",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"CMAKE_CXX_STANDARD": "23",
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
"CMAKE_CXX_EXTENSIONS": "OFF",
"CMAKE_CXX_MODULE_STD": "1",
"CMAKE_CXX_FLAGS_INIT": "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"
}
},
{
"name": "release",
"inherits": "default",
"displayName": "Release",
"description": "Release configuration, including C# support",
Comment thread
Arctis-Fireblight marked this conversation as resolved.
"binaryDir": "${sourceDir}/build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "debug",
"inherits": "default",
"displayName": "Debug",
"description": "Debug configuration, including C# support",
"binaryDir": "${sourceDir}/build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
}
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Draconic Engine

<p align="center">
<a href="https://redotengine.org">
<img src="logo.png" width="400" alt="Draconic Engine Logo">
<a href="https://draconicengine.org">
<img src="assets/draconic_logo_text.png" width="400" alt="Draconic Engine Logo">
</a>
</p>

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
23 changes: 23 additions & 0 deletions cmake/Compiler.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
include_guard(GLOBAL)

include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT ERROR)

if (CMAKE_BUILD_TYPE STREQUAL "Release")
if(IPO_SUPPORTED)
message(STATUS "IPO / LTO enabled")
add_link_options(-flto)
else()
message(STATUS "IPO / LTO not supported: <${ERROR}>")
endif()
else()
message(STATUS "IPO / LTO disabled")
add_compile_definitions(DEBUG)
endif()
Comment thread
Arctis-Fireblight marked this conversation as resolved.

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
# TODO: Make SIMD level configurable or detect at runtime
add_compile_options(-mavx2 -mfma)
endif()
endif()
Comment thread
OldDev78 marked this conversation as resolved.
110 changes: 110 additions & 0 deletions cmake/Modules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
include_guard(GLOBAL)

set(NATIVE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/engine/native")

set(NATIVE_THIRD_PARTY_DIR "${NATIVE_SOURCE_DIR}/thirdparty")

if (BUILD_TESTING)
message(STATUS "Bootstrapping unit tests module boost.ut")
add_library(boost_ut_main "${NATIVE_THIRD_PARTY_DIR}/boost/ut_main.cpp")
target_sources(boost_ut_main
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS "${NATIVE_THIRD_PARTY_DIR}/boost"
FILES "${NATIVE_THIRD_PARTY_DIR}/boost/ut.cppm"
)
target_compile_features(boost_ut_main PUBLIC cxx_std_23)
endif()

function(add_modules_library)
cmake_parse_arguments(
MOD_LIB # prefix for all variables
"STATIC;SHARED" # tags for flags (only defined ones will be true)
"" # tags for single values
"" # tags for lists
"${ARGN}"
)

set(LIB_PATH ${ARGV0})

if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${LIB_PATH}")
message(FATAL_ERROR "Library directory ${LIB_PATH} not found")
endif()

set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${LIB_PATH}")

if (EXISTS "${LIB_DIR}/CMakeLists.txt") # allow recursion
add_subdirectory(${LIB_DIR})
endif()

string(MAKE_C_IDENTIFIER ${LIB_PATH} LIB_TARGET)
file(GLOB CPP_MODULE_FILES CONFIGURE_DEPENDS "${LIB_PATH}/*.cppm")
file(GLOB CPP_UNIT_TESTS CONFIGURE_DEPENDS "${LIB_PATH}/*.test.cpp")
file(GLOB CPP_SRC_FILES CONFIGURE_DEPENDS "${LIB_PATH}/*.cpp")
if (CPP_UNIT_TESTS)
list(REMOVE_ITEM CPP_SRC_FILES ${CPP_UNIT_TESTS})
endif()

if (MOD_LIB_SHARED)
message(STATUS "Adding shared modules library ${LIB_TARGET}")
add_library(${LIB_TARGET} SHARED)
else()
message(STATUS "Adding static modules library ${LIB_TARGET}")
add_library(${LIB_TARGET} STATIC)
endif()
target_compile_features(${LIB_TARGET} PUBLIC cxx_std_23)
target_include_directories(${LIB_TARGET} PUBLIC ${NATIVE_SOURCE_DIR})

target_sources(${LIB_TARGET}
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS ${LIB_DIR}
FILES ${CPP_MODULE_FILES}
)

target_sources(${LIB_TARGET} PRIVATE ${CPP_SRC_FILES})

if(CMAKE_TESTING_ENABLED)
foreach(UNIT_TEST_FILE ${CPP_UNIT_TESTS})
string(REPLACE "${LIB_DIR}/" "" UNIT_TEST_TARGET "${UNIT_TEST_FILE}")
string(REPLACE ".test.cpp" "_test" UNIT_TEST_TARGET ${UNIT_TEST_TARGET})
string(MAKE_C_IDENTIFIER ${UNIT_TEST_TARGET} UNIT_TEST_TARGET)
if (NOT UNIT_TEST_TARGET MATCHES ".*${LIB_TARGET}.*")
string(PREPEND UNIT_TEST_TARGET "${LIB_TARGET}_")
endif()
add_executable(${UNIT_TEST_TARGET} ${UNIT_TEST_FILE})
target_compile_features(${UNIT_TEST_TARGET} PUBLIC cxx_std_23)
target_link_libraries(${UNIT_TEST_TARGET} PRIVATE boost_ut_main ${LIB_TARGET})
message(STATUS "Unit test ${UNIT_TEST_TARGET}")
add_test(NAME ${UNIT_TEST_TARGET} COMMAND ${UNIT_TEST_TARGET} --reporter junit --out "Testing/${UNIT_TEST_TARGET}.xml")
endforeach()
endif()

endfunction()

function(target_link_modules)
cmake_parse_arguments(
MOD_LINK # prefix for all variables
"" # tags for flags (only defined ones will be true)
"" # tags for single values
"PRIVATE;PUBLIC" # tags for lists
"${ARGN}"
)

if (MOD_LINK_PUBLIC)
foreach(NAME ${MOD_LINK_PUBLIC})
set(DIR "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}")
string(MAKE_C_IDENTIFIER ${NAME} TARGET)
target_link_libraries(${ARGV0} PUBLIC ${TARGET})
endforeach()
endif()

if (MOD_LINK_PRIVATE)
foreach(NAME ${MOD_LINK_PRIVATE})
set(DIR "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}")
string(MAKE_C_IDENTIFIER ${NAME} TARGET)
target_link_libraries(${ARGV0} PRIVATE ${TARGET})
endforeach()
endif()

endfunction()
Empty file added docs/index.md
Empty file.
5 changes: 5 additions & 0 deletions engine/native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(Compiler)
include(Modules)

add_modules_library(core SHARED)
target_link_libraries(core PUBLIC definitions math)
3 changes: 3 additions & 0 deletions engine/native/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_modules_library(definitions)
add_modules_library(math)
target_link_libraries(math PUBLIC definitions)
3 changes: 3 additions & 0 deletions engine/native/core/core.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export module core;
export import core.defs;
export import core.math;
32 changes: 32 additions & 0 deletions engine/native/core/definitions/definitions.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export module core.defs;
export import core.version;
import std;

static_assert(__cplusplus >= 202302L, "Minimum of C++23 required.");

export namespace draco {

// Traits and Concepts

template <typename T>
concept arithmetic = std::is_arithmetic_v<T>;

template <typename T>
concept trivial = std::is_trivial_v<T>;

// Whether the default value of a type is just all-0 bytes.
// This can most commonly be exploited by using memset for these types instead of loop-construct.
// Must be explicitly specialized to mark a type as such.
template <typename T>
struct is_zero_constructible : std::false_type {};

template <typename T>
constexpr bool is_zero_constructible_v = is_zero_constructible<T>::value;

template <typename T>
concept zero_constructible = is_zero_constructible_v<T>;
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// Limit the depth of recursive algorithms when dealing with Array/Dictionary
constexpr int MAX_RECURSION = 100;

}
26 changes: 26 additions & 0 deletions engine/native/core/definitions/version.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export module core.version;
export import std;
import std.compat;

export namespace draco {

struct Version {
uint16_t major;
uint16_t minor;
uint16_t patch;
};

constexpr Version VERSION { .major = 2026, .minor = 0, .patch = 0 };
}

export namespace std {
template<> struct formatter<draco::Version> {
constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); // Accept any format spec (or parse custom ones)
}

auto format(const draco::Version& v, std::format_context& ctx) const {
return std::format_to(ctx.out(), "{}.{}.{}", v.major, v.minor, v.patch);
}
};
}
26 changes: 26 additions & 0 deletions engine/native/core/math/constants.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export module core.math.constants;
import std;

export namespace draco::math {
constexpr double SQRT2 = std::numbers::sqrt2_v<double>;
constexpr double SQRT3 = std::numbers::sqrt3_v<double>;
constexpr double SQRT12 = 1. / SQRT2;
constexpr double SQRT13 = 1. / SQRT3;
constexpr double LN2 = std::numbers::ln2_v<double>;
constexpr double LN10 = std::numbers::ln10_v<double>;
constexpr double PI = std::numbers::pi_v<double>;
constexpr double TAU = 2. * PI;
constexpr double E = std::numbers::e_v<double>;
constexpr double INF = std::numeric_limits<double>::infinity();
constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
constexpr double DB_CONVERSION_GAIN = 8.6858896380650365530225783783321;
constexpr double GAIN_CONVERSION_DB = 0.11512925464970228420089957273422;
constexpr double UINT32_MAX_D = 1. / static_cast<double>(std::numeric_limits<std::uint32_t>::max());
constexpr float UINT32_MAX_F = 1.f / static_cast<float>(std::numeric_limits<std::uint32_t>::max());

template<std::floating_point T> constexpr T CMP_EPSILON = T{0.000001};
template<std::floating_point T> constexpr T CMP_EPSILON2 = CMP_EPSILON<T> * CMP_EPSILON<T>;

template<std::floating_point T> constexpr T CMP_NORMALIZE_TOLERANCE = T{0.000001};
template<std::floating_point T> constexpr T CMP_POINT_IN_PLANE_EPSILON = T{0.00001};
}
Loading