summaryrefslogtreecommitdiff
path: root/public/materialsystem/hardwaretexels.h
diff options
context:
space:
mode:
Diffstat (limited to 'public/materialsystem/hardwaretexels.h')
-rw-r--r--public/materialsystem/hardwaretexels.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/public/materialsystem/hardwaretexels.h b/public/materialsystem/hardwaretexels.h
new file mode 100644
index 0000000..0821b41
--- /dev/null
+++ b/public/materialsystem/hardwaretexels.h
@@ -0,0 +1,87 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Hardware Texels
+//
+// Contains texture data that was encoded with the map. The initial use case
+// is for per-texel lightmaps to allow static props to match the lighting
+// of the surrounding BSP geometry.
+//
+//=============================================================================//
+
+#ifndef HARDWARETEXELS_H
+#define HARDWARETEXELS_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "bitmap/imageformat.h"
+#include "datamap.h"
+
+// valve hardware texels
+#define VHT_VERSION 0
+
+namespace HardwareTexels
+{
+#pragma pack(1)
+
+// ------------------------------------------------------------------------------------------------
+struct MeshHeader_t
+{
+ DECLARE_BYTESWAP_DATADESC();
+
+ // this mesh is part of this lod
+ unsigned int m_nLod;
+
+ // starting at this offset
+ unsigned int m_nOffset;
+
+ // this mesh consumes this many bytes
+ unsigned int m_nBytes;
+
+ // with this width and height
+ unsigned int m_nWidth;
+ unsigned int m_nHeight;
+
+ unsigned int m_nUnused[3];
+};
+
+// ------------------------------------------------------------------------------------------------
+struct FileHeader_t
+{
+ DECLARE_BYTESWAP_DATADESC();
+
+ // file version as defined by VHV_VERSION
+ int m_nVersion;
+
+ // must match checkSum in the .mdl header
+ unsigned int m_nChecksum;
+
+ // all texels are encoded in the same format
+ // This is a value from ImageFormat.
+ unsigned int m_nTexelFormat;
+
+ // Number of meshes
+ int m_nMeshes;
+
+ inline MeshHeader_t *pMesh( int nMesh ) const
+ {
+ Assert(nMesh < m_nMeshes);
+
+ return (MeshHeader_t *)(((byte *)this) + sizeof(FileHeader_t)) + nMesh;
+ };
+
+ inline void *pTexelBase( int nMesh ) const
+ {
+ return (void *)((byte *)this + pMesh( nMesh )->m_nOffset);
+ };
+
+ unsigned int m_nUnused[4];
+};
+
+#pragma pack()
+
+}; // end namespace
+
+#endif // HARDWARETEXELS_H
+