A rust wrapper around the Nvidia Texture Tools 3 library.
NVTT 3 is a library that can be used to compress image data and files into compressed texture formats, and to handle compressed and uncompressed images.
In NVTT 3, most compression algorithms and image processing algorithms can be accelerated by the GPU. These have CPU fallbacks for GPUs without support for CUDA. CUDA operations can be enabled through the cuda
feature.
The NVTT 3 SDK must be installed on the system. A non-standard path to the binaries can be specified via the NVTT_PATH
environment variable. A compiler supporting at least C99 and dynamic linking is also required.
Windows 10 or 11 (64-bit) are required.
64-bit only; Ubuntu 16.04+ or a similarly compatible distro is required. libc.so
version 6 or higher is required as well.
``` rust // Create a surface let input = InputFormat::Bgra8Ub { data: &[0u8; 16 * 16 * 4], unsignedtosigned: false, }; let image = Surface::image(input, 16, 16, 1).unwrap();
// Create the compression context; enable CUDA if possible let mut context = Context::new(); if *CUDASUPPORTED { context.setcuda_acceleration(true); }
// Specify compression settings to use; compress to Bc7 let mut compressionoptions = CompressionOptions::new(); compressionoptions.set_format(Format::Bc7);
// Specify how to write the compressed data. Here, we write to temporary file. let mut outputoptions = OutputOptions::newtemp().unwrap();
// Write the DDS header. assert!(context.outputheader( &image, 1, // number of mipmaps &compressionoptions, &mut output_options, ));
// Compress and write the compressed data. assert!(context.compress( &image, &compressionoptions, &mut outputoptions, ));
// Get raw bytes, and delete temporary file let bytes = outputoptions.to_bytes().unwrap(); ```