Skip to content

TAServers/VTFParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5a85ab4 · Nov 10, 2024

History

61 Commits
Oct 14, 2024
Aug 4, 2024
Nov 10, 2024
Jan 25, 2022
Aug 4, 2024
Aug 4, 2024
Aug 4, 2024
Aug 3, 2024
Aug 4, 2024
Aug 4, 2024
Jan 26, 2022
Oct 14, 2024
Aug 4, 2024

Repository files navigation

VTFParser

Simple and modern library for parsing the Valve Texture Format.

Documentation: https://taservers.github.io/VTFParser/

See also: https://github.com/TAServers/BSPParser and https://github.com/TAServers/MDLParser.

What's Included

  • A class for parsing and abstracting the VTF file format.
  • Enums, limits and structs for most of the file format.
    • Unlike older versions of the library, structs are not provided for each of the possible pixel formats. Most if not all of the formats are supported by each major graphics API.

Example

The following minimal example shows how you can parse and access the VTF high-res image data:

#include "VTFParser.hpp"

// Load from a file on disk, an API, or somewhere in memory
const auto vtfData = ...;

// Parse the data (you should wrap this in a try/catch)
const VtfParser::Vtf vtf(vtfData);

// Read data (exact approach will depend on your use-case)
const auto imageData = vtf.getHighResImageData();
for (uint32_t mipLevel = 0; mipLevel < vtf.getMipLevels(); mipLevel++) {
  for (uint32_t frame = 0; frame < vtf.getFrames(); frame++) {
    for (uint32_t face = 0; face < vtf.getFaces(); face++) {
      const auto offset = vtf.getImageSliceOffset(mipLevel, frame, face);
      // imageData[offset]
    }
  }
}