### Create Example Executables Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/CMakeLists.txt Creates various example executables if BASISU_EXAMPLES is enabled, including a general example, a C API example, and a transcoding example. Some examples link against basisu_encoder, while others do not. ```cmake if (BASISU_EXAMPLES) # Create the example executables add_executable(examples example/example.cpp) set_common_executable_properties(examples TRUE) add_executable(example_capi example_capi/example_capi.c encoder/basisu_wasm_api.cpp encoder/basisu_wasm_transcoder_api.cpp) set_common_executable_properties(example_capi TRUE) add_executable(example_transcoding example_transcoding/example_transcoding.cpp example_transcoding/utils.cpp zstd/zstddeclib.c transcoder/basisu_transcoder.cpp) set_common_executable_properties(example_transcoding FALSE) # As target is not linked with basisu_encoder, these values won't be imported. target_compile_definitions(example_transcoding PRIVATE "BASISD_SUPPORT_KTX2_ZSTD=$,1,0>") target_compile_options(example_transcoding PUBLIC "$<$:-fno-exceptions -fno-rtti>" ) endif() ``` -------------------------------- ### Build and Install on Windows with NMake Source: https://github.com/khronosgroup/ktx-software/blob/main/external/astc-encoder/Docs/Building.md Compile and install the project on Windows using NMake after configuring the build. Binaries are installed to the specified CMAKE_INSTALL_PREFIX/bin. ```shell # Run a build and install build outputs in `${CMAKE_INSTALL_PREFIX}/bin/` cd build nmake install ``` -------------------------------- ### Install Basis Universal with vcpkg Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/README.md Instructions for installing Basis Universal using the vcpkg dependency manager. Ensure vcpkg is cloned and bootstrapped before installing. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install vcpkg install basisu ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/test/add-subdirectory-test/CMakeLists.txt Sets the minimum CMake version and names the C++ project. This is a standard starting point for most CMake projects. ```cmake cmake_minimum_required(VERSION 3.8...3.25) project(fmt-test CXX) ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/shader_deblocking/README.md Install the necessary Python packages for running the sample. Ensure you have pip installed. ```bash pip install numpy Pillow glfw PyOpenGL ``` -------------------------------- ### Create Examples Executable Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/khronos/CMakeLists.txt Creates the 'examples' executable if BASISU_EXAMPLES is defined, linking against the basisu_encoder static library and applying common executable properties. ```cmake if (BASISU_EXAMPLES) # Create the new example executable and link against the static library add_executable(examples ../example/example.cpp) set_common_executable_properties(examples) endif() ``` -------------------------------- ### Build and Install on macOS/Linux with Make Source: https://github.com/khronosgroup/ktx-software/blob/main/external/astc-encoder/Docs/Building.md Compile and install the project on macOS and Linux using Make after configuring the build. Binaries are installed to CMAKE_INSTALL_PREFIX/bin and libraries to CMAKE_INSTALL_PREFIX/lib. ```shell # Run a build and install build outputs in `${CMAKE_INSTALL_PREFIX}/bin/` # for executable binaries and `${CMAKE_INSTALL_PREFIX}/lib/` for libraries cd build make install -j16 ``` -------------------------------- ### Installation of ktx_js Target and Files Source: https://github.com/khronosgroup/ktx-software/blob/main/CMakeLists.txt Installs the ktx_js runtime target and its associated WebAssembly file to the runtime destination, assigning them to the 'ktx_js' component. ```cmake install(TARGETS ktx_js RUNTIME DESTINATION . COMPONENT ktx_js ) install(FILES ${CMAKE_BINARY_DIR}/libktx.wasm DESTINATION . COMPONENT ktx_js ) ``` -------------------------------- ### Installation of ktx_js_read Target and Files Source: https://github.com/khronosgroup/ktx-software/blob/main/CMakeLists.txt Installs the ktx_js_read runtime target and its associated WebAssembly file to the runtime destination, assigning them to the 'ktx_js_read' component. ```cmake install(TARGETS ktx_js_read RUNTIME DESTINATION . COMPONENT ktx_js_read ) install(FILES ${CMAKE_BINARY_DIR}/libktx_read.wasm DESTINATION . COMPONENT ktx_js_read ) ``` -------------------------------- ### Installing Package Configuration Files Source: https://github.com/khronosgroup/ktx-software/blob/main/lib/CMakeLists.txt Installs the KtxConfig.cmake and the generated KtxConfigVersion.cmake files into the lib/cmake/ktx directory, marked for the 'dev' component. ```cmake install(FILES "cmake/KtxConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KtxConfigVersion.cmake" DESTINATION lib/cmake/ktx COMPONENT dev ) ``` -------------------------------- ### Install Wasmtime Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/readme_wasi.md Install Wasmtime using the official installer script. Verify the installation by checking the version. ```shell curl https://wasmtime.dev/install.sh | bash ``` ```shell wasmtime --version ``` -------------------------------- ### Format String Examples Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/doc/syntax.md Illustrates basic format string usage with explicit and implicit argument referencing. ```c++ "First, thou shalt count to {0}" // References the first argument ``` ```c++ "Bring me a {}" // Implicitly references the first argument ``` ```c++ "From {} to {}" // Same as "From {0} to {1}" ``` -------------------------------- ### Run ASTC Encoder Example Source: https://github.com/khronosgroup/ktx-software/blob/main/external/astc-encoder/Utils/Example/README.md Execute the compiled example application from the build directory, providing input and output PNG file paths. This compresses the input image and writes the decompressed output. ```bash astcenc_example ``` -------------------------------- ### Install fmt Library on OS X with Homebrew Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/doc/ChangeLog-old.md Install the fmt library on OS X using the Homebrew package manager. ```bash $ brew install cppformat ``` -------------------------------- ### Build ASTC Encoder Example on Windows Source: https://github.com/khronosgroup/ktx-software/blob/main/external/astc-encoder/Utils/Example/README.md Use these commands to build the example project on Windows using CMake and NMake Makefiles from a Visual Studio command prompt. Ensure you are in the './Utils/Example' directory. ```bash mkdir build cd build cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release .. nmake ``` -------------------------------- ### Install KTX Tools Source: https://github.com/khronosgroup/ktx-software/blob/main/tools/CMakeLists.txt Installs the 'ktxtools' target to the runtime destination directory, categorized under the 'tools' component. ```cmake install(TARGETS ktxtools RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT tools ) ``` -------------------------------- ### Install Python 3.12 using winget Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/python/README_win.md If Python 3.12 is not found, use this command to install it via winget. ```bash winget install Python.Python.3.12 ``` -------------------------------- ### Install dfdutils Library and Headers Source: https://github.com/khronosgroup/ktx-software/blob/main/external/dfdutils/CMakeLists.txt Installs the dfdutils target, including its library, framework, public headers, and runtime binaries, based on build configurations. ```cmake if(DFDUTILS_INSTALL AND NOT DFDUTILS_EMBED) install(TARGETS dfdutils ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # No if() as, fortunately, CMake does not complain when the target does # not contain a matching FILE_SET. FILE_SET public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) endif() ``` -------------------------------- ### Install Load Test App Dependencies (Fedora/RedHat) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Installs development libraries required for building KTX-Software's load test applications on Fedora/RedHat. Includes SDL3, OpenGL, Vulkan, and Assimp. ```bash sudo dnf install SDL3-devel mesa-libGL mesa-libGL-devel mesa-vulkan-drivers assimp-devel ``` -------------------------------- ### Build pyktx with libktx installed Source: https://github.com/khronosgroup/ktx-software/blob/main/interface/python_binding/README.md Run the build script to build and test pyktx. Optionally specify the installation directory for libktx using the LIBKTX_INSTALL_DIR environment variable. ```bash cd $PROJECT_DIR/interface/python_binding KTX_RUN_TESTS=ON python3 buildscript.py ``` ```bash LIBKTX_INSTALL_DIR= KTX_RUN_TESTS=ON python3 buildscript.py ``` -------------------------------- ### Install GNU/Linux Dependencies (Fedora/RedHat) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Installs essential build tools and libraries for KTX-Software on Fedora/RedHat-based systems. Includes CMake, compilers, and OpenCL support. ```bash sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libzstd-devel ninja-build doxygen graphviz mesa-libOpenCL ``` -------------------------------- ### Build ASTC Encoder Example on Linux/macOS Source: https://github.com/khronosgroup/ktx-software/blob/main/external/astc-encoder/Utils/Example/README.md Use these commands to build the example project on Linux or macOS using CMake and Unix Makefiles. Ensure you are in the './Utils/Example' directory. ```bash mkdir build cd build cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. make -j8 ``` -------------------------------- ### Install fmt subproject with Meson Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/doc/get-started.md Install the fmt subproject from Meson WrapDB. This makes fmt available for use in your Meson build files. ```bash meson wrap install fmt ``` -------------------------------- ### Example: XUASTC LDR 6x6 Compression with Arithmetic Profile Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/README.md Windows command-line example for XUASTC LDR 6x6 compression using the arithmetic profile with Weight Grid DCT level 70. This demonstrates a specific advanced compression setting. ```bash bin/basisu -encode_astc_lrgb -astc_lrgb_level 70 -astc_lrgb_arithmetic -o output.ktx2 input.png ``` -------------------------------- ### Install GNU/Linux Dependencies (Debian/Ubuntu) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Installs essential build tools and libraries for KTX-Software on Debian-based systems. Includes CMake, compilers, Ninja, and OpenCL headers. ```bash sudo apt install build-essential cmake libzstd-dev ninja-build doxygen graphviz opencl-c-headers ocl-icd-opencl-dev mesa-opencl-icd ``` -------------------------------- ### Shell Script Example for Wasmtime Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/readme_wasi.md A shell script example demonstrating how to run basisu.wasm with Wasmtime, including specific directory mappings and threading options. ```shell #!/usr/bin/env bash wasmtime run --dir=. --dir=../test_files --dir=/mnt/d/dev/test_images::/test_images --dir=/mnt/d/dev/test_images/bik::/test_images/bik --wasm threads=yes --wasi threads=yes ./basisu.wasm "$@" ``` -------------------------------- ### Install Load Test App Dependencies (Debian/Ubuntu) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Installs development libraries required for building KTX-Software's load test applications on Debian/Ubuntu. Includes SDL3, OpenGL, Vulkan, and Assimp. ```bash sudo apt install libsdl3-dev libgl1-mesa-glx libgl1-mesa-dev libvulkan1 libvulkan-dev libassimp-dev ``` -------------------------------- ### Example Test Output Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/python/README.md This output demonstrates the successful execution of the 'test_backend_loading' test, showing results for both native and WASM backends. ```text richg@ryzen9:/mnt/c/dev/bu_1_22_snapshot2/basis_universal-master/python$ python3 -m tests.test_backend_loading ========== BACKEND LOADING TEST ========== Testing native backend... [Encoder] Using native backend [OK] Native backend loaded Hello from basisu_wasm_api.cpp version 200 Native get_version() ? 200 Native alloc() returned ptr = 685784256 Native free() OK [OK] Native basic operations working. Testing WASM backend... [WASM Encoder] Loaded: /mnt/c/dev/bu_1_22_snapshot2/basis_universal-master/python/basisu_py/wasm/basisu_module_st.wasm [Encoder] Using WASM backend [OK] WASM backend loaded Hello from basisu_wasm_api.cpp version 200 WASM get_version() ? 200 WASM alloc() returned ptr = 26920160 WASM free() OK [OK] WASM basic operations working. ========== DONE ========== ``` -------------------------------- ### Build pyktx on Windows with libktx installed Source: https://github.com/khronosgroup/ktx-software/blob/main/interface/python_binding/README.md Execute the build script on Windows. Set the LIBKTX_INSTALL_DIR environment variable to the libktx installation path. The KTX_RUN_TESTS variable can also be set to ON. ```powershell cd $env:PROJECT_DIR/interface/python_binding pwsh -Command { $env:LIBKTX_INSTALL_DIR=''; python buildscript.py } ``` ```powershell pwsh -Command { $env:LIBKTX_INSTALL_DIR=''; $env:KTX_RUN_TESTS='ON'; python buildscript.py } ``` -------------------------------- ### Build Web/Emscripten Version with Local Installation Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Build the WebAssembly version using a local Emscripten installation. Ensure your Emscripten environment is set up in the terminal before running the build command. ```bash # Debug: # (No specific command provided in source for Debug, only a placeholder) ``` -------------------------------- ### Windows .cmd Batch Script Example for Wasmtime Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/readme_wasi.md Example of how to run basisu.wasm on Windows using a .cmd batch script, specifying multiple directories for filesystem access. ```batch wasmtime --dir=. --dir=.. --dir=..\test_files --dir=d:/dev/test_images::/test_images --dir=d:/dev/test_images/bik::/bik basisu.wasm %* ``` -------------------------------- ### Start Local Webserver with Python Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/webgl/README.md Use Python to set up a local webserver for hosting files in the 'webgl' directory. Ensure the server is configured for WASM multithreading if needed. ```bash cd webgl python3 -m http.server 8000 ``` -------------------------------- ### Basic Project Setup and Subdirectories Source: https://github.com/khronosgroup/ktx-software/blob/main/CMakeLists.txt Sets the library version and includes subdirectories for core library and optional bindings based on feature flags. ```cmake set(LIBKTX_VERSION_READ_ONLY ON CACHE BOOL "Build the read-only library") add_subdirectory(lib) if(KTX_FEATURE_JNI) add_subdirectory(interface/java_binding) endif() if(KTX_FEATURE_PY) add_subdirectory(interface/python_binding) endif() create_version_file() ``` -------------------------------- ### Configure format-benchmark with CMake Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/README.md Navigate into the cloned repository and configure the build system using CMake. ```bash cd format-benchmark cmake . ``` -------------------------------- ### Install pybind11 for Python 3.12 Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/python/README_win.md Install the pybind11 library specifically for your Python 3.12 installation using pip. ```bash py -3.12 -m pip install pybind11 ``` -------------------------------- ### Configure and Build for Windows (Basic) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Configure and build the KTX-Software project for native Windows development. This creates a Visual Studio solution. ```powershell # This creates a solution at `build/KTX-Software.sln` # containing the libktx and tools targets. cmake -B build . ``` -------------------------------- ### Installed CMake Integration Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/doc/get-started.md Link against an installed version of {fmt} in your CMake project. Ensure {fmt} is installed on the system first. ```cmake find_package(fmt) target_link_libraries( fmt::fmt) ``` -------------------------------- ### Configure and Build for Universal Windows Platform (UWP) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Configure and build KTX-Software for the Universal Windows Platform. This example targets ARM64 and builds only the 'ktx.dll' target. ```powershell cmake . -A ARM64 -B build_uwp_arm64 -D CMAKE_SYSTEM_NAME:String=WindowsStore -D CMAKE_SYSTEM_VERSION:String="10.0" ``` ```powershell # Build `ktx.dll` only cmake -B build_uwp_arm64 --target ktx ``` -------------------------------- ### Conditional NAMELINK_ONLY Installation on Apple/Linux Source: https://github.com/khronosgroup/ktx-software/blob/main/lib/CMakeLists.txt On Apple or Linux systems, this installs library targets with NAMELINK_ONLY, ensuring only the symbolic links are installed. ```cmake if(APPLE OR LINUX) install(TARGETS ${LIBKTX_INSTALL_TARGETS} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library NAMELINK_ONLY ) endif() ``` -------------------------------- ### Configure and Build for Web (Release) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Use these commands to configure and build the project for web development in release mode. ```bash emcmake cmake -B build-web . ``` ```bash cmake --build build-web ``` -------------------------------- ### Check Installed Python Versions Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/python/README_win.md Use this command to list all installed Python versions on your system. ```bash py -0 ``` -------------------------------- ### Configure and Build for Windows (with Load Tests) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Configure and build the KTX-Software project for Windows, including load test applications. This utilizes vcpkg for dependency management. ```powershell # If you want to build the load test apps as well, set the # `KTX_FEATURE_LOADTEST_APPS` and `CMAKE_TOOLCHAIN_FILE` # parameters. vcpkg will automatically install the dependencies. cmake -B build . -D KTX_FEATURE_LOADTEST_APPS=ON -D CMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake ``` ```powershell # Compile the project cmake --build build ``` -------------------------------- ### Install KTX Target Source: https://github.com/khronosgroup/ktx-software/blob/main/lib/CMakeLists.txt Appends the 'ktx' target to the LIBKTX_INSTALL_TARGETS list if LIBKTX_VERSION_FULL is defined, indicating that the 'ktx' target should be installed. ```cmake if(LIBKTX_VERSION_FULL) list(APPEND LIBKTX_INSTALL_TARGETS ktx) endif() ``` -------------------------------- ### Set Installation Directory for Include Files Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/CMakeLists.txt Configures the installation directory for include files using the `set_verbose` helper function. ```cmake set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING "Installation directory for include files, a relative path that " "will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.") ``` -------------------------------- ### Install msc_basis_transcoder_js target Source: https://github.com/khronosgroup/ktx-software/blob/main/CMakeLists.txt Installs the msc_basis_transcoder_js target to the runtime directory. This makes the JavaScript transcoder module available for use. ```cmake install(TARGETS msc_basis_transcoder_js RUNTIME DESTINATION . COMPONENT msc_basis_transcoder_js ) ``` -------------------------------- ### Installing Export CMake Files Source: https://github.com/khronosgroup/ktx-software/blob/main/lib/CMakeLists.txt Installs the KTXTargets.cmake file, which is used for exporting targets, into the lib/cmake/ktx directory, marked for the 'dev' component. ```cmake install(EXPORT KTXTargets FILE KtxTargets.cmake NAMESPACE KTX:: DESTINATION lib/cmake/ktx COMPONENT dev ) ``` -------------------------------- ### Build the Complete KTX Project Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Navigate to the root directory and use CMake to generate build files and compile the entire project, including the library and command-line tools. ```bash # Navigate to the root of your KTX-Software clone (replace with # your actual path) cd /path/to/KTX-Software # This generates build/project files in the sub-folder `build` cmake . -B build # Compile the project cmake --build build ``` -------------------------------- ### Install fmt Library on Debian Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/doc/ChangeLog-old.md Use this command to install the fmt library development package on Debian GNU/Linux and derived distributions. ```bash $ sudo apt-get install libcppformat1-dev ``` -------------------------------- ### Install wasmtime for WASM Backend Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/python/README_win.md Install the wasmtime runtime using pip for Python 3.12 if you intend to use the WASM backend. ```bash py -3.12 -m pip install wasmtime ``` -------------------------------- ### Development Workflow with CTS Testing Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md A comprehensive example demonstrating the development workflow, including cloning, submodule updates, CMake configuration with CTS enabled, building, and running tests. ```bash # Git clone and submodule fetch git clone git@github.com:KhronosGroup/KTX-Software.git cd KTX-Software/ git submodule update --init --recursive tests/cts # Configure mkdir build cmake -B build . -DKTX_FEATURE_DOC=ON -DBUILD_SHARED_LIBS=OFF -DKTX_FEATURE_TOOLS=ON -DKTX_FEATURE_TESTS=ON -DKTX_FEATURE_TOOLS_CTS=ON # Build everything (depending on workflow its better to build the specific target like 'ktxtools'): cmake --build build --target all # Run every test case: ctest --test-dir build # Run only the CTS test cases: ctest --test-dir build -R ktxToolsTest ``` -------------------------------- ### Project Initialization Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/CMakeLists.txt Initializes the project with C and C++ languages. ```cmake project(basisu C CXX) ``` -------------------------------- ### Conditional Installation of ktx_read Target Source: https://github.com/khronosgroup/ktx-software/blob/main/lib/CMakeLists.txt The ktx_read target is conditionally installed only when building read-only libraries and not building shared libraries or the full version. ```cmake if(LIBKTX_VERSION_READ_ONLY AND NOT (BUILD_SHARED_LIBRARIES OR LIBKTX_VERSION_FULL)) list(APPEND LIBKTX_INSTALL_TARGETS ktx_read) endif() ``` -------------------------------- ### Bootstrap vcpkg Package Manager Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Clone the vcpkg repository and run the bootstrap script to set up the package manager. This is used for installing SDL3 and assimp on macOS and Windows. ```bash cd /place/to/clone/vcpkg git clone https://github.com/microsoft/vcpkg cd vcpkg ./bootstrap-vcpkg.sh -disableMetrics # On Windows use ./bootstrap-vcpkg.bat ``` -------------------------------- ### Initialize Demo Items Source: https://github.com/khronosgroup/ktx-software/blob/main/tests/webgl/libktx-webgl/index.html Sets up the initial display items for the WebGL demo, including creating placeholder textures and associated DOM elements. Each item represents a different stage or type of texture manipulation. ```javascript const contentElem = document.querySelector('#glcontent'); const items = []; const numItems = 6; const origImageItem = 0, uncompTextureItem = 1; const copyTextureItem = 2, basisCompTextureItem = 3; const writeReadTextureItem = 4, astcCompTextureItem = 5; const labelText = [ 'Input image', 'Uncompressed ktxTexture2', 'Copy of uncompressed ktxTexture2', 'Compressed to ETC1S/Basis-LZ', 'Written and Read .ktx2 file with uncompressed texture', 'ASTC compressed texture' ]; for (let i = 0; i < numItems; ++i) { const outerElem = createElem('div', contentElem, 'item'); const viewElem = createElem('div', outerElem, 'view'); const labelElem = createElem('div', outerElem, 'label'); labelElem.textContent = labelText[i]; const bgColor = [rand(1), rand(1), rand(1), 1]; var placeholder = {}; switch (i) { case 0: placeholder.target = null; placeholder.object = null; placeholder.uvMatrix = null; break; default: const texColor = [rand(255), rand(255), rand(255), 255]; placeholder = createPlaceholderTexture(gl, texColor); break; } items.push({ color: bgColor, texture: placeholder, element: viewElem, label: labelElem }); } ``` -------------------------------- ### Installing Library Targets Source: https://github.com/khronosgroup/ktx-software/blob/main/lib/CMakeLists.txt Installs various types of library targets (ARCHIVE, FRAMEWORK, LIBRARY, RUNTIME) to their respective destinations, categorized under the 'library' component. ```cmake get_target_property(targetIsFw ktx FRAMEWORK) # Have library's name links as separate component install(TARGETS ${LIBKTX_INSTALL_TARGETS} EXPORT KTXTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library NAMELINK_SKIP RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT library FILE_SET public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT dev ) ``` -------------------------------- ### Build WASI .wasm Executable Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/readme_wasi.md Build the WASI WebAssembly executable using the 'make' command. This will generate 'basisu.wasm' and potentially 'examples.wasm' if EXAMPLES=ON. ```shell make ``` -------------------------------- ### Install WASM file for msc_basis_transcoder_js Source: https://github.com/khronosgroup/ktx-software/blob/main/CMakeLists.txt Installs the compiled WebAssembly file for the msc_basis_transcoder_js component. This ensures the WASM binary is available alongside the JavaScript module. ```cmake install(FILES ${CMAKE_BINARY_DIR}/msc_basis_transcoder.wasm DESTINATION . COMPONENT msc_basis_transcoder_js ) ``` -------------------------------- ### Enable Load Test Apps and Documentation Build Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Configure the CMake build to include load test applications and documentation by setting KTX_FEATURE_LOADTEST_APPS and KTX_FEATURE_DOC to ON. ```bash cmake . -B build -D KTX_FEATURE_LOADTEST_APPS=ON -D KTX_FEATURE_DOC=ON ``` -------------------------------- ### Build and Install on macOS with Xcode Source: https://github.com/khronosgroup/ktx-software/blob/main/external/astc-encoder/Docs/Building.md Compile and install the project on macOS using CMake after configuring with the Xcode generator. Supports building universal binaries. ```shell cmake --build . --config Release # Optionally install the binaries to the installation directory cmake --install . --config Release ``` -------------------------------- ### Configure and Build for Web (Debug) Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Use these commands to configure and build the project for web development with debug settings. ```bash emcmake cmake -B build-web-debug . -D CMAKE_BUILD_TYPE=Debug ``` ```bash cmake --build build-web-debug --config Debug ``` -------------------------------- ### Checkout Repository with Git LFS Source: https://github.com/khronosgroup/ktx-software/blob/main/README.md Run this command after installing Git LFS if you did not have it installed at the first checkout. This ensures all repository files are properly checked out. ```bash git lfs checkout ``` -------------------------------- ### Set Test Properties for Install RPATH Source: https://github.com/khronosgroup/ktx-software/blob/main/tests/CMakeLists.txt Configures the INSTALL_RPATH for test executables based on the operating system. This ensures that shared libraries can be found at runtime after installation. ```cmake function(set_test_properties test_target) # See comments in set_tools_properties() in ../tools/CMakeLists.txt. if(APPLE) set_target_properties(${test_target} PROPERTIES INSTALL_RPATH "@executable_path;@executable_path/../${CMAKE_INSTALL_LIBDIR}" ) elseif(LINUX) set_target_properties(${test_target} PROPERTIES INSTALL_RPATH "$ORIGIN;$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" ) endif() endfunction() ``` -------------------------------- ### Install Strawberry Perl on Windows Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Use Chocolatey to install Strawberry Perl, which is required for regenerating source files on Windows and ensures correct line endings. ```powershell choco install strawberryperl ``` -------------------------------- ### Build {fmt} Documentation Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/doc/get-started.md Compile the documentation for {fmt} after generating build scripts. Requires Python, Doxygen, and MkDocs. ```bash make doc ``` -------------------------------- ### Build pyktx with self-built libktx Source: https://github.com/khronosgroup/ktx-software/blob/main/interface/python_binding/README.md Configure include and library directories for a self-built libktx. Set LIBKTX_INCLUDE_DIR and LIBKTX_LIB_DIR to point to your build artifacts. ```bash cd $PROJECT_DIR/interface/python_binding LIBKTX_INCLUDE_DIR=../../lib/include LIBKTX_LIB_DIR=../../build/Debug KTX_RUN_TESTS=ON python3 buildscript.py ``` -------------------------------- ### Run Basis Universal Command-Line Tool (Windows) Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/README.md Execute the Basis Universal command-line tool on Windows to compress images or transcode KTX2 files. Ensure you are in the 'bin' directory. ```batch cd bin runwt.bat ../test_files/tough.png -xuastc_ldr_6x6 -quality 70 -xuastc_arith runwt.bat tough.ktx2 ``` -------------------------------- ### Install Git Filters for Date Keyword Expansion (Unix) Source: https://github.com/khronosgroup/ktx-software/blob/main/README.md Installs git filters for handling $Date$ keywords on Unix-like systems. Run these commands in the root of your clone. ```bash ./install-gitconfig.sh ./scripts/smudge_date.sh ``` -------------------------------- ### Run Shader Deblocking Sample Source: https://github.com/khronosgroup/ktx-software/blob/main/external/basis_universal/shader_deblocking/README.md Execute the sample application with the specified shader, dimensions, and texture files. Depending on your setup, you might need to use 'python3' or a specific Python version. ```bash python testbed.py shader.glsl 12 12 flower_unpacked_rgb_ASTC_LDR_12X12_RGBA_level_0_face_0_layer_0000.png flower_unpacked_rgb_ASTC_LDR_12X12_RGBA_level_1_face_0_layer_0000.png flower_unpacked_rgb_ASTC_LDR_12X12_RGBA_level_2_face_0_layer_0000.png flower_unpacked_rgb_ASTC_LDR_12X12_RGBA_level_3_face_0_layer_0000.png flower_unpacked_rgb_ASTC_LDR_12X12_RGBA_level_4_face_0_layer_0000.png ``` -------------------------------- ### Format a string with fmt Source: https://github.com/khronosgroup/ktx-software/blob/main/external/fmt/README.md Demonstrates formatting a string with a simple placeholder and an integer value. ```c++ std::string s = fmt::format("The answer is {}.", 42); // s == "The answer is 42." ``` -------------------------------- ### Run Tests on macOS with Custom Library Path Source: https://github.com/khronosgroup/ktx-software/blob/main/interface/java_binding/README.md Command to run tests on macOS when libktx and libktx-jni are installed in a custom location. Adjust the -Djava.library.path to your specific installation directory. ```bash _JAVA_OPTIONS=-Djava.library.path=/usr/local/lib mvn test ``` -------------------------------- ### Build KTX-Software with CMake Source: https://github.com/khronosgroup/ktx-software/blob/main/BUILDING.md Standard command to build the project after CMake configuration. ```bash cmake --build "build-android" ```