Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6c86f1e
third-party: update vulkan headers & vma
dark-dylan-dev Sep 12, 2026
cae4d4c
add: GCC workaround
dark-dylan-dev Sep 14, 2026
36d4c94
cmake: Simplifying some things
dark-dylan-dev Sep 14, 2026
ed952b8
TODO: Remove vectors, matrices and quaternions as they have been done…
dark-dylan-dev Sep 14, 2026
30bec6e
add: some utilities
dark-dylan-dev Sep 14, 2026
7e8ba6b
window: make life easier
dark-dylan-dev Sep 14, 2026
5487fa9
add: Vulkan RHI (start of implementation)
dark-dylan-dev Sep 14, 2026
99c1096
linux: fix some compilation errors.
dark-dylan-dev Sep 14, 2026
ccc2b4b
Update the math library with a few utilities.
dark-dylan-dev Sep 27, 2026
a47d1ed
Update math library tests.
dark-dylan-dev Sep 27, 2026
58a1db9
fix(linux): clang 22 just wouldn't work.
dark-dylan-dev Sep 27, 2026
9511297
fix: use engine types
dark-dylan-dev Sep 27, 2026
47b9d07
formatting
dark-dylan-dev Sep 27, 2026
a3970d3
fun: add a color animation
dark-dylan-dev Sep 27, 2026
d6f8c30
feat: Preparing SIMD support.
dark-dylan-dev Sep 28, 2026
bbe5d7a
Fix the SimdConfig module to compile under Windows.
dark-dylan-dev Oct 8, 2026
2680147
SIMD: Make detection constexpr when possible and improve overall perf…
dark-dylan-dev Nov 7, 2026
edc4476
Stop the experimental STD module from CMake 4.5.0 onwards.
dark-dylan-dev Nov 14, 2026
44bdc32
Cleaning it up
dark-dylan-dev Nov 14, 2026
3a489cf
Don't need C++ extensions.
dark-dylan-dev Nov 15, 2026
b0e8cd6
SIMD: Added traits helpers, compile and link options.
dark-dylan-dev Nov 15, 2026
464d217
Fix linux compilation error.
dark-dylan-dev Nov 15, 2026
f772a6a
Not needed for now, and it was a bad way of doing it anyway.
dark-dylan-dev Nov 15, 2026
f0a899d
Was supposed to be a bugfix, then I added some QoL functions.
dark-dylan-dev Nov 16, 2026
515acd6
Oops, got confused with WindowsSockets
dark-dylan-dev Nov 16, 2026
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
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ cmake_minimum_required(VERSION 3.30 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# C++20 modules
include(Scripts/CMake/SetModuleUUID.cmake)
Expand All @@ -22,6 +23,9 @@ endif()

project(NexusEngine VERSION 0.0.1 LANGUAGES CXX)

option(NEXUS_RHI_VULKAN "Build Vulkan backend" ON)
option(NEXUS_RHI_DX12 "Build DirectX12 backend" OFF)

add_subdirectory(Source)

option(NEXUS_BUILD_TEST "Enable Nexus Engine tests" OFF)
Expand Down
27 changes: 17 additions & 10 deletions Scripts/CMake/SetModuleUUID.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

# See: https://discourse.cmake.org/t/cmake-experimental-cxx-import-std-value-history-and-state/15712/3
function(setModuleID)
set(CMAKE_CXX_SCAN_FOR_MODULES ON CACHE BOOL "" FORCE)
set(CMAKE_EXPERIMENTAL_CXX_MODULE_STD ON CACHE BOOL "" FORCE)
set(NEEDS_IMPORT_STD_GATE ON)

if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.4.0")
if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.5.0")
set(NEEDS_IMPORT_STD_GATE OFF)
elseif(CMAKE_VERSION VERSION_GREATER_EQUAL "4.4.0")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"f35a9ac6-8463-4d38-8eec-5d6008153e7d"
CACHE STRING "" FORCE
Expand All @@ -31,19 +32,25 @@ function(setModuleID)
"a9e1cf81-9932-4810-974b-6eccaf14e457"
CACHE STRING "" FORCE
)
elseif(CMAKE_VERSION VERSION_LESS "4.3.0")
else() # 4.0.3 <= version < 4.3.0
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444"
CACHE STRING "" FORCE
)
else()
message(FATAL_ERROR "Unsupported CMake version ${CMAKE_VERSION}")
endif()
else()
message(FATAL_ERROR "CMake CXX_MODULES not supported for version ${CMAKE_VERSION}")
message(FATAL_ERROR "import std requires CMake 3.30 or newer (found ${CMAKE_VERSION})")
endif()

