Restore compatibility with Windows
This commit is contained in:
@@ -30,6 +30,14 @@ FetchContent_Declare(
|
||||
URL https://github.com/glfw/glfw/releases/download/3.3.8/glfw-3.3.8.zip
|
||||
)
|
||||
|
||||
# nlohmann-json
|
||||
FetchContent_Declare(
|
||||
json
|
||||
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(json)
|
||||
|
||||
option(GLFW_BUILD_DOCS "" OFF)
|
||||
option(GLFW_BUILD_EXAMPLES "" OFF)
|
||||
option(GLFW_BUILD_TESTS "" OFF)
|
||||
@@ -47,8 +55,21 @@ option(FX_GLTF_BUILD_TESTS "" OFF)
|
||||
option(FX_GLTF_INSTALL "" OFF)
|
||||
FetchContent_MakeAvailable(fx-gltf)
|
||||
|
||||
find_package(glm REQUIRED)
|
||||
find_package(spdlog REQUIRED)
|
||||
# glm
|
||||
FetchContent_Declare(
|
||||
glm
|
||||
URL https://github.com/g-truc/glm/archive/refs/tags/0.9.9.8.tar.gz
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(glm)
|
||||
|
||||
# glm
|
||||
FetchContent_Declare(
|
||||
spdlog
|
||||
URL https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(spdlog)
|
||||
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/lib)
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
@@ -20,17 +20,17 @@ add_library(fever_engine
|
||||
|
||||
target_compile_features(fever_engine PUBLIC cxx_std_20)
|
||||
target_include_directories(fever_engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_compile_definitions(fever_engine PRIVATE SPDLOG_FMT_EXTERNAL)
|
||||
|
||||
target_link_libraries(
|
||||
fever_engine PUBLIC
|
||||
glad
|
||||
glfw
|
||||
EnTT::EnTT
|
||||
fmt
|
||||
pthread
|
||||
spdlog
|
||||
glm
|
||||
fx-gltf::fx-gltf
|
||||
nlohmann_json::nlohmann_json
|
||||
stb
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ using namespace entt::literals;
|
||||
Controller::Controller()
|
||||
{
|
||||
std::filesystem::path document_path("WaterBottle/glTF-Binary/WaterBottle.glb");
|
||||
entt::hashed_string document_hash(document_path.c_str());
|
||||
entt::hashed_string document_hash(document_path.string().c_str());
|
||||
|
||||
entt::resource<Gltf> gltf_document =
|
||||
gltf_cache.load(document_hash, document_path).first->second;
|
||||
|
||||
@@ -128,7 +128,7 @@ void init_glad()
|
||||
// Initialize GLAD
|
||||
if (gladLoadGL(glfwGetProcAddress) == 0) {
|
||||
spdlog::critical("Failed to initialize GLAD");
|
||||
std::quick_exit(-1);
|
||||
std::abort();
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "shader.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fstream>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
@@ -78,7 +78,7 @@ static auto load_texture(fx::gltf::Texture const& texture,
|
||||
std::istreambuf_iterator<char>(),
|
||||
std::back_inserter(image_data));
|
||||
|
||||
entt::hashed_string const image_hash(image_path.c_str());
|
||||
entt::hashed_string const image_hash(image_path.string().c_str());
|
||||
|
||||
return image_cache.load(image_hash, image_data, colorFormat).first->second;
|
||||
}
|
||||
@@ -389,103 +389,6 @@ auto GltfLoader::operator()(std::filesystem::path const& document_path) -> resul
|
||||
nodes.push_back(node.second);
|
||||
}
|
||||
|
||||
// // Load scenes
|
||||
// std::vector<entt::resource<Scene>> scenes;
|
||||
// for (auto const& gltf_scene : gltf.scenes) {
|
||||
// // Get nodes by hash
|
||||
// std::vector<entt::resource<GltfNode>> nodes;
|
||||
// nodes.reserve(gltf_scene.nodes.size());
|
||||
|
||||
// for (auto node_id : gltf_scene.nodes) {
|
||||
// auto const& node = gltf.nodes.at(node_id);
|
||||
// entt::hashed_string node_hash(node.name.c_str());
|
||||
// nodes.push_back(gltf_node_cache[node_hash]);
|
||||
// }
|
||||
|
||||
// if (gltf_scene.name.empty()) {
|
||||
// spdlog::warn("glTF scene has no name.");
|
||||
// }
|
||||
|
||||
// // Spawn an entity for every node in scene
|
||||
// for (auto const& node : nodes) {
|
||||
// std::function<entt::entity(GltfNode const&, std::optional<entt::entity>)> spawn_node =
|
||||
// [this, &spawn_node](GltfNode const& node, std::optional<entt::entity> parent) {
|
||||
// auto entity = registry.create();
|
||||
// registry.emplace<Name>(entity, node.name);
|
||||
// registry.emplace<Transform>(entity, node.transform);
|
||||
// registry.emplace<GlobalTransform>(entity, GlobalTransform{});
|
||||
|
||||
// if (parent.has_value()) {
|
||||
// registry.emplace<Parent>(entity, Parent{.parent = parent.value()});
|
||||
// }
|
||||
|
||||
// std::vector<entt::entity> child_entities;
|
||||
|
||||
// auto mesh = node.mesh;
|
||||
// if (mesh.has_value()) {
|
||||
// for (auto const& primitive : mesh.value()->primitives) {
|
||||
// auto mesh_entity = registry.create();
|
||||
// registry.emplace<Parent>(mesh_entity, Parent{.parent = entity});
|
||||
// registry.emplace<Transform>(mesh_entity, Transform{});
|
||||
// registry.emplace<GlobalTransform>(mesh_entity, GlobalTransform{});
|
||||
// registry.emplace<entt::resource<Mesh>>(mesh_entity, primitive.mesh);
|
||||
// registry.emplace<entt::resource<Material>>(mesh_entity,
|
||||
// primitive.material);
|
||||
|
||||
// child_entities.push_back(mesh_entity);
|
||||
// }
|
||||
// }
|
||||
|
||||
// auto camera = node.camera;
|
||||
// if (camera.has_value()) {
|
||||
// auto perspective =
|
||||
// std::get<fx::gltf::Camera::Perspective>(camera.value().projection);
|
||||
// Camera::Perspective camera_perspective{.fov = perspective.yfov,
|
||||
// .aspect_ratio =
|
||||
// perspective.aspectRatio,
|
||||
// .near = perspective.znear,
|
||||
// .far = perspective.zfar};
|
||||
// registry.emplace<Camera>(entity, Camera{.projection = camera_perspective});
|
||||
// }
|
||||
|
||||
// // Spawn child nodes
|
||||
// for (auto const& child : node.children) {
|
||||
// auto child_entity = spawn_node(child, entity);
|
||||
// child_entities.push_back(child_entity);
|
||||
// }
|
||||
|
||||
// registry.emplace<Children>(entity, Children{.children = child_entities});
|
||||
// return entity;
|
||||
// };
|
||||
|
||||
// spawn_node(node, {});
|
||||
// }
|
||||
|
||||
// auto camera_view = registry.view<Camera const>();
|
||||
// if (camera_view.empty()) {
|
||||
// // Spawn default camera
|
||||
// auto entity = registry.create();
|
||||
// registry.emplace<Name>(entity, "Camera");
|
||||
// registry.emplace<Transform>(entity, Transform{.translation = Camera::DEFAULT_POSITION});
|
||||
// registry.emplace<GlobalTransform>(entity, GlobalTransform{});
|
||||
// registry.emplace<Camera>(entity, Camera{.projection = Camera::Perspective{}});
|
||||
// }
|
||||
|
||||
// entt::hashed_string scene_hash(gltf_scene.name.c_str());
|
||||
// entt::resource<Scene> scene_resource =
|
||||
// scene_cache.load(scene_hash, Scene{}).first->second;
|
||||
// scenes.push_back(scene_resource);
|
||||
// }
|
||||
|
||||
// // Default scene
|
||||
// auto default_scene = [&gltf, &scenes]() -> std::optional<entt::resource<Scene>> {
|
||||
// if (gltf.scene != -1) {
|
||||
// return scenes.at(gltf.scene);
|
||||
// }
|
||||
|
||||
// return {};
|
||||
// }();
|
||||
|
||||
return std::make_shared<Gltf>(Gltf{.materials = std::move(materials),
|
||||
.meshes = std::move(gltf_meshes),
|
||||
.nodes = std::move(nodes),
|
||||
|
||||
Reference in New Issue
Block a user