Documentation ¶
Index ¶
Constants ¶
const ( // FlagPointSampling FlagPointSampling = 0x0001 // FlagTrilinearSampling FlagTrilinearSampling = 0x0002 // FlagClampS FlagClampS = 0x0004 // FlagClampT FlagClampT = 0x0008 // FlagAnisotropicFiltering FlagAnisotropicFiltering = 0x0010 // FlagHintDXT5 FlagHintDXT5 = 0x0020 // FlagPWLCorrected FlagPWLCorrected = 0x0040 // FlagSRGB FlagSRGB = 0xFFFF // n/a // FlagNoCompress FlagNoCompress = 0x0040 // FlagNormalMap FlagNormalMap = 0x0080 // FlagNoMipmaps FlagNoMipmaps = 0x0100 // FlagNoLevelOfDetail FlagNoLevelOfDetail = 0x0200 // FlagNoMinimumMipmap FlagNoMinimumMipmap = 0x0400 // FlagProcedural FlagProcedural = 0x0800 // FlagOneBitAlpha FlagOneBitAlpha = 0x1000 // FlagEightBitAlpha FlagEightBitAlpha = 0x2000 // FlagEnvironmentMap FlagEnvironmentMap = 0x4000 // FlagRenderTarget FlagRenderTarget = 0x8000 // FlagDepthRenderTarget FlagDepthRenderTarget = 0x10000 // FlagNoDebugOverride FlagNoDebugOverride = 0x20000 // FlagSingleCopy FlagSingleCopy = 0x40000 // FlagPreSRGB FlagPreSRGB = 0x80000 // FlagOneOverMipmapLevelInAlpha FlagOneOverMipmapLevelInAlpha = 0x80000 // FlagPreMultiplyColorByOneOverMipmapLevel FlagPreMultiplyColorByOneOverMipmapLevel = 0x100000 // FlagNormalToDuDv FlagNormalToDuDv = 0x200000 // FlagAlphaTestMipmapGeneration FlagAlphaTestMipmapGeneration = 0x400000 // FlagNoDepthBuffer FlagNoDepthBuffer = 0x800000 // FlagNiceFiltered FlagNiceFiltered = 0x1000000 // FlagClampU FlagClampU = 0x2000000 // FlagVertexTexture FlagVertexTexture = 0x4000000 // FlagSSBump FlagSSBump = 0x8000000 // FlagBorder FlagBorder = 0x20000000 )
Variables ¶
var ( // ErrorVtfSignatureMismatch occurs when a stream does not start with the VTF magic signature ErrorVtfSignatureMismatch = errors.New("header signature does not match: VTF\x00") // ErrorTextureDepthNotSupported occurs when attempting to parse a stream with depth > 1 ErrorTextureDepthNotSupported = errors.New("only vtf textures with depth 1 are supported") // ErrorMipmapSizeMismatch occurs when filesize does not match calculated mipmap size ErrorMipmapSizeMismatch = errors.New("expected data size is smaller than actual") )
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct { HeaderCommon Header72 Header73 }
Header for VTF Header format Contents includes information for all versions Its up to the implementee to decide what properties they need based on the version
type Header72 ¶
type Header72 struct { // Depth of the largest mipmap in pixels (^2) ushort Depth uint16 }
Header72 is v7.2+ includes these properties
type Header73 ¶
type Header73 struct { // NumResource is number of resources this vtf has NumResource uint32 // contains filtered or unexported fields }
Header73 is v7.3+ includes these properties
type HeaderCommon ¶
type HeaderCommon struct { //Signature is file signature char Signature [4]byte // Version - Version[0].version[1] e.g. 7.2 uint Version [2]uint32 // HeaderSize is size of Header (16 byte aligned, currently 80bytes) uint HeaderSize uint32 // Width of largest mipmap (^2) ushort Width uint16 // Height of largest mipmap (^2) ushort Height uint16 // Flags are VTF Flags uint Flags uint32 // Frames in number of frames (if animated) default: 1 ushort Frames uint16 // FirstFrame is first frame in animation (0 based) ushort FirstFrame uint16 // Reflectivity vector float Reflectivity [3]float32 // BumpmapScale is bumpmap scale float BumpmapScale float32 // HighResImageFormat is high resolution image format uint (probably 4?) HighResImageFormat uint32 // MipmapCount is number of mipmaps uchar MipmapCount uint8 // LowResImageFormat is low resolution image format (always DXT1 [=14]) uint LowResImageFormat uint32 // LowResImageWidth is low resolution image width uchar LowResImageWidth uint8 // LowResImageHeight is low resolution image height uchar LowResImageHeight uint8 // contains filtered or unexported fields }
HeaderCommon: All VTF versions start with these properties
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads from a vtf stream
func (*Reader) Read ¶
Read parses vtf image from stream into a usable structure The only error to expect would be if mipmap data size overflows the total file size; normally due to tampered Header data.
func (*Reader) ReadHeader ¶ added in v1.2.0
ReadHeader reads the header of a texture only.
type Vtf ¶
type Vtf struct {
// contains filtered or unexported fields
}
Vtf: Exported vtf format Contains a Header, resources (v7.3+), low res thumbnail & high-res mipmaps
func ReadFromFile ¶
ReadFromFile is a wrapper for ReadFromStream wrapper to load directly from filesystem. Exists for convenience
func ReadFromStream ¶
ReadFromStream loads a vtf from standard io.Reader stream
func (*Vtf) HighResImageData ¶ added in v1.1.0
HighResImageData returns all data for all mipmaps
func (*Vtf) HighestResolutionImageForFrame ¶ added in v1.1.0
HighestResolutionImageForFrame returns the best possible resolution for a single frame in the vtf
func (*Vtf) Image ¶ added in v1.2.0
Image returns raw data of the first frame of the highest resolution mipmap
func (*Vtf) LowResImageData ¶ added in v1.1.0
LowResImageData returns raw data of low-resolution thumbnail
func (*Vtf) MipmapsForFrame ¶ added in v1.1.0
MipmapsForFrame returns all mipmap sizes for a single frame