Skip to content
Snippets Groups Projects
Commit bfa63006 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

remove conan from most builds

parent 70c09b18
No related branches found
No related tags found
No related merge requests found
Pipeline #3410 failed
...@@ -3,7 +3,7 @@ set(namespace "fggl") ...@@ -3,7 +3,7 @@ set(namespace "fggl")
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
option(FGGL_CONAN "Should we use conan to find missing dependencies?" ON) option(FGGL_CONAN "Should we use conan to find missing dependencies?" OFF)
set(CONAN_BUILD_TYPE "Debug") set(CONAN_BUILD_TYPE "Debug")
# Define the project # Define the project
...@@ -11,56 +11,12 @@ project(fggl ...@@ -11,56 +11,12 @@ project(fggl
VERSION 0.1 VERSION 0.1
DESCRIPTION "" DESCRIPTION ""
HOMEPAGE_URL "" HOMEPAGE_URL ""
LANGUAGES CXX) LANGUAGES C CXX)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# slightly cleaner conan support # slightly cleaner conan support
if ( FGGL_CONAN ) include(cmake/conan-wrangler.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/conan.cmake )
conan_cmake_configure(
REQUIRES
assimp/5.2.2
opengl/system
glfw/3.3.7
glad/0.1.35
glm/0.9.9.8
spdlog/1.10.0
freetype/2.11.1
bullet3/3.22a
openal/1.21.1
yaml-cpp/0.7.0
GENERATORS
cmake_find_package
cmake_find_package_multi
OPTIONS
glfw:shared=True
glad:gl_profile=core
glad:gl_version=4.5
glad:extensions="GL_ARB_get_program_binary,GL_ARB_shading_language_include"
)
if ( CMAKE_CONFIGURATION_TYPES )
foreach(TYPE ${CMAKE_CONFIGURATION_TYPES})
conan_cmake_autodetect( settings BUILD_TYPE ${TYPE} )
conan_cmake_install(
PATH_OR_REFERENCE .
BUILD missing
SETTINGS ${settings}
)
endforeach()
else()
conan_cmake_autodetect( settings BUILD_TYPE ${TYPE} )
conan_cmake_install(
PATH_OR_REFERENCE .
BUILD missing
SETTINGS ${settings}
)
endif()
endif()
# testing support # testing support
include(CTest) include(CTest)
...@@ -91,14 +47,11 @@ endif() ...@@ -91,14 +47,11 @@ endif()
## ##
# engine # engine
#add_subdirectory(vendor/imgui/) add_subdirectory( fggl )
add_subdirectory(fggl)
## G++ enable insane checks ## G++ enable insane checks
target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -fno-strict-aliasing -fno-strict-overflow ) target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -fno-strict-aliasing -fno-strict-overflow )
# extras # extras
#add_subdirectory(tests) #add_subdirectory(tests)
add_subdirectory(demo) add_subdirectory(demo)
...@@ -130,9 +83,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d") ...@@ -130,9 +83,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")
# generate and install export file # generate and install export file
install(EXPORT "${PROJECT_NAME}Targets" install(EXPORT "${PROJECT_NAME}Targets"
FILE "${PROJECT_NAME}Targets.cmake" FILE "${PROJECT_NAME}Targets.cmake"
NAMESPACE ${namespace}:: NAMESPACE ${namespace}::
DESTINATION cmake DESTINATION cmake
) )
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
...@@ -156,7 +109,7 @@ install(FILES ...@@ -156,7 +109,7 @@ install(FILES
) )
# generate the export targets for the build tree # generate the export targets for the build tree
export(EXPORT "${PROJECT_NAME}Targets" export(EXPORT "${PROJECT_NAME}Targets"
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Targets.cmake" FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${namespace}:: NAMESPACE ${namespace}::
) )
......
##
# Conan Wranger
# Integrate Conan when needed, don't bother when it's not
##
if ( FGGL_CONAN )
if ( CONAN_EXPORTED )
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
# download conan if not available
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
# download and enable dependencies
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_configure(
REQUIRES
opengl/system
openal/1.21.1
assimp/5.2.2
glfw/3.3.7
glad/0.1.35
glm/0.9.9.8
spdlog/1.10.0
freetype/2.11.1
bullet3/3.22a
yaml-cpp/0.7.0
GENERATORS
cmake_find_package
cmake_find_package_multi
OPTIONS
glfw:shared=True
glad:gl_profile=core
glad:gl_version=4.5
glad:extensions="GL_ARB_get_program_binary,GL_ARB_shading_language_include"
BASIC_SETUP
)
if ( CMAKE_CONFIGURATION_TYPES )
foreach(TYPE ${CMAKE_CONFIGURATION_TYPES})
conan_cmake_autodetect( settings BUILD_TYPE ${TYPE} )
conan_cmake_install(
PATH_OR_REFERENCE .
BUILD missing
SETTINGS ${settings}
)
endforeach()
else()
conan_cmake_autodetect( settings BUILD_TYPE ${TYPE} )
conan_cmake_install(
PATH_OR_REFERENCE .
BUILD missing
SETTINGS ${settings}
)
endif()
endif()
endif()
\ No newline at end of file
This diff is collapsed.
...@@ -94,7 +94,7 @@ int main(int argc, const char* argv[]) { ...@@ -94,7 +94,7 @@ int main(int argc, const char* argv[]) {
// -- should not be our problem - this is a broken api // -- should not be our problem - this is a broken api
auto window = windowing.createWindow("Demo Game"); auto window = windowing.createWindow("Demo Game");
window->make_graphics<fggl::gfx::OpenGL4>(); window->make_graphics<fggl::gfx::OpenGL4>();
window->fullscreen( true ); window->fullscreen( true );
app.setWindow( std::move(window) ); app.setWindow( std::move(window) );
......
# headers # headers
file(GLOB_RECURSE HEADER_LIST CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/include/fggl/**.hpp") file(GLOB_RECURSE HEADER_LIST CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/include/fggl/**.hpp")
# the fggl library itself # the fggl library itself
add_library(fggl ${HEADER_LIST}) add_library(fggl SHARED ${HEADER_LIST})
# we need to tell people using the library about our headers # we need to tell people using the library about our headers
target_include_directories(fggl target_include_directories(fggl
...@@ -68,8 +70,9 @@ target_link_libraries(fggl PUBLIC yaml-cpp) ...@@ -68,8 +70,9 @@ target_link_libraries(fggl PUBLIC yaml-cpp)
find_package(assimp) find_package(assimp)
target_link_libraries(${PROJECT_NAME} PUBLIC assimp) target_link_libraries(${PROJECT_NAME} PUBLIC assimp)
find_package(freetype) find_package(Freetype)
target_link_libraries(${PROJECT_NAME} PUBLIC freetype) target_link_libraries(${PROJECT_NAME} PUBLIC ${FREETYPE_LIBRARIES})
target_include_directories(${PROJECT_NAME} PUBLIC ${FREETYPE_INCLUDE_DIRS})
# Graphics backend # Graphics backend
add_subdirectory(gfx) add_subdirectory(gfx)
......
find_package( OpenAL REQUIRED ) find_package( OpenAL REQUIRED )
target_link_libraries(fggl PUBLIC OpenAL::OpenAL ) target_link_libraries( fggl PUBLIC openal )
target_sources(fggl target_sources(fggl
PRIVATE PRIVATE
......
...@@ -75,6 +75,9 @@ ...@@ -75,6 +75,9 @@
// ES 3.0 300 "#version 300 es" = WebGL 2.0 // ES 3.0 300 "#version 300 es" = WebGL 2.0
//---------------------------------------- //----------------------------------------
// JWR force GLAD to load
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
......
...@@ -5,7 +5,7 @@ find_package( glfw3 REQUIRED ) ...@@ -5,7 +5,7 @@ find_package( glfw3 REQUIRED )
include(CMakePrintHelpers) include(CMakePrintHelpers)
cmake_print_variables(GLFW_TARGETS) cmake_print_variables(GLFW_TARGETS)
target_link_libraries(fggl PUBLIC glfw::glfw ) target_link_libraries(fggl PUBLIC glfw )
target_sources(fggl target_sources(fggl
PRIVATE PRIVATE
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Sources # Sources
target_sources(fggl target_sources(fggl
PRIVATE PRIVATE
glad.c
backend.cpp backend.cpp
shader.cpp shader.cpp
renderer.cpp renderer.cpp
...@@ -11,7 +12,7 @@ target_sources(fggl ...@@ -11,7 +12,7 @@ target_sources(fggl
# Math # Math
# probably shouldn't be graphics dependent... # probably shouldn't be graphics dependent...
find_package( glm REQUIRED ) find_package( glm REQUIRED )
target_link_libraries(${PROJECT_NAME} PUBLIC glm::glm) target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm )
# OpenGL Backend # OpenGL Backend
if ( WIN32 ) if ( WIN32 )
...@@ -22,14 +23,10 @@ if ( WIN32 ) ...@@ -22,14 +23,10 @@ if ( WIN32 )
else() else()
find_package( OpenGL REQUIRED ) find_package( OpenGL REQUIRED )
include_directories( ${OPENGL_INCLUDE_DIR} ) include_directories( ${OPENGL_INCLUDE_DIR} )
target_link_libraries(${PROJECT_NAME} PUBLIC OpenGL::OpenGL) target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::OpenGL)
endif() endif()
# GLEW
find_package( glad CONFIG )
target_link_libraries(${PROJECT_NAME} PUBLIC glad::glad)
# FreeType # FreeType
#find_package(Freetype REQUIRED ) #find_package(Freetype REQUIRED )
#target_link_libraries(fggl PUBLIC Freetype::Freetype) #target_link_libraries(fggl PUBLIC Freetype::Freetype)
This diff is collapsed.
# bullet integration support # bullet integration support
find_package( Bullet REQUIRED ) find_package( Bullet REQUIRED )
target_link_libraries(fggl PUBLIC Bullet::Bullet ) target_link_libraries(fggl PUBLIC ${BULLET_LIBRARIES} )
target_include_directories(fggl PUBLIC ${BULLET_INCLUDE_DIR})
# #
target_sources(fggl target_sources(fggl
......
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2018 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE 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 AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* The master copy of khrplatform.h is maintained in the Khronos EGL
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
* The last semantic modification to khrplatform.h was at commit ID:
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by filing pull requests or issues on
* the EGL Registry repository linked above.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__)
# define KHRONOS_APICALL __attribute__((visibility("default")))
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
/*
* To support platform where unsigned long cannot be used interchangeably with
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
* unsigned long long or similar (this results in different C++ name mangling).
* To avoid changes for existing platforms, we restrict usage of intptr_t to
* platforms where the size of a pointer is larger than the size of long.
*/
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
#define KHRONOS_USE_INTPTR_T
#endif
#endif
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef KHRONOS_USE_INTPTR_T
typedef intptr_t khronos_intptr_t;
typedef uintptr_t khronos_uintptr_t;
#elif defined(_WIN64)
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
#endif
#if defined(_WIN64)
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */
...@@ -35,15 +35,69 @@ ...@@ -35,15 +35,69 @@
namespace fggl::data { namespace fggl::data {
static inline math::vec3 aiVec3ToFggl(aiVector3D vec) {
return {vec.x, vec.y, vec.z};
}
static inline math::vec2 aiVec2ToFggl(aiVector3D vec) {
return {vec.x, vec.y};
}
static void process_mesh(aiMesh* mesh, data::Mesh& meshRecord) {
// process vertices
std::vector< data::Mesh::IndexType > indexList;
for ( auto idx = 0; idx < mesh->mNumVertices; ++idx ) {
auto idxVal = meshRecord.pushVertex( {
.posititon = aiVec3ToFggl(mesh->mVertices[idx]),
.normal = aiVec3ToFggl( mesh->mNormals[idx] ),
.texPos = aiVec2ToFggl( mesh->mTextureCoords[0][idx] )
} );
indexList.push_back( idxVal );
}
if ( mesh->HasFaces() ) {
// if there is face data, that's our index list
for ( auto face = 0; face < mesh->mNumFaces; ++face ) {
auto &facePtr = mesh->mFaces[face];
meshRecord.pushIndex(indexList[facePtr.mIndices[0]]);
meshRecord.pushIndex(indexList[facePtr.mIndices[1]]);
meshRecord.pushIndex(indexList[facePtr.mIndices[2]]);
}
}
}
static void process_model(aiScene* scene, aiNode* node, data::Mesh& mesh) {
auto ptr = node->mMeshes;
for ( auto j=0; j < node->mNumMeshes; ++j ) {
for (int meshCount = 0; node->mNumMeshes; ++meshCount) {
auto aiMeshIdx = node->mMeshes[meshCount];
data::Mesh mesh;
auto* aiMesh = scene->mMeshes[aiMeshIdx];
process_mesh( aiMesh, mesh);
}
}
// process child meshes
for ( int i = 0; i < node->mNumChildren; ++i ) {
auto* child = node->mChildren[i];
process_model( child );
}
}
template<> template<>
bool fggl_deserialize(std::filesystem::path &data, StaticMesh *out) { bool fggl_deserialize(std::filesystem::path &data, StaticMesh *out) {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene* scene = importer.ReadFile( data.c_str(), aiProcess_Triangulate | aiProcess_FlipUVs ); const aiScene* scene = importer.ReadFile( data.c_str(), aiProcess_Triangulate | aiProcess_FlipUVs );
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) { // check if the import worked
if (scene == nullptr || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) {
return false; return false;
} }
// figure out the meshes
process_model( scene->mRootNode );
//TODO implement the rest of this //TODO implement the rest of this
return false; return false;
} }
......
...@@ -17,6 +17,7 @@ namespace fggl::data { ...@@ -17,6 +17,7 @@ namespace fggl::data {
math::vec3 posititon; math::vec3 posititon;
math::vec3 normal; math::vec3 normal;
math::vec3 colour; math::vec3 colour;
math::vec2 texPos;
inline static Vertex from_pos(math::vec3 pos) { inline static Vertex from_pos(math::vec3 pos) {
return { return {
......
...@@ -110,8 +110,6 @@ namespace fggl::gui { ...@@ -110,8 +110,6 @@ namespace fggl::gui {
std::map<const std::string, std::shared_ptr<FontFace>> m_cache; std::map<const std::string, std::shared_ptr<FontFace>> m_cache;
}; };
} // nmespace fggl::gui } // nmespace fggl::gui
#endif //FGGL_GUI_FONTS_HPP #endif //FGGL_GUI_FONTS_HPP
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment