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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
.vs/

cmake-build-*

include/CAE/Generated/
78 changes: 30 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib")
set(PLUGIN_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(PATH_VERSION "${PROJECT_SOURCE_DIR}/include/CAE/Generated/Version.hpp")
set(PATH_VERSION "${PROJECT_BINARY_DIR}/include/CAE/Version.hpp")
set(TEMPLATE_PATH "${PROJECT_SOURCE_DIR}/cmake/config/Version.hpp.in")

add_compile_definitions(PLUGINS_DIR="${PLUGIN_DIR}")
Expand All @@ -34,64 +34,46 @@ include(MakeDoc)
include(ClangTidy)
include(ClangFormat)
include(CopyAssets)
include(CompileOptions)

find_package(nlohmann_json QUIET CONFIG)
if (NOT nlohmann_json_FOUND)
include(FetchContent)
FetchContent_Declare(
nlohmann-json
GIT_REPOSITORY "https://github.com/nlohmann/json.git"
GIT_TAG "v3.12.0"
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(nlohmann-json)
endif ()
find_package(glm QUIET CONFIG)
if (NOT glm_FOUND)
FetchContent_Declare(
glm
GIT_REPOSITORY "https://github.com/g-truc/glm.git"
GIT_TAG 1.0.3
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
set(GLM_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(glm)
endif ()

add_subdirectory(modules)
add_subdirectory(plugins)
add_subdirectory(tests)

include(FetchContent)
FetchContent_Declare(
nlohmann-json
GIT_REPOSITORY "https://github.com/nlohmann/json.git"
GIT_TAG "v3.12.0"
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(nlohmann-json)

add_executable(${PROJECT_NAME} ${SOURCES})
add_dependencies(${PROJECT_NAME} cae-modules)
target_include_directories(${PROJECT_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${PROJECT_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include" ${glm_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE
cae-modules
nlohmann_json::nlohmann_json
glm::glm
)
if (NOT WIN32 AND NOT APPLE)
set(WARNING_FLAGS
-Wall
-Wextra
-Wdeprecated-copy
-Wmisleading-indentation
-Wnull-dereference
-Woverloaded-virtual
-Wpedantic
-Wshadow
-Wsign-conversion
-Wnon-virtual-dtor
-Wunused
-Wcast-align
-Wno-padded
-Wconversion
-Wformat
-Winit-self
-Wmissing-include-dirs
-Wold-style-cast
-Wredundant-decls
-Wswitch-default
-Wundef
)
else ()
if (MSVC)
set(WARNING_FLAGS /W3)
else()
set(WARNING_FLAGS -Wno-error)
endif()
endif()
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE ${WARNING_FLAGS} /O2)
else ()
target_compile_options(${PROJECT_NAME} PRIVATE ${WARNING_FLAGS} -O3)
endif ()

copy_directory_to_target(
cae
Expand Down
15 changes: 11 additions & 4 deletions assets/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
"masterVolume": 0.8,
"muted": false
},
"camera": {
"position": [0.0, 0.0, 1.0],
"rotation": [0.0, 0.0, 0.0],
"direction": [0.0, 0.0, -1.0],
"movementSpeed": 2.5,
"rotationSpeed": 7.5,
"fov": 45,
"nearPlane": 0.1,
"farPlane": 1000.0
},
"log": {
"fps": false
},
Expand All @@ -13,10 +23,7 @@
"renderer": {
"vsync": false,
"frameRateLimit": 90,
"clearColor": [1.0, 1.0, 1.0, 1.0]
},
"user": {
"name": "User"
"clearColor": [0.2, 0.2, 0.2, 1.0]
},
"window": {
"name": "CAE - Cross API Engine",
Expand Down
6 changes: 2 additions & 4 deletions assets/shaders/glsl/texture.frag
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#version 450 core

layout(location = 0) in vec2 vUV;
layout(location = 0) in vec3 vColor;
layout(location = 0) out vec4 FragColor;

layout(binding = 0) uniform sampler2D uTexture;

void main()
{
FragColor = texture(uTexture, vUV);
FragColor = vec4(vColor, 1.0);
}
15 changes: 10 additions & 5 deletions assets/shaders/glsl/texture.vert
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#version 450 core

layout(location = 0) in vec2 aPos;
layout(location = 1) in vec2 aUV;
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec3 aColor;

layout(location = 0) out vec2 vUV;
layout(location = 0) out vec3 vColor;

layout(set = 0, binding = 0) uniform Matrices
{
mat4 uMVP;
};

void main()
{
gl_Position = vec4(aPos, 0.0, 1.0);
vUV = aUV;
vColor = aColor;
gl_Position = uMVP * vec4(aPos, 1.0);
}
113 changes: 113 additions & 0 deletions cmake/modules/CompileOptions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
add_library(cae-compile-options INTERFACE)

target_compile_features(cae-compile-options INTERFACE cxx_std_23)

option(CAE_STRICT_WARNINGS "Enable strict warning level" OFF)
option(CAE_ENABLE_SANITIZERS "Enable address and undefined sanitizers" OFF)
option(CAE_ENABLE_LTO "Enable LTO on final targets" OFF)

target_compile_options(cae-compile-options INTERFACE
# Strict warnings
$<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<BOOL:${CAE_STRICT_WARNINGS}>,$<NOT:$<PLATFORM_ID:Android,Emscripten,iOS>>>:
-Wall
-Wextra
-Wpedantic
-Wshadow
-Wconversion
-Wsign-conversion
-Wold-style-cast
-Woverloaded-virtual
-Wnull-dereference
-Wformat=2
-Wundef
-Wswitch-default
>
# mobile / web
$<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<BOOL:${CAE_STRICT_WARNINGS}>,$<PLATFORM_ID:Android,Emscripten,iOS>>:
-Wall
-Wextra
-Wshadow
-Wsign-conversion
-Wold-style-cast
>
# Default warnings
$<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<NOT:$<BOOL:${CAE_STRICT_WARNINGS}>>>:
-Wall
-Wextra
>
# MSVC
$<$<CXX_COMPILER_ID:MSVC>:
/W4
/permissive-
/Zc:__cplusplus
/Zc:preprocessor
>
)

# GCC / Clang
target_compile_options(cae-compile-options INTERFACE
$<$<AND:$<CONFIG:RelWithDebInfo>,$<CXX_COMPILER_ID:GNU,Clang,AppleClang>>:-O2>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU,Clang,AppleClang>>:-O0 -g>
)

# MSVC
target_compile_options(cae-compile-options INTERFACE
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:MSVC>>:/O2>
$<$<AND:$<CONFIG:RelWithDebInfo>,$<CXX_COMPILER_ID:MSVC>>:/O2 /Zi>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Od /Zi>
)

target_compile_definitions(cae-compile-options INTERFACE
$<$<CONFIG:Debug>:
CAE_DEBUG
>
)

if(CAE_ENABLE_SANITIZERS)
target_compile_options(cae-compile-options INTERFACE
$<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<NOT:$<PLATFORM_ID:Android,Emscripten,Windows>>>:
-fsanitize=address,undefined
>
)
target_link_options(cae-compile-options INTERFACE
$<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<NOT:$<PLATFORM_ID:Android,Emscripten,Windows>>>:
-fsanitize=address,undefined
>
)
endif()

function(cae_enable_lto target)
if (CAE_ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT CAE_LTO_SUPPORTED OUTPUT CAE_LTO_ERROR)
if (CAE_LTO_SUPPORTED)
set_property(TARGET ${target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "CAE: LTO not supported: ${CAE_LTO_ERROR}")
endif()
endif()
endfunction()

if (EMSCRIPTEN)
target_compile_definitions(cae-compile-options INTERFACE
CAE_PLATFORM_WEB
CAE_PLATFORM_EMSCRIPTEN
)
elseif (ANDROID)
target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_ANDROID)
elseif (APPLE)
if (IOS)
target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_IOS)
else()
target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_MACOS)
endif()
elseif (WIN32)
target_compile_definitions(cae-compile-options INTERFACE
CAE_PLATFORM_WINDOWS
NOMINMAX
WIN32_LEAN_AND_MEAN
)
elseif (UNIX)
target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_LINUX)
endif()

8 changes: 7 additions & 1 deletion include/CAE/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace cae
///
/// @brief Start the application
///
void start() const;
void start();

///
/// @brief Stop the application
Expand All @@ -75,10 +75,16 @@ namespace cae
///
static EngineConfig parseEngineConf(const std::string &path);

///
/// @brief main loop
///
void mainLoop();

std::unique_ptr<utl::PluginLoader> m_pluginLoader = nullptr;
std::unique_ptr<Engine> m_engine = nullptr;

AppConfig m_appConfig;
std::unordered_map<KeyCode, bool> m_keyState;

}; // class Application

Expand Down
3 changes: 2 additions & 1 deletion include/CAE/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include "CAE/Generated/Version.hpp"
#include "CAE/Version.hpp"

#include "Engine/Common.hpp"

Expand Down Expand Up @@ -47,6 +47,7 @@ namespace cae

namespace WINDOW
{
inline constexpr auto COCOA = "Cocoa";
inline constexpr auto GLFW = "GLFW";
inline constexpr auto WIN32_ = "Win32";
inline constexpr auto X11 = "X11";
Expand Down
1 change: 1 addition & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_subdirectory(Engine)
target_link_libraries(cae-modules INTERFACE
cae-utils
cae-engine
cae-compile-options
)
target_include_directories(cae-modules SYSTEM INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/Interfaces/include"
Expand Down
18 changes: 1 addition & 17 deletions modules/Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@ project(cae-engine
LANGUAGES CXX
)

include(FetchContent)

set(GLM_BUILD_TESTS OFF CACHE INTERNAL "")
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")

FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 1.0.3
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)

FetchContent_MakeAvailable(glm)

set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")

Expand All @@ -36,6 +21,7 @@ target_sources(${PROJECT_NAME}

target_link_libraries(${PROJECT_NAME} PRIVATE
cae-utils
cae-compile-options
glm::glm
)
target_include_directories(${PROJECT_NAME}
Expand All @@ -47,8 +33,6 @@ target_include_directories(${PROJECT_NAME}
"${CMAKE_SOURCE_DIR}/modules/Interfaces/include"
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23)
target_compile_options(${PROJECT_NAME} PRIVATE ${WARNING_FLAGS})
set_target_properties(${PROJECT_NAME} PROPERTIES
POSITION_INDEPENDENT_CODE ON
CXX_EXTENSIONS OFF
Expand Down
Loading
Loading