A tiny, dependency-free C++ VTF (Valve Texture Format) loader/decoder.
This repo provides a single header (vtf.hpp) plus a small example program that decodes a VTF and writes a PPM image.
- Header-only, standard C++ (C++17+)
- Parses VTF headers (tested for VTF 7.x; accepts 7.0–7.5)
- Decodes the largest mip level of a chosen frame into RGBA8
- Supported formats:
- Uncompressed:
RGBA8888,ARGB8888,ABGR8888,BGRA8888,RGB888,BGR888 - Compressed:
DXT1,DXT3,DXT5
- Uncompressed:
- Not a full VTF implementation (no cubemaps, no volume textures, no normal-map special handling)
- Only decodes the largest mip level (mip 0)
- Only reads the high-res image resource; other resources are ignored
cmake -S . -B build
cmake --build build --config Release./build/vtf_to_ppm <input.vtf> <output.ppm> [frameIndex]Example:
./build/vtf_to_ppm my_texture.vtf out.ppm 0The example writes a binary PPM (P6). Alpha is dropped.
#include "vtf.hpp"
vtf::Image img;
if (!img.load_from_file("foo.vtf")) {
// img.error()
}
if (!img.decode_rgba8(0)) {
// img.error()
}
auto& header = img.header();
auto& rgba = img.rgba8(); // width * height * 4MIT