Skip to content

Commit

Permalink
gh-1: rework engine code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorOrachyov committed May 12, 2024
1 parent 620705a commit 71b0d93
Show file tree
Hide file tree
Showing 645 changed files with 967 additions and 625 deletions.
6 changes: 4 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"request": "launch",
"program": "${workspaceRoot}/build-Debug/template/template.exe",
"args": [
"--root_remap=${workspaceRoot}/template"
"--root_remap=${workspaceRoot}/template",
"--engine_remap=root://../engine/"
],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/build-Debug/template",
Expand All @@ -23,7 +24,8 @@
"request": "launch",
"program": "${workspaceRoot}/build-Release/template/template.exe",
"args": [
"--root_remap=${workspaceRoot}/template"
"--root_remap=${workspaceRoot}/template",
"--engine_remap=root://../engine/"
],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/build-Release/template",
Expand Down
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ add_subdirectory(deps)

add_subdirectory(engine)

###########################################################
# Plugins sources (standard plugins for engine)

add_subdirectory(plugins)

###########################################################
# Game template for test purposes and to kick-off new projects

Expand Down
54 changes: 6 additions & 48 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,9 @@
# egnine sources
file(GLOB_RECURSE ENGINE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/**/*.cpp ${CMAKE_CURRENT_LIST_DIR}/**/*.hpp)
###########################################################
# Engine runtime source code

# declare static engine library
add_library(wmoge STATIC ${ENGINE_SOURCES})
add_subdirectory(code)

# add interface to the engine for plugins
add_library(wmoge_headers INTERFACE)
###########################################################
# Plugins sources (standard plugins for engine)

# specify public include path, so user can reference engine files by modules names
target_include_directories(wmoge_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/)

# engine dependencies, which are also visible to the engine users
target_link_libraries(wmoge_headers INTERFACE cxxopts)
target_link_libraries(wmoge_headers INTERFACE tinyxml2)
target_link_libraries(wmoge_headers INTERFACE ryml)
target_link_libraries(wmoge_headers INTERFACE magic_enum)
target_link_libraries(wmoge_headers INTERFACE robin_hood)
target_link_libraries(wmoge_headers INTERFACE svector)
target_link_libraries(wmoge_headers INTERFACE yamc)

# generic functions to setup target
wmoge_target_iface_defs(wmoge_headers)

# engine headers target link to engine library
target_link_libraries(wmoge PUBLIC wmoge_headers)

# engine dependencies, private
target_link_libraries(wmoge PRIVATE glfw)
target_link_libraries(wmoge PRIVATE whereami)
target_link_libraries(wmoge PRIVATE stbimage)
target_link_libraries(wmoge PRIVATE filewatch)
target_link_libraries(wmoge PRIVATE lz4)
target_link_libraries(wmoge PRIVATE compressonator)
target_link_libraries(wmoge PRIVATE base64)
target_link_libraries(wmoge PRIVATE dynalo)
target_link_libraries(wmoge PRIVATE sha256)

# audio dependencies, private
target_link_libraries(wmoge PRIVATE OpenAL)
target_link_libraries(wmoge PRIVATE audio_file)

# lua scripting dependencies, private
target_link_libraries(wmoge PRIVATE lua_static)
target_link_libraries(wmoge PRIVATE LuaBridge)

# vulkan rendering backend related dependencies, private
target_link_libraries(wmoge PRIVATE volk)
target_link_libraries(wmoge PRIVATE vma)
target_link_libraries(wmoge PRIVATE glslang)
target_link_libraries(wmoge PRIVATE SPIRV)
add_subdirectory(plugins)
51 changes: 51 additions & 0 deletions engine/code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# egnine sources
file(GLOB_RECURSE ENGINE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/**/*.cpp ${CMAKE_CURRENT_LIST_DIR}/**/*.hpp)

# declare static engine library
add_library(wmoge STATIC ${ENGINE_SOURCES})

# add interface to the engine for plugins
add_library(wmoge_headers INTERFACE)

# specify public include path, so user can reference engine files by modules names
target_include_directories(wmoge_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/)

# engine dependencies, which are also visible to the engine users
target_link_libraries(wmoge_headers INTERFACE cxxopts)
target_link_libraries(wmoge_headers INTERFACE tinyxml2)
target_link_libraries(wmoge_headers INTERFACE ryml)
target_link_libraries(wmoge_headers INTERFACE magic_enum)
target_link_libraries(wmoge_headers INTERFACE robin_hood)
target_link_libraries(wmoge_headers INTERFACE svector)
target_link_libraries(wmoge_headers INTERFACE yamc)

