MCPcopy Create free account
hub / github.com/codestation/qcma / FaceOffset

Function FaceOffset

common/dds.cpp:836–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834
835
836static int FaceOffset( const DDSHeader & header )
837{
838
839 DDSType type = GetType( header );
840
841 int mipmap = qMax(header.mipmapcount, 1U);
842 int size = 0;
843 int w = header.width;
844 int h = header.height;
845
846 if( type >= DDS_DXT1 ) {
847 int multiplier = (type == DDS_DXT1) ? 8 : 16;
848 do {
849 int face_size = qMax(w/4,1) * qMax(h/4,1) * multiplier;
850 size += face_size;
851 w >>= 1;
852 h >>= 1;
853 } while( --mipmap );
854 } else {
855 int multiplier = header.pf.bitcount / 8;
856 do {
857 int face_size = w * h * multiplier;
858 size += face_size;
859 w = qMax( w>>1, 1 );
860 h = qMax( h>>1, 1 );
861 } while( --mipmap );
862 }
863
864 return size;
865}
866
867#if CUBE_LAYOUT == HORIZONTAL
868static int face_offset[6][2] = { {2, 1}, {0, 1}, {1, 0}, {1, 2}, {1, 1}, {3, 1} };

Callers 1

LoadCubeMapFunction · 0.85

Calls 1

GetTypeFunction · 0.85

Tested by

no test coverage detected