function parseDDS(arrayBuffer) {
    var data = new Uint32Array(arrayBuffer);
    var magicWord = data[0];
    if (magicWord !== DDS_MAGIC) {
        throw new Error('Invalid DDS file magic word');
    }
    var header = new Uint32Array(arrayBuffer, 0, DDS_HEADER_SIZE / Uint32Array.BYTES_PER_ELEMENT);
    // DDS header fields
    var height = header[DDS_FIELDS.HEIGHT];
    var width = header[DDS_FIELDS.WIDTH];
    var mipmapCount = header[DDS_FIELDS.MIPMAP_COUNT];
    // PIXEL_FORMAT fields
    var pixelFormat = new Uint32Array(arrayBuffer, DDS_FIELDS.PIXEL_FORMAT * Uint32Array.BYTES_PER_ELEMENT, DDS_HEADER_PF_SIZE / Uint32Array.BYTES_PER_ELEMENT);
    var formatFlags = pixelFormat[PF_FLAGS];
    // File contains compressed texture(s)
    if (formatFlags & DDPF_FOURCC) {
        var fourCC = pixelFormat[DDS_PF_FIELDS.FOURCC];
        // File contains one DXTn compressed texture
        if (fourCC !== FOURCC_DX10) {
            var internalFormat_1 = FOURCC_TO_FORMAT[fourCC];
            var dataOffset_1 = DDS_MAGIC_SIZE + DDS_HEADER_SIZE;
            var texData = new Uint8Array(arrayBuffer, dataOffset_1);
            var resource = new CompressedTextureResource(texData, {
                format: internalFormat_1,
                width: width,
                height: height,
                levels: mipmapCount // CompressedTextureResource will separate the levelBuffers for us!
            });
            return [resource];
        }
        // FOURCC_DX10 indicates there is a 20-byte DDS_HEADER_DX10 after DDS_HEADER
        var dx10Offset = DDS_MAGIC_SIZE + DDS_HEADER_SIZE;
        var dx10Header = new Uint32Array(data.buffer, dx10Offset, DDS_HEADER_DX10_SIZE / Uint32Array.BYTES_PER_ELEMENT);
        var dxgiFormat = dx10Header[DDS_DX10_FIELDS.DXGI_FORMAT];
        var resourceDimension = dx10Header[DDS_DX10_FIELDS.RESOURCE_DIMENSION];
        var miscFlag = dx10Header[DDS_DX10_FIELDS.MISC_FLAG];
        var arraySize = dx10Header[DDS_DX10_FIELDS.ARRAY_SIZE];
        // Map dxgiFormat to PIXI.INTERNAL_FORMATS
        var internalFormat_2 = DXGI_TO_FORMAT[dxgiFormat];
        if (internalFormat_2 === undefined) {
            throw new Error("DDSParser cannot parse texture data with DXGI format " + dxgiFormat);
        }
        if (miscFlag === DDS_RESOURCE_MISC_TEXTURECUBE) {
            // FIXME: Anybody excited about cubemap compressed textures?
            throw new Error('DDSParser does not support cubemap textures');
        }
        if (resourceDimension === D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D) {
            // FIXME: Anybody excited about 3D compressed textures?
            throw new Error('DDSParser does not supported 3D texture data');
        }
        // Uint8Array buffers of image data, including all mipmap levels in each image
        var imageBuffers = new Array();
        var dataOffset = DDS_MAGIC_SIZE
            + DDS_HEADER_SIZE
            + DDS_HEADER_DX10_SIZE;
        if (arraySize === 1) {
            // No need bothering with the imageSize calculation!
            imageBuffers.push(new Uint8Array(arrayBuffer, dataOffset));
        }
        else {
            // Calculate imageSize for each texture, and then locate each image's texture data
            var pixelSize = INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[internalFormat_2];
            var imageSize = 0;
            var levelWidth = width;
            var levelHeight = height;
            for (var i = 0; i < mipmapCount; i++) {
                var alignedLevelWidth = Math.max(1, (levelWidth + 3) & ~3);
                var alignedLevelHeight = Math.max(1, (levelHeight + 3) & ~3);
                var levelSize = alignedLevelWidth * alignedLevelHeight * pixelSize;
                imageSize += levelSize;
                levelWidth = levelWidth >>> 1;
                levelHeight = levelHeight >>> 1;
            }
            var imageOffset = dataOffset;
            // NOTE: Cubemaps have 6-images per texture (but they aren't supported so ^_^)
            for (var i = 0; i < arraySize; i++) {
                imageBuffers.push(new Uint8Array(arrayBuffer, imageOffset, imageSize));
                imageOffset += imageSize;
            }
        }
        // Uint8Array -> CompressedTextureResource, and we're done!
        return imageBuffers.map(function (buffer) { return new CompressedTextureResource(buffer, {
            format: internalFormat_2,
            width: width,
            height: height,
            levels: mipmapCount
        }); });
    }
    if (formatFlags & DDPF_RGB) {
        // FIXME: We might want to allow uncompressed *.dds files?
        throw new Error('DDSParser does not support uncompressed texture data.');
    }
    if (formatFlags & DDPF_YUV) {
        // FIXME: Does anybody need this feature?
        throw new Error('DDSParser does not supported YUV uncompressed texture data.');
    }
    if (formatFlags & DDPF_LUMINANCE) {
        // FIXME: Microsoft says older DDS filers use this feature! Probably not worth the effort!
        throw new Error('DDSParser does not support single-channel (lumninance) texture data!');
    }
    if (formatFlags & DDPF_ALPHA) {
        // FIXME: I'm tired! See above =)
        throw new Error('DDSParser does not support single-channel (alpha) texture data!');
    }
    throw new Error('DDSParser failed to load a texture file due to an unknown reason!');
}
Parses the DDS file header, generates base-textures, and puts them into the texture cache.
@param arrayBuffer