# generic functions to setup target
wmoge_target_iface_defs(wmoge_headers)

# engine headers target link to engine library
target_link_libraries(wmoge PUBLIC wmoge_headers)

# engine dependencies, private
target_link_libraries(wmoge PRIVATE glfw)
target_link_libraries(wmoge PRIVATE whereami)
target_link_libraries(wmoge PRIVATE stbimage)
target_link_libraries(wmoge PRIVATE filewatch)
target_link_libraries(wmoge PRIVATE lz4)
target_link_libraries(wmoge PRIVATE compressonator)
target_link_libraries(wmoge PRIVATE base64)
target_link_libraries(wmoge PRIVATE dynalo)
target_link_libraries(wmoge PRIVATE sha256)

# audio dependencies, private
target_link_libraries(wmoge PRIVATE OpenAL)
target_link_libraries(wmoge PRIVATE audio_file)

# lua scripting dependencies, private
target_link_libraries(wmoge PRIVATE lua_static)
target_link_libraries(wmoge PRIVATE LuaBridge)

# vulkan rendering backend related dependencies, private
target_link_libraries(wmoge PRIVATE volk)
target_link_libraries(wmoge PRIVATE vma)
target_link_libraries(wmoge PRIVATE glslang)
target_link_libraries(wmoge PRIVATE SPIRV)
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions engine/asset/asset.cpp → engine/code/asset/asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ namespace wmoge {

Status yaml_read(IoContext& context, YamlConstNodeRef node, AssetId& id) {
WG_YAML_READ(context, node, id.m_name);
return StatusCode::Ok;
return WG_OK;
}
Status yaml_write(IoContext& context, YamlNodeRef node, const AssetId& id) {
WG_YAML_WRITE(context, node, id.m_name);
return StatusCode::Ok;
return WG_OK;
}
Status archive_read(IoContext& context, Archive& archive, AssetId& id) {
WG_ARCHIVE_READ(context, archive, id.m_name);
return StatusCode::Ok;
return WG_OK;
}
Status archive_write(IoContext& context, Archive& archive, const AssetId& id) {
WG_ARCHIVE_WRITE(context, archive, id.m_name);
return StatusCode::Ok;
return WG_OK;
}

AssetId::AssetId(const std::string& id) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace wmoge {
meta.deps = std::move(asset_file.deps);
meta.import_data = std::move(asset_file.import_data);

return StatusCode::Ok;
return WG_OK;
}

}// namespace wmoge
File renamed without changes.
16 changes: 8 additions & 8 deletions engine/asset/asset_ref.hpp → engine/code/asset/asset_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace wmoge {
return StatusCode::NoAsset;
}
ref = AssetRef<T>(ptr);
return StatusCode::Ok;
return WG_OK;
}

template<typename T>
Expand All @@ -85,7 +85,7 @@ namespace wmoge {
return StatusCode::NoAsset;
}
WG_YAML_WRITE(context, node, ref->get_id());
return StatusCode::Ok;
return WG_OK;
}

template<typename T>
Expand All @@ -97,7 +97,7 @@ namespace wmoge {
return StatusCode::NoAsset;
}
ref = AssetRef<T>(ptr);
return StatusCode::Ok;
return WG_OK;
}

template<typename T>
Expand All @@ -107,37 +107,37 @@ namespace wmoge {
return StatusCode::NoAsset;
}
WG_ARCHIVE_WRITE(context, archive, ref->get_id());
return StatusCode::Ok;
return WG_OK;
}

template<typename T>
Status yaml_read(IoContext& context, YamlConstNodeRef node, AssetRefWeak<T>& ref) {
AssetId id;
WG_YAML_READ(context, node, id);
ref = AssetRefWeak<T>(id);
return StatusCode::Ok;
return WG_OK;
}

template<typename T>
Status yaml_write(IoContext& context, YamlNodeRef node, const AssetRefWeak<T>& ref) {
AssetId id = ref;
WG_YAML_WRITE(context, node, id);
return StatusCode::Ok;
return WG_OK;
}

template<typename T>
Status archive_read(IoContext& context, Archive& archive, AssetRefWeak<T>& ref) {
AssetId id;
WG_ARCHIVE_READ(context, archive, id);
ref = AssetRefWeak<T>(id);
return StatusCode::Ok;
return WG_OK;
}

template<typename T>
Status archive_write(IoContext& context, Archive& archive, const AssetRefWeak<T>& ref) {
AssetId id = ref;
WG_ARCHIVE_WRITE(context, archive, id);
return StatusCode::Ok;
return WG_OK;
}

}// namespace wmoge
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace wmoge {
m_data.push_back(buffer);
}

return StatusCode::Ok;
return WG_OK;
}

Ref<Data> AudioStreamWav::get_channel_data(int channel) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace wmoge {
for (const auto& entry : vector) {
WG_ARCHIVE_WRITE(context, archive, entry);
}
return StatusCode::Ok;
return WG_OK;
}

template<typename T, std::size_t MinCapacity>
Expand All @@ -63,7 +63,7 @@ namespace wmoge {
for (int i = 0; i < size; i++) {
WG_ARCHIVE_READ(context, archive, vector[i]);
}
return StatusCode::Ok;
return WG_OK;
}

template<typename T, std::size_t MinCapacity>
Expand All @@ -73,7 +73,7 @@ namespace wmoge {
YamlNodeRef child = node.append_child();
WG_YAML_WRITE(context, child, value);
}
return StatusCode::Ok;
return WG_OK;
}

template<typename T, std::size_t MinCapacity>
Expand All @@ -85,7 +85,7 @@ namespace wmoge {
WG_YAML_READ(context, child, vector[element_id]);
element_id += 1;
}
return StatusCode::Ok;
return WG_OK;
}
#endif

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions engine/core/class.hpp → engine/code/core/class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace wmoge {
else if constexpr (sizeof...(Args) == 4)
(*target.*p_method)(*argvp[0], *argvp[1], *argvp[2], *argvp[3]);

return StatusCode::Ok;
return WG_OK;
};

auto ptr_method = std::make_shared<ClassMethod>(std::move(method));
Expand Down Expand Up @@ -307,7 +307,7 @@ namespace wmoge {
else if constexpr (sizeof...(Args) == 4)
res = (*target.*p_method)(*argvp[0], *argvp[1], *argvp[2], *argvp[3]);

return StatusCode::Ok;
return WG_OK;
};

auto ptr_method = std::make_shared<ClassMethod>(std::move(method));
Expand Down Expand Up @@ -340,7 +340,7 @@ namespace wmoge {
T* target = (T*) obj;
res = Var(*target.*p_field);

return StatusCode::Ok;
return WG_OK;
};

setter.m_args_values = {std::move(default_value)};
Expand All @@ -353,7 +353,7 @@ namespace wmoge {
T* target = (T*) obj;
(*target.*p_field) = std::move((F) (*argvp[0]));

return StatusCode::Ok;
return WG_OK;
};

auto ptr_getter = std::make_shared<ClassMethod>(std::move(getter));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion engine/core/data.cpp → engine/code/core/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace wmoge {
Status yaml_write(IoContext& context, YamlNodeRef node, const Ref<Data>& data) {
if (!data) {
node << "";
return StatusCode::Ok;
return WG_OK;
}

std::string encoded;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions engine/core/flat_map.hpp → engine/code/core/flat_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace wmoge {
WG_ARCHIVE_WRITE(context, archive, entry.first);
WG_ARCHIVE_WRITE(context, archive, entry.second);
}
return StatusCode::Ok;
return WG_OK;
}

template<typename K, typename V>
Expand All @@ -66,7 +66,7 @@ namespace wmoge {
WG_ARCHIVE_READ(context, archive, entry.second);
map.insert(std::move(entry));
}
return StatusCode::Ok;
return WG_OK;
}

template<typename K, typename V>
Expand All @@ -78,7 +78,7 @@ namespace wmoge {
WG_YAML_READ(context, child, entry);
map.insert(std::move(entry));
}
return StatusCode::Ok;
return WG_OK;
}

template<typename K, typename V>
Expand All @@ -88,7 +88,7 @@ namespace wmoge {
YamlNodeRef entry_child = node.append_child();
WG_YAML_WRITE(context, entry_child, entry);
}
return StatusCode::Ok;
return WG_OK;
}

#endif
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions engine/core/mask.hpp → engine/code/core/mask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace wmoge {
mask.set(flag);
}

return StatusCode::Ok;
return WG_OK;
}

template<typename T, int size>
Expand All @@ -127,7 +127,7 @@ namespace wmoge {
});

WG_YAML_WRITE(context, node, flags);
return StatusCode::Ok;
return WG_OK;
}

template<typename T, int size>
Expand Down
File renamed without changes.
Loading

0 comments on commit 71b0d93

Please sign in to comment.