Skip to content

Commit

Permalink
Add: Textures and materials to gl_viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Nov 14, 2022
1 parent ef16e69 commit 699b118
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 77 deletions.
18 changes: 14 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL TRUE)

set(FASTGLTF_EXAMPLE_DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps")

# glad
add_library(fastgltf_examples_glad EXCLUDE_FROM_ALL)
target_include_directories(fastgltf_examples_glad PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/glad/include")
Expand All @@ -8,15 +10,15 @@ add_source_directory(TARGET fastgltf_examples_glad FOLDER "${CMAKE_CURRENT_SOURC
add_source_directory(TARGET fastgltf_examples_glad FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/deps/glad/include")

# glfw. We emulate parts of glfw's CMakeLists but don't want to include any examples or tests.
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/glfw")
if(EXISTS "${FASTGLTF_EXAMPLE_DEPS_DIR}/glfw")
message(STATUS "fastgltf: Found glfw")
# copied from glfw's CMakeLists. We seriously don't want any examples/tests/docs.
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
option(GLFW_INSTALL "Generate installation target" OFF)

add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/deps/glfw")
add_subdirectory("${FASTGLTF_EXAMPLE_DEPS_DIR}/glfw")

set_target_properties(glfw PROPERTIES EXCLUDE_FROM_ALL 1)
set_target_properties(update_mappings PROPERTIES EXCLUDE_FROM_ALL 1)
Expand All @@ -25,9 +27,9 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/glfw")
endif()

# glm
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/glm")
if(EXISTS "${FASTGLTF_EXAMPLE_DEPS_DIR}/glm")
message(STATUS "fastgltf: Found glm")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/deps/glm")
add_subdirectory("${FASTGLTF_EXAMPLE_DEPS_DIR}/glm")
add_library(glm::glm ALIAS glm)

if (TARGET glm_static)
Expand All @@ -40,4 +42,12 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/glm")
endif()
endif()

# stb
if(EXISTS "${FASTGLTF_EXAMPLE_DEPS_DIR}/stb")
message(STATUS "fastgltf: Found stb")
add_library(stb)
target_include_directories(stb PUBLIC "${FASTGLTF_EXAMPLE_DEPS_DIR}/stb")
target_sources(stb PUBLIC "${FASTGLTF_EXAMPLE_DEPS_DIR}/stb/stb_vorbis.c")
endif()

add_subdirectory(gl_viewer)
4 changes: 2 additions & 2 deletions examples/gl_viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
add_executable(fastgltf_gl_viewer EXCLUDE_FROM_ALL)
target_compile_features(fastgltf_gl_viewer PUBLIC cxx_std_17)
target_link_libraries(fastgltf_gl_viewer PRIVATE fastgltf fastgltf_examples_glad)
if (TARGET glfw::glfw AND TARGET glm::glm)
target_link_libraries(fastgltf_gl_viewer PRIVATE glfw::glfw glm::glm)
if (TARGET glfw::glfw AND TARGET glm::glm AND TARGET stb)
target_link_libraries(fastgltf_gl_viewer PRIVATE glfw::glfw glm::glm stb)
endif()

add_source_directory(TARGET fastgltf_gl_viewer FOLDER ".")
Loading

0 comments on commit 699b118

Please sign in to comment.