![]() |
SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
|
#include <VTF.h>
Classes | |
struct | CreationOptions |
Public Member Functions | |
VTF () | |
VTF (std::vector< std::byte > &&vtfData, bool parseHeaderOnly=false) | |
VTF (std::span< const std::byte > vtfData, bool parseHeaderOnly=false) | |
VTF (const std::string &vtfPath, bool parseHeaderOnly=false) | |
VTF (const VTF &other) | |
VTF & | operator= (const VTF &other) |
VTF (VTF &&) noexcept=default | |
VTF & | operator= (VTF &&) noexcept=default |
operator bool () const | |
Platform | getPlatform () const |
void | setPlatform (Platform newPlatform) |
uint32_t | getMajorVersion () const |
uint32_t | getMinorVersion () const |
void | setVersion (uint32_t newMajorVersion, uint32_t newMinorVersion) |
void | setMajorVersion (uint32_t newMajorVersion) |
void | setMinorVersion (uint32_t newMinorVersion) |
ImageConversion::ResizeMethod | getImageWidthResizeMethod () const |
ImageConversion::ResizeMethod | getImageHeightResizeMethod () const |
void | setImageResizeMethods (ImageConversion::ResizeMethod imageWidthResizeMethod_, ImageConversion::ResizeMethod imageHeightResizeMethod_) |
void | setImageWidthResizeMethod (ImageConversion::ResizeMethod imageWidthResizeMethod_) |
void | setImageHeightResizeMethod (ImageConversion::ResizeMethod imageHeightResizeMethod_) |
uint16_t | getWidth (uint8_t mip=0) const |
uint16_t | getHeight (uint8_t mip=0) const |
void | setSize (uint16_t newWidth, uint16_t newHeight, ImageConversion::ResizeFilter filter) |
Flags | getFlags () const |
void | setFlags (Flags flags_) |
void | addFlags (Flags flags_) |
void | removeFlags (Flags flags_) |
void | computeTransparencyFlags () |
ImageFormat | getFormat () const |
void | setFormat (ImageFormat newFormat, ImageConversion::ResizeFilter filter=ImageConversion::ResizeFilter::DEFAULT) |
uint8_t | getMipCount () const |
bool | setMipCount (uint8_t newMipCount) |
bool | setRecommendedMipCount () |
void | computeMips (ImageConversion::ResizeFilter filter=ImageConversion::ResizeFilter::DEFAULT) |
uint16_t | getFrameCount () const |
bool | setFrameCount (uint16_t newFrameCount) |
uint8_t | getFaceCount () const |
bool | setFaceCount (bool isCubemap, bool hasSphereMap=false) |
uint16_t | getSliceCount () const |
bool | setSliceCount (uint16_t newSliceCount) |
bool | setFrameFaceAndSliceCount (uint16_t newFrameCount, bool isCubemap, bool hasSphereMap=false, uint16_t newSliceCount=1) |
uint16_t | getStartFrame () const |
void | setStartFrame (uint16_t newStartFrame) |
sourcepp::math::Vec3f | getReflectivity () const |
void | setReflectivity (sourcepp::math::Vec3f newReflectivity) |
void | computeReflectivity () |
float | getBumpMapScale () const |
void | setBumpMapScale (float newBumpMapScale) |
ImageFormat | getThumbnailFormat () const |
uint8_t | getThumbnailWidth () const |
uint8_t | getThumbnailHeight () const |
const std::vector< Resource > & | getResources () const |
const Resource * | getResource (Resource::Type type) const |
std::vector< std::byte > | getParticleSheetFrameDataRaw (uint16_t &spriteWidth, uint16_t &spriteHeight, uint32_t shtSequenceID, uint32_t shtFrame, uint8_t shtBounds=0, uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) const |
This is a convenience function. You're best off uploading the bounds to the GPU and scaling the UV there if trying to render a particle. | |
std::vector< std::byte > | getParticleSheetFrameDataAs (ImageFormat newFormat, uint16_t &spriteWidth, uint16_t &spriteHeight, uint32_t shtSequenceID, uint32_t shtFrame, uint8_t shtBounds=0, uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) const |
This is a convenience function. You're best off uploading the bounds to the GPU and scaling the UV there if trying to render a particle. | |
std::vector< std::byte > | getParticleSheetFrameDataAsRGBA8888 (uint16_t &spriteWidth, uint16_t &spriteHeight, uint32_t shtSequenceID, uint32_t shtFrame, uint8_t shtBounds=0, uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) const |
This is a convenience function. You're best off uploading the bounds to the GPU and scaling the UV there if trying to render a particle. | |
void | setParticleSheetResource (const SHT &value) |
void | removeParticleSheetResource () |
void | setCRCResource (uint32_t value) |
void | removeCRCResource () |
void | setLODResource (uint8_t u, uint8_t v, uint8_t u360=0, uint8_t v360=0) |
void | removeLODResource () |
void | setExtendedFlagsResource (uint32_t value) |
void | removeExtendedFlagsResource () |
void | setKeyValuesDataResource (const std::string &value) |
void | removeKeyValuesDataResource () |
int16_t | getCompressionLevel () const |
void | setCompressionLevel (int16_t newCompressionLevel) |
CompressionMethod | getCompressionMethod () const |
void | setCompressionMethod (CompressionMethod newCompressionMethod) |
bool | hasImageData () const |
bool | imageDataIsSRGB () const |
std::span< const std::byte > | getImageDataRaw (uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) const |
std::vector< std::byte > | getImageDataAs (ImageFormat newFormat, uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) const |
std::vector< std::byte > | getImageDataAsRGBA8888 (uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) const |
bool | setImage (std::span< const std::byte > imageData_, ImageFormat format_, uint16_t width_, uint16_t height_, ImageConversion::ResizeFilter filter=ImageConversion::ResizeFilter::DEFAULT, uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) |
bool | setImage (const std::string &imagePath, ImageConversion::ResizeFilter filter=ImageConversion::ResizeFilter::DEFAULT, uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0) |
std::vector< std::byte > | saveImageToFile (uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0, ImageConversion::FileFormat fileFormat=ImageConversion::FileFormat::DEFAULT) const |
bool | saveImageToFile (const std::string &imagePath, uint8_t mip=0, uint16_t frame=0, uint8_t face=0, uint16_t slice=0, ImageConversion::FileFormat fileFormat=ImageConversion::FileFormat::DEFAULT) const |
bool | hasThumbnailData () const |
std::span< const std::byte > | getThumbnailDataRaw () const |
std::vector< std::byte > | getThumbnailDataAs (ImageFormat newFormat) const |
std::vector< std::byte > | getThumbnailDataAsRGBA8888 () const |
void | setThumbnail (std::span< const std::byte > imageData_, ImageFormat format_, uint16_t width_, uint16_t height_) |
void | computeThumbnail (ImageConversion::ResizeFilter filter=ImageConversion::ResizeFilter::DEFAULT) |
void | removeThumbnail () |
std::vector< std::byte > | saveThumbnailToFile (ImageConversion::FileFormat fileFormat=ImageConversion::FileFormat::DEFAULT) const |
bool | saveThumbnailToFile (const std::string &imagePath, ImageConversion::FileFormat fileFormat=ImageConversion::FileFormat::DEFAULT) const |
std::vector< std::byte > | bake () const |
bool | bake (const std::string &vtfPath) const |
Static Public Member Functions | |
static bool | create (std::span< const std::byte > imageData, ImageFormat format, uint16_t width, uint16_t height, const std::string &vtfPath, CreationOptions options) |
static bool | create (ImageFormat format, uint16_t width, uint16_t height, const std::string &vtfPath, CreationOptions options) |
static VTF | create (std::span< const std::byte > imageData, ImageFormat format, uint16_t width, uint16_t height, CreationOptions options) |
static VTF | create (ImageFormat format, uint16_t width, uint16_t height, CreationOptions options) |
static bool | create (const std::string &imagePath, const std::string &vtfPath, CreationOptions options) |
static VTF | create (const std::string &imagePath, CreationOptions options) |
static ImageFormat | getDefaultCompressedFormat (ImageFormat inputFormat, uint32_t majorVersion, uint32_t minorVersion) |
Static Public Attributes | |
static constexpr std::underlying_type_t< Flags > | FLAG_MASK_AFTER_V7_3 = FLAG_LOAD_ALL_MIPS | FLAG_SRGB | FLAG_DEFAULT_POOL | FLAG_COMBINED | FLAG_ASYNC_DOWNLOAD | FLAG_SKIP_INITIAL_DOWNLOAD | FLAG_LOAD_MOST_MIPS | FLAG_YCOCG | FLAG_ASYNC_SKIP_INITIAL_LOW_RES |
static constexpr std::underlying_type_t< Flags > | FLAG_MASK_INTERNAL = FLAG_NO_MIP | FLAG_ENVMAP |
static constexpr std::underlying_type_t< Flags > | FLAG_MASK_SRGB = FLAG_PWL_CORRECTED | FLAG_SRGB |
static constexpr auto | FORMAT_UNCHANGED = static_cast<ImageFormat>(-2) |
This value is only valid when passed to VTF::create through CreationOptions. | |
static constexpr auto | FORMAT_DEFAULT = static_cast<ImageFormat>(-1) |
This value is only valid when passed to VTF::create through CreationOptions or VTF::setFormat. | |
Protected Member Functions | |
Resource * | getResourceInternal (Resource::Type type) |
void | setResourceInternal (Resource::Type type, std::span< const std::byte > data_) |
void | removeResourceInternal (Resource::Type type) |
void | regenerateImageData (ImageFormat newFormat, uint16_t newWidth, uint16_t newHeight, uint8_t newMipCount, uint16_t newFrameCount, uint8_t newFaceCount, uint16_t newSliceCount, ImageConversion::ResizeFilter filter=ImageConversion::ResizeFilter::DEFAULT) |
Static Protected Member Functions | |
static void | createInternal (VTF &writer, CreationOptions options) |
Protected Attributes | |
bool | opened = false |
std::vector< std::byte > | data |
uint32_t | majorVersion {} |
uint32_t | minorVersion {} |
uint16_t | width {} |
uint16_t | height {} |
Flags | flags {} |
uint16_t | frameCount = 1 |
uint16_t | startFrame {} |
sourcepp::math::Vec3f | reflectivity {} |
float | bumpMapScale {} |
ImageFormat | format = ImageFormat::EMPTY |
uint8_t | mipCount = 1 |
ImageFormat | thumbnailFormat = ImageFormat::EMPTY |
uint8_t | thumbnailWidth {} |
uint8_t | thumbnailHeight {} |
uint16_t | sliceCount = 1 |
std::vector< Resource > | resources |
Platform | platform = PLATFORM_PC |
int16_t | compressionLevel = 0 |
CompressionMethod | compressionMethod = CompressionMethod::ZSTD |
ImageConversion::ResizeMethod | imageWidthResizeMethod = ImageConversion::ResizeMethod::POWER_OF_TWO_BIGGER |
ImageConversion::ResizeMethod | imageHeightResizeMethod = ImageConversion::ResizeMethod::POWER_OF_TWO_BIGGER |
enum vtfpp::VTF::Flags : int32_t |
enum vtfpp::VTF::Platform : uint32_t |
|
explicit |
|
explicit |
|
explicit |
|
defaultnoexcept |
void VTF::computeMips | ( | ImageConversion::ResizeFilter | filter = ImageConversion::ResizeFilter::DEFAULT | ) |
void VTF::computeThumbnail | ( | ImageConversion::ResizeFilter | filter = ImageConversion::ResizeFilter::DEFAULT | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
staticprotected |
CompressionMethod VTF::getCompressionMethod | ( | ) | const |
|
static |
VTF::Flags VTF::getFlags | ( | ) | const |
ImageFormat VTF::getFormat | ( | ) | const |
std::vector< std::byte > VTF::getImageDataAs | ( | ImageFormat | newFormat, |
uint8_t | mip = 0 , |
||
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) | const |
std::vector< std::byte > VTF::getImageDataAsRGBA8888 | ( | uint8_t | mip = 0 , |
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) | const |
std::span< const std::byte > VTF::getImageDataRaw | ( | uint8_t | mip = 0 , |
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) | const |
ImageConversion::ResizeMethod VTF::getImageHeightResizeMethod | ( | ) | const |
ImageConversion::ResizeMethod VTF::getImageWidthResizeMethod | ( | ) | const |
std::vector< std::byte > VTF::getParticleSheetFrameDataAs | ( | ImageFormat | newFormat, |
uint16_t & | spriteWidth, | ||
uint16_t & | spriteHeight, | ||
uint32_t | shtSequenceID, | ||
uint32_t | shtFrame, | ||
uint8_t | shtBounds = 0 , |
||
uint8_t | mip = 0 , |
||
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) | const |
std::vector< std::byte > VTF::getParticleSheetFrameDataAsRGBA8888 | ( | uint16_t & | spriteWidth, |
uint16_t & | spriteHeight, | ||
uint32_t | shtSequenceID, | ||
uint32_t | shtFrame, | ||
uint8_t | shtBounds = 0 , |
||
uint8_t | mip = 0 , |
||
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) | const |
std::vector< std::byte > VTF::getParticleSheetFrameDataRaw | ( | uint16_t & | spriteWidth, |
uint16_t & | spriteHeight, | ||
uint32_t | shtSequenceID, | ||
uint32_t | shtFrame, | ||
uint8_t | shtBounds = 0 , |
||
uint8_t | mip = 0 , |
||
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) | const |
VTF::Platform VTF::getPlatform | ( | ) | const |
const Resource * VTF::getResource | ( | Resource::Type | type | ) | const |
|
protected |
const std::vector< Resource > & VTF::getResources | ( | ) | const |
std::vector< std::byte > VTF::getThumbnailDataAs | ( | ImageFormat | newFormat | ) | const |
std::vector< std::byte > VTF::getThumbnailDataAsRGBA8888 | ( | ) | const |
std::span< const std::byte > VTF::getThumbnailDataRaw | ( | ) | const |
ImageFormat VTF::getThumbnailFormat | ( | ) | const |
|
protected |
|
protected |
bool VTF::saveImageToFile | ( | const std::string & | imagePath, |
uint8_t | mip = 0 , |
||
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 , |
||
ImageConversion::FileFormat | fileFormat = ImageConversion::FileFormat::DEFAULT |
||
) | const |
std::vector< std::byte > VTF::saveImageToFile | ( | uint8_t | mip = 0 , |
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 , |
||
ImageConversion::FileFormat | fileFormat = ImageConversion::FileFormat::DEFAULT |
||
) | const |
bool VTF::saveThumbnailToFile | ( | const std::string & | imagePath, |
ImageConversion::FileFormat | fileFormat = ImageConversion::FileFormat::DEFAULT |
||
) | const |
std::vector< std::byte > VTF::saveThumbnailToFile | ( | ImageConversion::FileFormat | fileFormat = ImageConversion::FileFormat::DEFAULT | ) | const |
void VTF::setCompressionLevel | ( | int16_t | newCompressionLevel | ) |
void VTF::setCompressionMethod | ( | CompressionMethod | newCompressionMethod | ) |
bool VTF::setFaceCount | ( | bool | isCubemap, |
bool | hasSphereMap = false |
||
) |
void VTF::setFormat | ( | ImageFormat | newFormat, |
ImageConversion::ResizeFilter | filter = ImageConversion::ResizeFilter::DEFAULT |
||
) |
bool VTF::setFrameFaceAndSliceCount | ( | uint16_t | newFrameCount, |
bool | isCubemap, | ||
bool | hasSphereMap = false , |
||
uint16_t | newSliceCount = 1 |
||
) |
bool VTF::setImage | ( | const std::string & | imagePath, |
ImageConversion::ResizeFilter | filter = ImageConversion::ResizeFilter::DEFAULT , |
||
uint8_t | mip = 0 , |
||
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) |
bool VTF::setImage | ( | std::span< const std::byte > | imageData_, |
ImageFormat | format_, | ||
uint16_t | width_, | ||
uint16_t | height_, | ||
ImageConversion::ResizeFilter | filter = ImageConversion::ResizeFilter::DEFAULT , |
||
uint8_t | mip = 0 , |
||
uint16_t | frame = 0 , |
||
uint8_t | face = 0 , |
||
uint16_t | slice = 0 |
||
) |
void VTF::setImageHeightResizeMethod | ( | ImageConversion::ResizeMethod | imageHeightResizeMethod_ | ) |
void VTF::setImageResizeMethods | ( | ImageConversion::ResizeMethod | imageWidthResizeMethod_, |
ImageConversion::ResizeMethod | imageHeightResizeMethod_ | ||
) |
void VTF::setImageWidthResizeMethod | ( | ImageConversion::ResizeMethod | imageWidthResizeMethod_ | ) |
void VTF::setKeyValuesDataResource | ( | const std::string & | value | ) |
void VTF::setLODResource | ( | uint8_t | u, |
uint8_t | v, | ||
uint8_t | u360 = 0 , |
||
uint8_t | v360 = 0 |
||
) |
void VTF::setReflectivity | ( | sourcepp::math::Vec3f | newReflectivity | ) |
|
protected |
void VTF::setSize | ( | uint16_t | newWidth, |
uint16_t | newHeight, | ||
ImageConversion::ResizeFilter | filter | ||
) |
void VTF::setThumbnail | ( | std::span< const std::byte > | imageData_, |
ImageFormat | format_, | ||
uint16_t | width_, | ||
uint16_t | height_ | ||
) |
void VTF::setVersion | ( | uint32_t | newMajorVersion, |
uint32_t | newMinorVersion | ||
) |
|
protected |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
protected |
|
staticconstexpr |
This value is only valid when passed to VTF::create through CreationOptions or VTF::setFormat.
|
staticconstexpr |
This value is only valid when passed to VTF::create through CreationOptions.
|
protected |
|
protected |
|
protected |
|
protected |