diff --git a/.gitmodules b/.gitmodules index 1c15c54..05d956f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "bx"] path = bx url = https://github.com/bkaradzic/bx.git +[submodule "bimg"] + path = bimg + url = https://github.com/bkaradzic/bimg.git diff --git a/CMakeLists.txt b/CMakeLists.txt index f2d008f..e3d97a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,9 @@ option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF if( NOT BX_DIR ) set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx." ) endif() +if( NOT BIMG_DIR ) + set( BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg." ) +endif() if( NOT BGFX_DIR ) set( BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx." ) endif() @@ -40,6 +43,7 @@ endif() include( cmake/shared.cmake ) include( cmake/bx.cmake ) +include( cmake/bimg.cmake ) include( cmake/bgfx.cmake ) if( BGFX_BUILD_TOOLS ) @@ -55,6 +59,10 @@ if( BGFX_INSTALL ) install( TARGETS bx DESTINATION lib ) install( DIRECTORY ${BX_DIR}/include DESTINATION . ) + # install bimg + install( TARGETS bimg DESTINATION lib ) + install( DIRECTORY ${BIMG_DIR}/include DESTINATION . ) + # install bgfx install( TARGETS bgfx DESTINATION lib ) install( DIRECTORY ${BGFX_DIR}/include DESTINATION . ) diff --git a/bgfx b/bgfx index 31312f8..c50cc84 160000 --- a/bgfx +++ b/bgfx @@ -1 +1 @@ -Subproject commit 31312f897d5f409ace4280bec57f06b65bd64b67 +Subproject commit c50cc8493fdd51d6deaf604b9f10f2b827f77401 diff --git a/bimg b/bimg new file mode 160000 index 0000000..342b0ed --- /dev/null +++ b/bimg @@ -0,0 +1 @@ +Subproject commit 342b0ed11f771fc3157efdd37a6450267fc064f3 diff --git a/bx b/bx index ac80145..96e8c66 160000 --- a/bx +++ b/bx @@ -1 +1 @@ -Subproject commit ac80145c2f6e65d68b30880f942ad3071ba888b7 +Subproject commit 96e8c66a60513aa5e609086f9a356aba0e825e6f diff --git a/cmake/3rdparty/edtaa3.cmake b/cmake/3rdparty/edtaa3.cmake new file mode 100644 index 0000000..d6a4855 --- /dev/null +++ b/cmake/3rdparty/edtaa3.cmake @@ -0,0 +1,19 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +if( TARGET edtaa3 ) + return() +endif() + +file( GLOB EDTAA3_SOURCES ${BIMG_DIR}/3rdparty/edtaa3/*.cpp ${BIMG_DIR}/3rdparty/edtaa3/*.h ) + +add_library( edtaa3 STATIC ${EDTAA3_SOURCES} ) +target_include_directories( edtaa3 PUBLIC ${BIMG_DIR}/3rdparty ) +set_target_properties( edtaa3 PROPERTIES FOLDER "bgfx/3rdparty" ) diff --git a/cmake/3rdparty/etc1.cmake b/cmake/3rdparty/etc1.cmake new file mode 100644 index 0000000..66970ac --- /dev/null +++ b/cmake/3rdparty/etc1.cmake @@ -0,0 +1,19 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +if( TARGET etc1 ) + return() +endif() + +file( GLOB ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/*.cpp ${BIMG_DIR}/3rdparty/etc1/*.h ) + +add_library( etc1 STATIC ${ETC1_SOURCES} ) +target_include_directories( etc1 PUBLIC ${BIMG_DIR}/3rdparty ) +set_target_properties( etc1 PROPERTIES FOLDER "bgfx/3rdparty" ) diff --git a/cmake/3rdparty/etc2.cmake b/cmake/3rdparty/etc2.cmake new file mode 100644 index 0000000..7d4de7a --- /dev/null +++ b/cmake/3rdparty/etc2.cmake @@ -0,0 +1,20 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +if( TARGET etc2 ) + return() +endif() + +file( GLOB ETC2_SOURCES ${BIMG_DIR}/3rdparty/etc2/*.cpp ${BIMG_DIR}/3rdparty/etc2/*.h ) + +add_library( etc2 STATIC ${ETC2_SOURCES} ) +target_include_directories( etc2 PUBLIC ${BIMG_DIR}/3rdparty ) +set_target_properties( etc2 PROPERTIES FOLDER "bgfx/3rdparty" ) +target_link_libraries( etc2 PUBLIC bx ) diff --git a/cmake/3rdparty/libsquish.cmake b/cmake/3rdparty/libsquish.cmake new file mode 100644 index 0000000..57f203d --- /dev/null +++ b/cmake/3rdparty/libsquish.cmake @@ -0,0 +1,19 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +if( TARGET squish ) + return() +endif() + +file( GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/libsquish/*.cpp ${BIMG_DIR}/3rdparty/libsquish/*.h ${BIMG_DIR}/3rdparty/libsquish/*.inl ) + +add_library( squish STATIC ${SQUISH_SOURCES} ) +target_include_directories( squish PUBLIC ${BIMG_DIR}/3rdparty ) +set_target_properties( squish PROPERTIES FOLDER "bgfx/3rdparty" ) diff --git a/cmake/3rdparty/nvtt.cmake b/cmake/3rdparty/nvtt.cmake new file mode 100644 index 0000000..f7f72a2 --- /dev/null +++ b/cmake/3rdparty/nvtt.cmake @@ -0,0 +1,33 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +if( TARGET nvtt ) + return() +endif() + +file( + GLOB + NVTT_SOURCES + ${BIMG_DIR}/3rdparty/nvtt/bc6h/*.cpp + ${BIMG_DIR}/3rdparty/nvtt/bc6h/*.h + ${BIMG_DIR}/3rdparty/nvtt/bc7/*.cpp + ${BIMG_DIR}/3rdparty/nvtt/bc7/*.h + ${BIMG_DIR}/3rdparty/nvtt/nvcore/*.h + ${BIMG_DIR}/3rdparty/nvtt/nvcore/*.inl + ${BIMG_DIR}/3rdparty/nvtt/nvmath/*.cpp + ${BIMG_DIR}/3rdparty/nvtt/nvmath/*.h + ${BIMG_DIR}/3rdparty/nvtt/*.cpp + ${BIMG_DIR}/3rdparty/nvtt/*.h +) + +add_library( nvtt STATIC ${NVTT_SOURCES} ) +target_include_directories( nvtt PUBLIC ${BIMG_DIR}/3rdparty ${BIMG_DIR}/3rdparty/nvtt ) +set_target_properties( nvtt PROPERTIES FOLDER "bgfx/3rdparty" ) +target_link_libraries( nvtt PUBLIC bx ) diff --git a/cmake/3rdparty/pvrtc.cmake b/cmake/3rdparty/pvrtc.cmake new file mode 100644 index 0000000..fb3c1b5 --- /dev/null +++ b/cmake/3rdparty/pvrtc.cmake @@ -0,0 +1,19 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +if( TARGET pvrtc ) + return() +endif() + +file( GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/pvrtc/*.cpp ${BIMG_DIR}/3rdparty/pvrtc/*.h ) + +add_library( pvrtc STATIC ${SQUISH_SOURCES} ) +target_include_directories( pvrtc PUBLIC ${BIMG_DIR}/3rdparty ) +set_target_properties( pvrtc PROPERTIES FOLDER "bgfx/3rdparty" ) diff --git a/cmake/bgfx.cmake b/cmake/bgfx.cmake index 61d1f4d..0e09f77 100755 --- a/cmake/bgfx.cmake +++ b/cmake/bgfx.cmake @@ -41,8 +41,8 @@ endif() target_include_directories( bgfx PRIVATE ${BGFX_DIR}/3rdparty ${BGFX_DIR}/3rdparty/dxsdk/include ${BGFX_DIR}/3rdparty/khronos ) target_include_directories( bgfx PUBLIC ${BGFX_DIR}/include ) -# bgfx depends on bx -target_link_libraries( bgfx PUBLIC bx ) +# bgfx depends on bx and bimg +target_link_libraries( bgfx PUBLIC bx bimg ) # ovr support if( BGFX_USE_OVR ) diff --git a/cmake/bimg.cmake b/cmake/bimg.cmake new file mode 100644 index 0000000..c80803f --- /dev/null +++ b/cmake/bimg.cmake @@ -0,0 +1,38 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +# Third party libs +include( cmake/3rdparty/edtaa3.cmake ) +include( cmake/3rdparty/etc1.cmake ) +include( cmake/3rdparty/etc2.cmake ) +include( cmake/3rdparty/libsquish.cmake ) +include( cmake/3rdparty/nvtt.cmake ) +include( cmake/3rdparty/pvrtc.cmake ) + +# Ensure the directory exists +if( NOT IS_DIRECTORY ${BIMG_DIR} ) + message( SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}" ) + return() +endif() + +# Grab the bimg source files +file( GLOB BIMG_SOURCES ${BIMG_DIR}/src/*.cpp ) + +# Create the bimg target +add_library( bimg STATIC ${BIMG_SOURCES} ) + +# Add include directory of bimg +target_include_directories( bimg PUBLIC ${BIMG_DIR}/include ) + +# bimg dependencies +target_link_libraries( bimg bx edtaa3 etc1 etc2 squish nvtt pvrtc ) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties( bimg PROPERTIES FOLDER "bgfx" ) diff --git a/cmake/examples.cmake b/cmake/examples.cmake index ee304e8..f7925bf 100755 --- a/cmake/examples.cmake +++ b/cmake/examples.cmake @@ -186,3 +186,4 @@ add_example( 29-debugdraw ) add_example( 30-picking ) add_example( 31-rsm ) add_example( 32-particles ) +#add_example( 33-pom ) # not currently working in Direct3D diff --git a/cmake/tools/shaderc.cmake b/cmake/tools/shaderc.cmake index 00a78f0..3711bf2 100644 --- a/cmake/tools/shaderc.cmake +++ b/cmake/tools/shaderc.cmake @@ -17,7 +17,7 @@ include( cmake/3rdparty/glslang.cmake ) add_executable( shaderc ${BGFX_DIR}/tools/shaderc/shaderc.cpp ${BGFX_DIR}/tools/shaderc/shaderc.h ${BGFX_DIR}/tools/shaderc/shaderc_glsl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_hlsl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_pssl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_spirv.cpp ) target_compile_definitions( shaderc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" ) set_target_properties( shaderc PROPERTIES FOLDER "bgfx/tools" ) -target_link_libraries( shaderc bx bgfx-vertexdecl bgfx-shader-spirv fcpp glsl-optimizer glslang ) +target_link_libraries( shaderc bx bimg bgfx-vertexdecl bgfx-shader-spirv fcpp glsl-optimizer glslang ) if( BGFX_CUSTOM_TARGETS ) add_dependencies( tools shaderc ) endif()