set(CMAKE_CXX_MODULE_STD ON CACHE BOOL "" FORCE)
if(NEEDS_IMPORT_STD_GATE)
set(CMAKE_CXX_SCAN_FOR_MODULES ON CACHE BOOL "" FORCE)
set(CMAKE_CXX_MODULE_STD ON CACHE BOOL "" FORCE)
message(STATUS "import std enabled via experimental gate (CMake ${CMAKE_VERSION}, UUID: ${CMAKE_EXPERIMENTAL_CXX_IMPORT_STD})")
else()
message(STATUS "import std enabled (CMake ${CMAKE_VERSION})")
if(CMAKE_CXX_STDLIB_MODULES_JSON)
message(STATUS "C++ stdlib modules metadata: ${CMAKE_CXX_STDLIB_MODULES_JSON}")
endif()
endif()

message(STATUS "C++ modules enabled (CMake ${CMAKE_VERSION}, UUID: ${CMAKE_EXPERIMENTAL_CXX_IMPORT_STD})")
endfunction()
endfunction()
4 changes: 2 additions & 2 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ target_link_libraries(NexusEngine PRIVATE NexusThirdParty)
target_link_libraries(NexusEditor PRIVATE NexusEngine)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(NexusEngine PRIVATE "-lstdc++exp")
target_link_libraries(NexusEditor PRIVATE "-lstdc++exp")
target_link_libraries(NexusEngine PRIVATE stdc++exp)
target_link_libraries(NexusEditor PRIVATE stdc++exp)
endif()
56 changes: 54 additions & 2 deletions Source/Editor/Application/Private/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,65 @@ import NexusEngine;
namespace Nexus {

void Application::run() {
GetEngineTime();

Logger logger;
logger.LogInfo(std::format("Hello {}", Config::engineName));
Window window(std::format("{} v{}", Config::engineName, Config::engineVersion));
const auto title = std::format("{} v{}", Config::engineName, Config::engineVersion);
Window window(title);
auto m_CurrentWidth = window.GetWidth();
auto m_CurrentHeight = window.GetHeight();
const auto device = RHI::Device::Create();
const auto surface = device->CreateSurface(window);

while (!window.ShouldClose()) {
window.PollEvents();
window.DrawFrame();
int32 newWidth = window.GetWidth();
int32 newHeight = window.GetHeight();

if (newWidth != m_CurrentWidth || newHeight != m_CurrentHeight) {
m_CurrentWidth = newWidth;
m_CurrentHeight = newHeight;

if (newWidth > 0 && newHeight > 0) {
surface->Resize(newWidth, newHeight);
}
}

static uint32 frameCount = 0;
static float64 lastFpsUpdate = 0.0;
static float64 fps = 0.0;

const float64 t = GetEngineTime();

++frameCount;

if (const float64 elapsed = t - lastFpsUpdate; elapsed >= 0.25) {
fps = static_cast<float64>(frameCount) / elapsed;

frameCount = 0;
lastFpsUpdate = t;

window.SetTitle(std::format("{} - FPS: {:.1f}", title, fps));
}

int32 pixelWidth = window.GetPixelWidth();
int32 pixelHeight = window.GetPixelHeight();

// Skip rendering while minimized
if (pixelWidth == 0 || pixelHeight == 0) {
std::this_thread::sleep_for(std::chrono::microseconds(100));
continue;
}
surface->BeginFrame();
auto wave = [](const float64 x) { return 0.5 + 0.5 * std::sin(x); };

surface->ClearScreen(wave(t * 0.4) * 0.7 + wave(t * 0.13 + 1.0) * 0.3,
wave(t * 0.3 + 2.0) * 0.7 + wave(t * 0.17) * 0.3,
wave(t * 0.5 + 4.0) * 0.7 + wave(t * 0.11 + 2.0) * 0.3);
surface->EndFrame();
}
logger.LogInfo(std::format("Engine ran for {:.3f} seconds", GetEngineTime()));
}

} // namespace Nexus
9 changes: 1 addition & 8 deletions Source/Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: MIT

add_executable(NexusEditor main.cpp)
set_target_properties(NexusEditor PROPERTIES OUTPUT_NAME "Nexus Engine")

add_subdirectory(Application)

Expand All @@ -9,14 +10,6 @@ target_sources(NexusEditor PUBLIC
FILES NexusEditor.cppm
)

if(WIN32 AND MSVC AND CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
add_custom_command(
TARGET NexusEditor POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rm -f
"$<TARGET_FILE_DIR:NexusEditor>/NexusEditor.ilk"
)
endif()

if(WIN32)
target_sources(NexusEditor PRIVATE
${CMAKE_SOURCE_DIR}/Assets/Windows/NexusEditor.rc
Expand Down
1 change: 1 addition & 0 deletions Source/Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: MIT

add_library(NexusEngine SHARED)
set_target_properties(NexusEngine PROPERTIES OUTPUT_NAME Engine)
set_target_properties(NexusEngine PROPERTIES PREFIX "")

target_compile_definitions(NexusEngine PRIVATE NEXUS_ENGINE_BUILD)
Expand Down
76 changes: 76 additions & 0 deletions Source/Engine/Core/Math/Public/Mat/Mat.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export module NE.Engine.Math.Mat;

import NE.Engine.Core.Config;
import NE.Engine.Core.Types;
import NE.Engine.Math.Vec;
import NE.Engine.Math.Quaternion;

import std;

Expand Down Expand Up @@ -93,6 +95,70 @@ export namespace Nexus {
template <usize N = RowCount>
requires(RowCount == ColCount && N == RowCount)
constexpr Mat Inverse() const;

template <usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount)
static constexpr Mat Zero();

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat RotationX(U angleRadians);

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat RotationY(U angleRadians);

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat RotationZ(U angleRadians);

template <Numeric U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat Scale(const Vec3<U>& scale);

template <Numeric U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat Translate(const Vec3<U>& translation);

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat Rotate(const Quaternion<U>& rotation);

template <Numeric U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat TRS(const Vec3<U>& translation, const Quaternion<U>& rotation, const Vec3<U>& scale);

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat Perspective(U fovYRadians, U aspect, U nearPlane, U farPlane);

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat Ortho(U left, U right, U bottom, U top, U nearPlane, U farPlane);

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
static constexpr Mat LookAt(const Vec3<U>& eye, const Vec3<U>& target, const Vec3<U>& up);

template <Numeric U, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
constexpr Vec3<std::common_type_t<T, U>> MultiplyPoint(const Vec3<U>& point) const;

template <Numeric U, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
constexpr Vec3<std::common_type_t<T, U>> MultiplyVector(const Vec3<U>& vector) const;

template <usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
constexpr Vec3<T> ExtractPosition() const;

template <usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
constexpr Vec3<T> ExtractScale() const;

template <std::floating_point U = T, usize R = RowCount, usize C = ColCount>
requires(R == RowCount && C == ColCount && R == 4 && C == 4)
constexpr Quaternion<U> ExtractRotation() const;
};

template <Numeric T, Numeric U, usize RowCount, usize ColCount, typename Layout>
Expand Down Expand Up @@ -126,6 +192,16 @@ export namespace Nexus {
template <Numeric T, usize RowCount, usize ColCount, typename FromLayout, typename ToLayout>
constexpr Mat<T, RowCount, ColCount, ToLayout> MatCastLayout(const Mat<T, RowCount, ColCount, FromLayout>& mat);

template <Numeric T, Numeric U, usize RowCount, usize ColCount, typename Layout>
constexpr auto operator*(const Mat<T, RowCount, ColCount, Layout>& mat, const Vec<U, ColCount>& vec)
-> Vec<std::common_type_t<T, U>, RowCount>;

template <std::floating_point T>
constexpr T ToRadians(T degrees);

template <Numeric T, usize RowCount, usize ColCount, typename Layout>
constexpr bool ValidTRS(const Mat<T, RowCount, ColCount, Layout>& mat);

template <Numeric T, usize RowCount, usize ColCount>
using MatRowMajor = Mat<T, RowCount, ColCount, RowMajor>;

Expand Down
Loading