blob: 4242c615701a84b9cca89fa2741ed7001a733ad1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#ifndef DDSFILE_H
#define DDSFILE_H
#include "ddsformat.h"
#include <QByteArray>
#include <QString>
#include <QVector>
struct DDSMipLevel {
uint32_t width;
uint32_t height;
QByteArray data;
};
struct DDSFace {
QVector<DDSMipLevel> mips;
};
class DDSFile
{
public:
bool loadFromFile(const QString& path);
bool loadFromData(const QByteArray& data);
uint32_t width() const { return m_width; }
uint32_t height() const { return m_height; }
bool isCubemap() const { return m_cubemap; }
int faceCount() const { return m_faces.size(); }
int mipCount() const { return m_faces.isEmpty() ? 0 : m_faces[0].mips.size(); }
const DDSFace& face(int i) const { return m_faces[i]; }
const GLFormatInfo& glFormat() const { return m_glFormat; }
QString description() const { return m_description; }
private:
bool parse(const QByteArray& data);
uint32_t m_width = 0;
uint32_t m_height = 0;
bool m_cubemap = false;
GLFormatInfo m_glFormat;
DXGIFormat m_dxgiFormat = DXGIFormat::UNKNOWN;
QString m_description;
QVector<DDSFace> m_faces;
};
#endif // DDSFILE_H
|