libsquish v1.15.1.2
S3TC/DXT compliant image compression
|
The squish library (abbreviated to libsquish) is an open source DXT compression library written in C++ with the following features:
A description of the algorithms used to perform the compression can be found on the following blog post by Simon Brown.
The cluster fit algorithm in squish forms the core DXT compression algorithm for NVIDIA's Legacy Texture Tools. NVIDIA was kind enough to allow implementation improvements to be refactored back into the library.
libsquish is provided as a CMake package composed of a single library and accompanying public header file, along with a couple optional executables.
Squish
- The main libraryGenerator
- The color lookup table generator applicationPng
- The PNG compressor demo applicationIf no components are specified in the find_package()
call, only the main library will be imported.
libsquish is also composed to gracefully support CMake's FetchContent mechanism. All exportable targets are named to match their corresponding component when packaged, and feature alias targets with the same names when building. This allows consumers to access the targets via the same name regardless of whether they are using a pre-built package of libsquish or building it as a sub-project.
For example, the Squish
component corresponds to the libsquish_squish
target, which can also be referred to via libsquish::Squish
.
1) Download the latest Release
2) Place the package somewhere CMake can find it
3) Import the package
4) Link to the library
5) Include the public header in your code
6) Review the documentation for the squish namespace.
The latest stable source is available in the 'master' branch of https://github.com/oblivioncth/libsquish
The requirements for building from source are the same as for using libsquish, with the exception that Doxygen (as well as Graphviz) is also needed to build the documentation.
It is recommended to use a multi-configuration generators such as Ninja Multi-Config or Visual Studio.
LIBSQUISH_USE_OPENMP
- Build libsquish using the OpenMP parallelization library (ON)LIBSQUISH_USE_SSE2
- Build libsquish using the SSE2 extended x86 instructions (ON)LIBSQUISH_USE_ALTIVEC
- Build libsquish using PPC AltiVec instructions (OFF)LIBSQUISH_EXTRAS
- Enable the 'generator' and 'png' targets (OFF)LIBSQUISH_DOCS
- Enable the libsquish documentation target (OFF)LIBSQUISH_TESTS
- Enable the libsquish test targets (OFF)BUILD_SHARED_LIBS
- Build libsquish as a shared library instead of a static one (OFF)all
- Builds the library, documentation if enabled, and 'extra' executables if enabledinstall
- Installs the build output into CMAKE_INSTALL_PREFIX
libsquish_docs
- Builds the libsquish documentationlibsquish_squish
- Builds the main librarylibsquish_generator
- Builds the color lookup table generatorlibsquish_png
- Builds the PNG compressor demolibsquish_tst_...
- Builds test targets. To actually run tests, just build the general CMake tests target test
.libsquish
- Installs top-level files (README.md, CMake package configuration files, etc.)libsquish_docs
- Installs the libsquish documentationlibsquish_squish
- Installs the main librarylibsquish_generator
- Installs the color lookup table generatorlibsquish_png
- Installs the PNG compressor demoIf libsquish is configured as a sub-project, its install components are automatically removed from the default install component, as to not pollute the install directory of the top-level project. They can still be installed by directly referencing their component names as shown above.
In order for the libsquish_docs
target to be generated the CMake cache variable LIBSQUISH_DOCS must be set to ON when CMake is invoked:
The project contains a suite of tests to ensure that the library functions as intended.
By default, the project configures CPack to create an artifact ZIP containing all installed components.
The following is the general build process required to successfully generate this package via a shadow build on Windows:
If you want to use libsquish compiled from source directly as a dependency in your CMake project and don't care about the intermediary redistributables, it is recommended to do the following.
Create 'Fetchlibsquish.cmake' and add it to CMAKE_MODULE_PATH:
Then in your CMake project:
This allows for more flexibility in downstream projects as they can more easily alter the configuration of libsquish on-the-fly as needed.