Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0849127
Showing
49 changed files
with
1,102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Language: Cpp | ||
Standard: Cpp11 | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
UseTab: Always | ||
ColumnLimit: 120 | ||
AccessModifierOffset: 0 | ||
AlignEscapedNewlinesLeft: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackParameters: false | ||
BreakBeforeBinaryOperators: false | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializersBeforeComma: true | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
IndentCaseLabels: true | ||
IndentWrappedFunctionNames: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MaxEmptyLinesToKeep: 3 | ||
NamespaceIndentation: All | ||
PointerAlignment: Right | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: Never | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 4 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInContainerLiterals: true | ||
SpacesInParentheses: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
Checks: 'clang-diagnostic-*,clang-analyzer-*,clang-analyzer-alpha*,cppcoreguidelines-*,modernize-*,performance-*,readability-*,-readability-named-parameter,misc-*,google-runtime-int,llvm-include-order' | ||
|
||
WarningsAsErrors: '' | ||
HeaderFilterRegex: '' | ||
AnalyzeTemporaryDtors: false | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build*/ | ||
cmake-build*/ | ||
.idea/ | ||
.directory | ||
.kdev4/ | ||
*.kdev4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[submodule "3rdparty/boost.outcome"] | ||
path = 3rdparty/boost.outcome | ||
url = https://github.com/ned14/boost.outcome.git | ||
[submodule "3rdparty/GSL"] | ||
path = 3rdparty/GSL | ||
url = https://github.com/Microsoft/GSL.git | ||
[submodule "3rdparty/json"] | ||
path = 3rdparty/json | ||
url = https://github.com/nlohmann/json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
add_library(nlohmann_json INTERFACE) | ||
target_include_directories(nlohmann_json SYSTEM INTERFACE json/src) | ||
|
||
add_library(microsoft_gsl INTERFACE) | ||
target_include_directories(microsoft_gsl SYSTEM INTERFACE GSL/include) | ||
|
||
add_library(boost_outcome INTERFACE) | ||
target_include_directories(boost_outcome SYSTEM INTERFACE "boost.outcome/include") | ||
target_compile_definitions(boost_outcome INTERFACE BOOST_OUTCOME_ENABLE_ADVANCED) |
Submodule boost.outcome
added at
bdfae0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(gltfpp VERSION 1.0) | ||
|
||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") | ||
include(GenerateClangTidyTarget) | ||
include(ExternalProject) | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
if(UNIX OR MINGW) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -fdiagnostics-color=always") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -march=native") | ||
endif() | ||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmodules -fimplicit-module-maps -fbuiltin-module-map -Wdocumentation -Wthread-safety") | ||
endif() | ||
|
||
# find_package(Doxygen) | ||
# if(Doxygen_FOUND) | ||
# file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc) | ||
# if(DOXYGEN_DOT_FOUND) | ||
# set(USE_DOT "YES") | ||
# else() | ||
# set(USE_DOT "NO") | ||
# endif() | ||
# configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY) | ||
# add_custom_target(gltfpp_doc | ||
# ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" | ||
# SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" | ||
# DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" | ||
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc") | ||
# endif() | ||
|
||
add_subdirectory(3rdparty) | ||
add_subdirectory(gltfpp) | ||
enable_testing() | ||
add_subdirectory(test test EXCLUDE_FROM_ALL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
gltfpp | ||
====== | ||
gltfpp is a glTF 2.0 loader written in C++14 targeting desktop platforms and WebAssembly with a focus on ease of use, type safety and extensibility. | ||
|
||
**WORK IN PROGRESS!** This library is not finished yet. | ||
|
||
Requirements | ||
------------ | ||
- gcc >= 6 or clang >= 3.5 | ||
- CMake >= 3.8 | ||
|
||
When using clang, modules are used to decrease build time. | ||
|
||
Finished tasks | ||
------ | ||
- Parsing infrastructure (trivial properties can be parsed simply by declaring their fields) | ||
- Finished properties: `Asset` | ||
|
||
TODO | ||
---- | ||
- generalized (and type safe) enum parsing | ||
- deserialization of buffer data (embedded base64, GLB) | ||
- Networking (HTTP on desktop, XHR on WebAssembly), asynchronous loading | ||
- CMake support for Emscripten | ||
- Proper documentation | ||
- out of tree extensions? | ||
- a small viewer based on the loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
find_path(CATCH_INCLUDE_DIR NAMES catch.hpp) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Catch REQUIRED_VARS CATCH_INCLUDE_DIR) | ||
|
||
add_library(Catch::Catch INTERFACE IMPORTED) | ||
set_target_properties(Catch::Catch PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CATCH_INCLUDE_DIR}) | ||
|
||
mark_as_advanced(CATCH_INCLUDE_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function(add_clang_tidy_check target) | ||
get_target_property(rel_source_files ${target} SOURCES) | ||
|
||
foreach(f ${rel_source_files}) | ||
get_filename_component(abs_file ${f} ABSOLUTE) | ||
list(APPEND source_files ${abs_file}) | ||
endforeach() | ||
|
||
add_custom_target(${target}_check) | ||
add_custom_command(TARGET ${target}_check POST_BUILD | ||
COMMAND clang-tidy "-p=${PROJECT_BINARY_DIR}" | ||
"-config='${ARGV1}'" | ||
"-extra-arg='-fdiagnostics-color=always'" | ||
"-export-fixes='${CMAKE_CURRENT_BINARY_DIR}/${target}_suggested_fixes.yaml'" | ||
${source_files} | ||
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/${target}_suggested_fixes.yaml" | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
for x in $(find test/ gltfpp/ -name '*.cpp' -o -name '*.h'); do clang-format -style=file -i $x; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include "BufferView.h" | ||
#include <boost/hana/define_struct.hpp> | ||
|
||
namespace gltfpp { | ||
inline namespace v1 { | ||
struct Accessor { | ||
BOOST_HANA_DEFINE_STRUCT(Accessor, (BufferView, bufferView)); | ||
}; | ||
} // namespace v1 | ||
} // namespace gltfpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
#include "Error.h" | ||
#include <boost/hana/define_struct.hpp> | ||
#include <json.hpp> | ||
|
||
namespace gltfpp { | ||
inline namespace v1 { | ||
struct Channel { // TODO generic enum parsing | ||
BOOST_HANA_DEFINE_STRUCT(Channel | ||
|
||
); | ||
}; | ||
|
||
struct AnimationSampler { | ||
BOOST_HANA_DEFINE_STRUCT(AnimationSampler, | ||
(int, input), | ||
(int, output), | ||
(option<std::string>, interpolation), // TODO default = linear | ||
(option<nlohmann::json>, extensions), | ||
(option<nlohmann::json>, extras)); | ||
}; | ||
|
||
struct Animation { | ||
BOOST_HANA_DEFINE_STRUCT(Animation, | ||
(std::vector<Channel>, channels), | ||
(std::vector<AnimationSampler>, samplers), | ||
(option<std::string>, name), | ||
(option<nlohmann::json>, extensions), | ||
(option<nlohmann::json>, extras)); | ||
}; | ||
} // namespace v1 | ||
} // namespace gltfpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
#include "Error.h" | ||
#include <boost/hana/define_struct.hpp> | ||
#include <json.hpp> | ||
|
||
namespace gltfpp { | ||
inline namespace v1 { | ||
struct Asset { | ||
BOOST_HANA_DEFINE_STRUCT(Asset, | ||
(option<std::string>, copyright), | ||
(option<std::string>, generator), | ||
(option<std::string>, minVersion), | ||
(std::string, version), | ||
|
||
(option<nlohmann::json>, extensions), | ||
(option<nlohmann::json>, extras)); | ||
}; | ||
} // namespace v1 | ||
} // namespace gltfpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include "Error.h" | ||
#include "detail/Byte.h" | ||
#include <json.hpp> | ||
#include <vector> | ||
|
||
namespace gltfpp { | ||
inline namespace v1 { | ||
class Buffer { | ||
public: | ||
Buffer() = default; | ||
|
||
std::vector<byte> &operator*(); | ||
const std::vector<byte> &operator*() const; | ||
std::vector<byte> *operator->(); | ||
const std::vector<byte> *operator->() const; | ||
std::vector<byte> &get(); | ||
const std::vector<byte> &get() const; | ||
|
||
option<std::string> uri; | ||
option<std::string> name; | ||
option<nlohmann::json> extensions; | ||
option<nlohmann::json> extras; | ||
std::vector<byte> data; | ||
}; | ||
|
||
auto parse(Buffer &b); | ||
} // namespace v1 | ||
} // namespace gltfpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include "Buffer.h" | ||
#include "Error.h" | ||
#include <boost/hana/define_struct.hpp> | ||
#include <gsl/span> | ||
#include <json.hpp> | ||
|
||
namespace gltfpp { | ||
inline namespace v1 { | ||
struct BufferView { | ||
BufferView() | ||
: byteStride{0} { | ||
} | ||
|
||
enum Target { ARRAY_BUFFER = 34962, ELEMENT_ARRAY_BUFFER = 34963 }; | ||
|
||
BOOST_HANA_DEFINE_STRUCT(BufferView, | ||
(int, target), // TODO enum parsing | ||
(option<std::string>, name), | ||
(uint8_t, byteStride), | ||
(option<nlohmann::json>, extensions), | ||
(option<nlohmann::json>, extras)); | ||
gsl::span<const byte> span; | ||
const Buffer *buffer; | ||
}; | ||
|
||
auto parse(BufferView &); | ||
} // namespace v1 | ||
} // namespace gltfpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
#include <boost/hana/define_struct.hpp> | ||
|
||
namespace gltfpp { | ||
inline namespace v1 { | ||
struct Camera { | ||
BOOST_HANA_DEFINE_STRUCT(Camera); | ||
}; | ||
} // namespace v1 | ||
} // namespace gltfpp |
Oops, something went wrong.