-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdds.cpp
More file actions
101 lines (86 loc) · 2.81 KB
/
dds.cpp
File metadata and controls
101 lines (86 loc) · 2.81 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/************************************************************************************************
File: Write to DDS
************************************************************************************************/
#include "dds.h"
unsigned char DDS_Ident[4] = {0x44, 0x44, 0x53, 0x20}; //This needs to be here in the CPP file
/*
void WriteDDS(const float4 &_data, const rStr fileName)
{
//--- Define main variables
rFile outHeader, outData;
DDS_PIXELFORMAT ddsPx;
DDS_HEADER ddsHead;
rMem::r_memset_asm(&ddsPx, 0, sizeof(DWORD) * 8);
rMem::r_memset_asm(&ddsHead, 0, sizeof(DWORD) * 31);
//--- Define DDS header
ddsPx.dwSize = 32;
ddsPx.dwFlags = 4;
ddsPx.dwFourCC = 116; //32bits per channel, RGBA
ddsPx.dwRGBBitCount = 0;
ddsPx.dwRBitMask = 0;
ddsPx.dwGBitMask = 0;
ddsPx.dwBBitMask = 0;
ddsPx.dwABitMask = 0;
ddsHead.dwSize = 124;
ddsHead.dwFlags = 0x80000 + 0x1000 + 0x07;
ddsHead.dwHeight = _SIZE1K_ * _SZMULT_;
ddsHead.dwWidth = _SIZE1K_ * _SZMULT_;
ddsHead.dwPitchOrLinearSize = 16; //Each pixel = 16 bytes
ddsHead.dwDepth = 0;
ddsHead.dwMipMapCount = 0;
ddsHead.dwReserved1; //All zero;
ddsHead.ddspf = ddsPx;
ddsHead.dwCaps = 0x1000; //Required 0x1000
ddsHead.dwCaps2 = 0;
ddsHead.dwCaps3 = 0;
ddsHead.dwCaps4 = 0;
ddsHead.dwReserved2 = 0;
//Write data
starFile.write( (const char*) &DDS_Ident, 4);
starFile.write( (const char*) &ddsHead, 124);
starFile.write( (const char*) &_data[0], sizeof(float4) * (ddsHead.dwHeight * ddsHead.dwWidth) );
starFile.close();
}
void WriteDDS(const rSurf2D_128f &hdrTexture, const rStr fileName)
{
//--- Define main variables
rFile outHeader, outData;
DDS_PIXELFORMAT ddsPx;
DDS_HEADER ddsHead;
rMem::r_memset_asm(&ddsPx, 0, sizeof(DWORD) * 8);
rMem::r_memset_asm(&ddsHead, 0, sizeof(DWORD) * 31);
//--- Define DDS header
ddsPx.dwSize = 32;
ddsPx.dwFlags = 4;
ddsPx.dwFourCC = 116; //32bits per channel, RGBA
ddsPx.dwRGBBitCount = 0;
ddsPx.dwRBitMask = 0;
ddsPx.dwGBitMask = 0;
ddsPx.dwBBitMask = 0;
ddsPx.dwABitMask = 0;
ddsHead.dwSize = 124;
ddsHead.dwFlags = 0x80000 + 0x1000 + 0x07;
ddsHead.dwHeight = hdrTexture.getLength();
ddsHead.dwWidth = hdrTexture.getLength();
ddsHead.dwPitchOrLinearSize = 16; //Each pixel = 16 bytes
ddsHead.dwDepth = 0;
ddsHead.dwMipMapCount = 0;
ddsHead.dwReserved1; //All zero;
ddsHead.ddspf = ddsPx;
ddsHead.dwCaps = 0x1000; //Required 0x1000
ddsHead.dwCaps2 = 0;
ddsHead.dwCaps3 = 0;
ddsHead.dwCaps4 = 0;
ddsHead.dwReserved2 = 0;
//--- Set names
outHeader.setName(fileName.c_str());
outHeader.setPath("d:/");
outData.setName(fileName.c_str());
outData.setPath("d:/");
//--- Write data
starFile.write( (const char*) &DDS_Ident, 4);
starFile.write( (const char*) &ddsHead, 124);
starFile.write( (const char*) &_data[0], sizeof(float4) * (ddsHead.dwHeight * ddsHead.dwWidth) );
starFile.close();
}
*/