WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
ddslib.h
Go to the documentation of this file.
1/* -----------------------------------------------------------------------------
2
3DDS Library
4
5Based on code from Nvidia's DDS example:
6http://www.nvidia.com/object/dxtc_decompression_code.html
7
8Copyright (c) 2003 Randy Reddig
9All rights reserved.
10
11Redistribution and use in source and binary forms, with or without modification,
12are permitted provided that the following conditions are met:
13
14Redistributions of source code must retain the above copyright notice, this list
15of conditions and the following disclaimer.
16
17Redistributions in binary form must reproduce the above copyright notice, this
18list of conditions and the following disclaimer in the documentation and/or
19other materials provided with the distribution.
20
21Neither the names of the copyright holders nor the names of its contributors may
22be used to endorse or promote products derived from this software without
23specific prior written permission.
24
25THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
29ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
36----------------------------------------------------------------------------- */
37#pragma once
38
39/* c++ marker */
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/* dds definition */
56
57/* 16bpp stuff */
58#define DDS_LOW_5 0x001F;
59#define DDS_MID_6 0x07E0;
60#define DDS_HIGH_5 0xF800;
61#define DDS_MID_555 0x03E0;
62#define DDS_HI_555 0x7C00;
63
64/* structures */
65typedef struct ddsColorKey_s
66{
67 unsigned int colorSpaceLowValue;
68 unsigned int colorSpaceHighValue;
69}
71
72typedef struct ddsCaps_s
73{
74 unsigned int caps1;
75 unsigned int caps2;
76 unsigned int caps3;
77 unsigned int caps4;
78}
80
82{
83 unsigned short flipMSTypes;
84 unsigned short bltMSTypes;
85}
87
88typedef struct ddsPixelFormat_s
89{
90 unsigned int size;
91 unsigned int flags;
92 unsigned int fourCC;
93
94 union
95 {
96 unsigned int rgbBitCount;
97 unsigned int yuvBitCount;
98 unsigned int zBufferBitDepth;
99 unsigned int alphaBitDepth;
100 unsigned int luminanceBitCount;
101 unsigned int bumpBitCount;
103 };
104
105 union
106 {
107 unsigned int rBitMask;
108 unsigned int yBitMask;
109 unsigned int stencilBitDepth;
110 unsigned int luminanceBitMask;
111 unsigned int bumpDuBitMask;
112 unsigned int operations;
113 };
114
115 union
116 {
117 unsigned int gBitMask;
118 unsigned int uBitMask;
119 unsigned int zBitMask;
120 unsigned int bumpDvBitMask;
122 };
123
124 union
125 {
126 unsigned int bBitMask;
127 unsigned int vBitMask;
128 unsigned int stencilBitMask;
130 };
131
132 union
133 {
134 unsigned int rgbAlphaBitMask;
135 unsigned int yuvAlphaBitMask;
137 unsigned int rgbZBitMask;
138 unsigned int yuvZBitMask;
139 };
140}
142
143typedef struct ddsBuffer_s
144{
145 /* magic: 'dds ' */
146 char magic[4];
147
148 /* directdraw surface */
149 unsigned int size;
150 unsigned int flags;
151 unsigned int height;
152 unsigned int width;
153
154 union
155 {
156 int pitch;
157 unsigned int linearSize;
158 };
159
160 unsigned int backBufferCount;
161
162 union
163 {
164 unsigned int mipMapCount;
165 unsigned int refreshRate;
166 unsigned int srcVBHandle;
167 };
168
169 unsigned int alphaBitDepth;
170 unsigned int reserved;
171 void* surface;
172
173 union
174 {
176 unsigned int emptyFaceColor;
177 };
178
182
183 union
184 {
186 unsigned int fvf;
187 };
188
190 unsigned int textureStage;
191
192 /* data (Varying size) */
193 unsigned char data[4];
194}
196
197typedef struct ddsColorBlock_s
198{
199 unsigned short colors[2];
200 unsigned char row[4];
201}
203
205{
206 unsigned short row[4];
207}
209
211{
212 unsigned char alpha0;
213 unsigned char alpha1;
214 unsigned char stuff[6];
215}
217
218typedef struct ddsColor_s
219{
220 unsigned char r, g, b, a;
221}
223
224/* public functions */
225//int DDSGetInfo( ddsBuffer_t *dds, int *width, int *height, ddsPF_t *pf );
226//int DDSDecompress( ddsBuffer_t *dds, unsigned char *pixels );
227
234int DDSDecompressDXT5(unsigned char* src, int width, int height, unsigned char* dest);
235
242int DDSDecompressDXT3(unsigned char* src, int width, int height, unsigned char* dest);
243
250int DDSDecompressDXT1(unsigned char* src, int width, int height, unsigned char* dest);
251
252/* end marker */
253#ifdef __cplusplus
254}
255#endif
struct ddsPixelFormat_s ddsPixelFormat_t
struct ddsAlphaBlockExplicit_s ddsAlphaBlockExplicit_t
struct ddsBuffer_s ddsBuffer_t
struct ddsColorKey_s ddsColorKey_t
ddsPF_t
Definition ddslib.h:46
@ DDS_PF_DXT2
Definition ddslib.h:49
@ DDS_PF_DXT3
Definition ddslib.h:50
@ DDS_PF_DXT4
Definition ddslib.h:51
@ DDS_PF_DXT1
Definition ddslib.h:48
@ DDS_PF_ARGB8888
Definition ddslib.h:47
@ DDS_PF_DXT5
Definition ddslib.h:52
@ DDS_PF_UNKNOWN
Definition ddslib.h:53
int DDSDecompressDXT1(unsigned char *src, int width, int height, unsigned char *dest)
Decompress a DXT1 (BC1) compressed texture into raw RGBA pixels.
Definition ddslib.cpp:479
struct ddsColorBlock_s ddsColorBlock_t
struct ddsAlphaBlock3BitLinear_s ddsAlphaBlock3BitLinear_t
struct ddsColor_s ddsColor_t
struct ddsCaps_s ddsCaps_t
int DDSDecompressDXT3(unsigned char *src, int width, int height, unsigned char *dest)
Decompress a DXT3 (BC2) compressed texture into raw RGBA pixels.
Definition ddslib.cpp:519
struct ddsMultiSampleCaps_s ddsMultiSampleCaps_t
int DDSDecompressDXT5(unsigned char *src, int width, int height, unsigned char *dest)
Decompress a DXT5 (BC3) compressed texture into raw RGBA pixels.
Definition ddslib.cpp:566
unsigned char alpha1
Definition ddslib.h:213
unsigned char stuff[6]
Definition ddslib.h:214
unsigned char alpha0
Definition ddslib.h:212
unsigned short row[4]
Definition ddslib.h:206
unsigned int height
Definition ddslib.h:151
unsigned int mipMapCount
Definition ddslib.h:164
unsigned int reserved
Definition ddslib.h:170
char magic[4]
Definition ddslib.h:146
unsigned int emptyFaceColor
Definition ddslib.h:176
void * surface
Definition ddslib.h:171
unsigned int refreshRate
Definition ddslib.h:165
unsigned int linearSize
Definition ddslib.h:157
unsigned int srcVBHandle
Definition ddslib.h:166
unsigned int textureStage
Definition ddslib.h:190
ddsPixelFormat_t pixelFormat
Definition ddslib.h:185
int pitch
Definition ddslib.h:156
ddsCaps_t ddsCaps
Definition ddslib.h:189
unsigned char data[4]
Definition ddslib.h:193
unsigned int backBufferCount
Definition ddslib.h:160
unsigned int width
Definition ddslib.h:152
unsigned int flags
Definition ddslib.h:150
unsigned int size
Definition ddslib.h:149
ddsColorKey_t ckDestBlt
Definition ddslib.h:179
unsigned int fvf
Definition ddslib.h:186
ddsColorKey_t ckDestOverlay
Definition ddslib.h:175
ddsColorKey_t ckSrcBlt
Definition ddslib.h:181
ddsColorKey_t ckSrcOverlay
Definition ddslib.h:180
unsigned int alphaBitDepth
Definition ddslib.h:169
unsigned int caps4
Definition ddslib.h:77
unsigned int caps1
Definition ddslib.h:74
unsigned int caps2
Definition ddslib.h:75
unsigned int caps3
Definition ddslib.h:76
unsigned char row[4]
Definition ddslib.h:200
unsigned short colors[2]
Definition ddslib.h:199
unsigned int colorSpaceLowValue
Definition ddslib.h:67
unsigned int colorSpaceHighValue
Definition ddslib.h:68
unsigned char a
Definition ddslib.h:220
unsigned char g
Definition ddslib.h:220
unsigned char b
Definition ddslib.h:220
unsigned char r
Definition ddslib.h:220
unsigned short flipMSTypes
Definition ddslib.h:83
unsigned short bltMSTypes
Definition ddslib.h:84
unsigned int yuvBitCount
Definition ddslib.h:97
unsigned int stencilBitDepth
Definition ddslib.h:109
unsigned int luminanceBitCount
Definition ddslib.h:100
unsigned int rBitMask
Definition ddslib.h:107
unsigned int bumpBitCount
Definition ddslib.h:101
unsigned int bumpDuBitMask
Definition ddslib.h:111
unsigned int fourCC
Definition ddslib.h:92
unsigned int uBitMask
Definition ddslib.h:118
unsigned int rgbZBitMask
Definition ddslib.h:137
unsigned int yuvZBitMask
Definition ddslib.h:138
unsigned int zBufferBitDepth
Definition ddslib.h:98
unsigned int vBitMask
Definition ddslib.h:127
unsigned int yBitMask
Definition ddslib.h:108
unsigned int rgbBitCount
Definition ddslib.h:96
unsigned int operations
Definition ddslib.h:112
unsigned int stencilBitMask
Definition ddslib.h:128
unsigned int luminanceBitMask
Definition ddslib.h:110
unsigned int gBitMask
Definition ddslib.h:117
unsigned int zBitMask
Definition ddslib.h:119
unsigned int size
Definition ddslib.h:90
unsigned int flags
Definition ddslib.h:91
unsigned int alphaBitDepth
Definition ddslib.h:99
unsigned int yuvAlphaBitMask
Definition ddslib.h:135
unsigned int rgbAlphaBitMask
Definition ddslib.h:134
ddsMultiSampleCaps_t multiSampleCaps
Definition ddslib.h:121
unsigned int bumpDvBitMask
Definition ddslib.h:120
unsigned int bumpLuminanceBitMask
Definition ddslib.h:129
unsigned int bBitMask
Definition ddslib.h:126
unsigned int luminanceAlphaBitMask
Definition ddslib.h:136
unsigned int privateFormatBitCount
Definition ddslib.h:102