Skip to content

Commit

Permalink
Merge pull request #7 from TAServers/expose-flags
Browse files Browse the repository at this point in the history
Expose VTF texture flags
  • Loading branch information
Derpius authored Nov 10, 2024
2 parents d68e57f + f9a6541 commit 1b598c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/vtf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ namespace VtfParser {
size_t size = 0;
for (uint8_t mipLevel = 0; mipLevel < sizeInfo.mipLevels; mipLevel++) {
ImageSizeInfo mipSizeInfo = sizeInfo;
mipSizeInfo.width = std::max(sizeInfo.width >> mipLevel, 1ull);
mipSizeInfo.height = std::max(sizeInfo.height >> mipLevel, 1ull);
mipSizeInfo.depth = std::max(sizeInfo.depth >> mipLevel, 1ull);
mipSizeInfo.width = std::max<size_t>(sizeInfo.width >> mipLevel, 1ul);
mipSizeInfo.height = std::max<size_t>(sizeInfo.height >> mipLevel, 1ul);
mipSizeInfo.depth = std::max<size_t>(sizeInfo.depth >> mipLevel, 1ul);
size += getMipSizeBytes(mipSizeInfo);
}

Expand Down Expand Up @@ -205,6 +205,10 @@ namespace VtfParser {
return header.firstFrame;
}

TextureFlags Vtf::getFlags() const {
return header.flags;
}

std::span<const std::byte> Vtf::getHighResImageData() const {
return highResImageData;
}
Expand Down
6 changes: 6 additions & 0 deletions src/vtf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ namespace VtfParser {
*/
[[nodiscard]] uint16_t getFirstFrame() const;

/**
* Gets the flags set on the texture.
* @return TextureFlags packed together as a bitflag.
*/
[[nodiscard]] TextureFlags getFlags() const;

/**
* Gets the high resolution image data.
* @return View over the high-res data.
Expand Down

0 comments on commit 1b598c1

Please sign in to comment.