Skip to content
Snippets Groups Projects
Verified Commit fa1d7162 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#26] Restructured asset_loader as module and added dependencies

parent 6f588a05
Branches
Tags
1 merge request!19Resolve "Asset Loading"
Showing
with 143 additions and 9 deletions
[submodule "lib/glfw"] [submodule "lib/glfw"]
path = lib/glfw path = lib/glfw
url = https://github.com/glfw/glfw.git url = https://github.com/glfw/glfw.git
[submodule "modules/asset_loader/lib/fx-gltf"]
path = modules/asset_loader/lib/fx-gltf
url = https://github.com/jessey-git/fx-gltf.git
[submodule "modules/asset_loader/lib/json"]
path = modules/asset_loader/lib/json
url = https://github.com/nlohmann/json.git
...@@ -36,12 +36,15 @@ if (vkcv_build_debug) ...@@ -36,12 +36,15 @@ if (vkcv_build_debug)
endif() endif()
endif() endif()
# add source files for compilation
include(${vkcv_config}/Sources.cmake)
# configure everything to use the required dependencies # configure everything to use the required dependencies
include(${vkcv_config}/Libraries.cmake) include(${vkcv_config}/Libraries.cmake)
# add modules as targets
add_subdirectory(modules)
# add source files for compilation
include(${vkcv_config}/Sources.cmake)
# set the compiler flags for the framework # set the compiler flags for the framework
set(CMAKE_CXX_FLAGS ${vkcv_flags}) set(CMAKE_CXX_FLAGS ${vkcv_flags})
......
...@@ -12,7 +12,4 @@ set(vkcv_sources ...@@ -12,7 +12,4 @@ set(vkcv_sources
${vkcv_include}/vkcv/Window.hpp ${vkcv_include}/vkcv/Window.hpp
${vkcv_source}/vkcv/Window.cpp ${vkcv_source}/vkcv/Window.cpp
${vkcv_include}/asset_loader/asset_loader.hpp
${vkcv_source}/asset_loader/main.cpp
) )
# Add new modules here:
add_subdirectory(asset_loader)
\ No newline at end of file
cmake_minimum_required(VERSION 3.16)
project(vkcv_asset_loader)
# setting c++ standard for the project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(vkcv_asset_loader_source ${PROJECT_SOURCE_DIR}/src)
set(vkcv_asset_loader_include ${PROJECT_SOURCE_DIR}/include)
set(vkcv_asset_loader_sources
${vkcv_asset_loader_include}/vkcv/asset/asset_loader.hpp
${vkcv_asset_loader_source}/vkcv/asset/asset_loader.cpp
)
set(vkcv_asset_loader_lib lib)
set(vkcv_asset_loader_lib_path ${PROJECT_SOURCE_DIR}/${vkcv_asset_loader_lib})
if (EXISTS "${vkcv_asset_loader_lib_path}/json")
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(${vkcv_asset_loader_lib}/json)
list(APPEND vkcv_asset_loader_libraries nlohmann_json::nlohmann_json)
else()
message(WARNING "NLOHMANN_JSON is required..! Update the submodules!")
endif ()
if (EXISTS "${vkcv_asset_loader_lib_path}/fx-gltf")
set(FX_GLTF_INSTALL OFF)
set(FX_GLTF_USE_INSTALLED_DEPS OFF)
set(BUILD_TESTING OFF)
add_subdirectory(${vkcv_asset_loader_lib}/fx-gltf)
list(APPEND vkcv_asset_loader_libraries fx-gltf)
else()
message(WARNING "FX-GLTF is required..! Update the submodules!")
endif ()
# adding source files to the project
add_library(vkcv_asset_loader STATIC ${vkcv_asset_loader_sources})
target_link_libraries(vkcv_asset_loader ${vkcv_asset_loader_libraries})
# add the own include directory for public headers
target_include_directories(vkcv_asset_loader BEFORE PUBLIC ${vkcv_asset_loader_include})
#pragma once #pragma once
/** /**
* @authors Trevor Hollmann * @authors Trevor Hollmann
* @file include/asset_loader/asset_loader.h * @file include/vkcv/asset/asset_loader.h
* @brief Interface of the asset loader module for the vkcv framework. * @brief Interface of the asset loader module for the vkcv framework.
*/ */
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
* These values can directly be given to vulkan when describing the content of * These values can directly be given to vulkan when describing the content of
* vertex buffers. */ * vertex buffers. */
namespace asset { namespace vkcv::asset {
/* With these enums, 0 is reserved to signal uninitialized or invalid data. */ /* With these enums, 0 is reserved to signal uninitialized or invalid data. */
......
Subproject commit f4f18f2017a049a23748c9c9aad42ba2de20bfd5
Subproject commit 0972f7ff0e651f09a306dba791cc42024b8642c1
#include "vkcv/asset/asset_loader.hpp"
#include <iostream>
#include <fx/gltf.h>
namespace vkcv::asset {
int loadMesh(const std::string &path, Mesh &mesh) {
std::vector<uint8_t> v;
if (fx::base64::TryDecode(path, v)) {
for (auto& ve : v) {
std::cout << ve << " ";
}
std::cout << std::endl;
} else {
std::cerr << "Schade!" << std::endl;
}
// TODO
return -1;
}
}
# Add new projects/examples here: # Add new projects/examples here:
add_subdirectory(first_triangle) add_subdirectory(first_triangle)
add_subdirectory(first_mesh)
first_mesh
\ No newline at end of file
cmake_minimum_required(VERSION 3.16)
project(first_mesh)
# setting c++ standard for the project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(first_mesh src/main.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(first_triangle PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(first_triangle PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
# including headers of dependencies and the VkCV framework
target_include_directories(first_mesh SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include})
# linking with libraries from all dependencies and the VkCV framework
target_link_libraries(first_mesh vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries})
#include <iostream>
#include <vkcv/asset/asset_loader.hpp>
int main(int argc, const char** argv) {
vkcv::asset::Mesh mesh;
int result = vkcv::asset::loadMesh("test.gltf", mesh);
if (result == 0) {
std::cout << "Mesh loading successful!" << std::endl;
} else {
std::cout << "Mesh loading failed: " << result << std::endl;
}
return 0;
}
first_triangle
\ No newline at end of file
...@@ -5,9 +5,18 @@ project(first_triangle) ...@@ -5,9 +5,18 @@ project(first_triangle)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project # adding source files to the project
add_executable(first_triangle src/main.cpp) add_executable(first_triangle src/main.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(first_triangle PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(first_triangle PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
# including headers of dependencies and the VkCV framework # including headers of dependencies and the VkCV framework
target_include_directories(first_triangle SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes}) target_include_directories(first_triangle SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes})
......
#include "asset_loader/asset_loader.hpp"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment