| 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 |
#ifndef DDSLIB_H |
| 42 |
#define DDSLIB_H |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
#include <stdio.h> |
| 48 |
#include <memory.h> |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#ifdef __cplusplus |
| 54 |
extern "C" |
| 55 |
{ |
| 56 |
#endif |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
typedef enum |
| 62 |
{ |
| 63 |
DDS_PF_ARGB8888, |
| 64 |
DDS_PF_DXT1, |
| 65 |
DDS_PF_DXT2, |
| 66 |
DDS_PF_DXT3, |
| 67 |
DDS_PF_DXT4, |
| 68 |
DDS_PF_DXT5, |
| 69 |
DDS_PF_UNKNOWN |
| 70 |
} |
| 71 |
ddsPF_t; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
#define DDS_LOW_5 0x001F; |
| 76 |
#define DDS_MID_6 0x07E0; |
| 77 |
#define DDS_HIGH_5 0xF800; |
| 78 |
#define DDS_MID_555 0x03E0; |
| 79 |
#define DDS_HI_555 0x7C00; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
typedef struct ddsColorKey_s |
| 84 |
{ |
| 85 |
unsigned int colorSpaceLowValue; |
| 86 |
unsigned int colorSpaceHighValue; |
| 87 |
} |
| 88 |
ddsColorKey_t; |
| 89 |
|
| 90 |
|
| 91 |
typedef struct ddsCaps_s |
| 92 |
{ |
| 93 |
unsigned int caps1; |
| 94 |
unsigned int caps2; |
| 95 |
unsigned int caps3; |
| 96 |
unsigned int caps4; |
| 97 |
} |
| 98 |
ddsCaps_t; |
| 99 |
|
| 100 |
|
| 101 |
typedef struct ddsMultiSampleCaps_s |
| 102 |
{ |
| 103 |
unsigned short flipMSTypes; |
| 104 |
unsigned short bltMSTypes; |
| 105 |
} |
| 106 |
ddsMultiSampleCaps_t; |
| 107 |
|
| 108 |
|
| 109 |
typedef struct ddsPixelFormat_s |
| 110 |
{ |
| 111 |
unsigned int size; |
| 112 |
unsigned int flags; |
| 113 |
unsigned int fourCC; |
| 114 |
union |
| 115 |
{ |
| 116 |
unsigned int rgbBitCount; |
| 117 |
unsigned int yuvBitCount; |
| 118 |
unsigned int zBufferBitDepth; |
| 119 |
unsigned int alphaBitDepth; |
| 120 |
unsigned int luminanceBitCount; |
| 121 |
unsigned int bumpBitCount; |
| 122 |
unsigned int privateFormatBitCount; |
| 123 |
}; |
| 124 |
union |
| 125 |
{ |
| 126 |
unsigned int rBitMask; |
| 127 |
unsigned int yBitMask; |
| 128 |
unsigned int stencilBitDepth; |
| 129 |
unsigned int luminanceBitMask; |
| 130 |
unsigned int bumpDuBitMask; |
| 131 |
unsigned int operations; |
| 132 |
}; |
| 133 |
union |
| 134 |
{ |
| 135 |
unsigned int gBitMask; |
| 136 |
unsigned int uBitMask; |
| 137 |
unsigned int zBitMask; |
| 138 |
unsigned int bumpDvBitMask; |
| 139 |
ddsMultiSampleCaps_t multiSampleCaps; |
| 140 |
}; |
| 141 |
union |
| 142 |
{ |
| 143 |
unsigned int bBitMask; |
| 144 |
unsigned int vBitMask; |
| 145 |
unsigned int stencilBitMask; |
| 146 |
unsigned int bumpLuminanceBitMask; |
| 147 |
}; |
| 148 |
union |
| 149 |
{ |
| 150 |
unsigned int rgbAlphaBitMask; |
| 151 |
unsigned int yuvAlphaBitMask; |
| 152 |
unsigned int luminanceAlphaBitMask; |
| 153 |
unsigned int rgbZBitMask; |
| 154 |
unsigned int yuvZBitMask; |
| 155 |
}; |
| 156 |
} |
| 157 |
ddsPixelFormat_t; |
| 158 |
|
| 159 |
|
| 160 |
typedef struct ddsBuffer_s |
| 161 |
{ |
| 162 |
|
| 163 |
char magic[ 4 ]; |
| 164 |
|
| 165 |
|
| 166 |
unsigned int size; |
| 167 |
unsigned int flags; |
| 168 |
unsigned int height; |
| 169 |
unsigned int width; |
| 170 |
union |
| 171 |
{ |
| 172 |
int pitch; |
| 173 |
unsigned int linearSize; |
| 174 |
}; |
| 175 |
unsigned int backBufferCount; |
| 176 |
union |
| 177 |
{ |
| 178 |
unsigned int mipMapCount; |
| 179 |
unsigned int refreshRate; |
| 180 |
unsigned int srcVBHandle; |
| 181 |
}; |
| 182 |
unsigned int alphaBitDepth; |
| 183 |
unsigned int reserved; |
| 184 |
unsigned int surface; |
| 185 |
union |
| 186 |
{ |
| 187 |
ddsColorKey_t ckDestOverlay; |
| 188 |
unsigned int emptyFaceColor; |
| 189 |
}; |
| 190 |
ddsColorKey_t ckDestBlt; |
| 191 |
ddsColorKey_t ckSrcOverlay; |
| 192 |
ddsColorKey_t ckSrcBlt; |
| 193 |
union |
| 194 |
{ |
| 195 |
ddsPixelFormat_t pixelFormat; |
| 196 |
unsigned int fvf; |
| 197 |
}; |
| 198 |
ddsCaps_t ddsCaps; |
| 199 |
unsigned int textureStage; |
| 200 |
|
| 201 |
|
| 202 |
unsigned char data[ 4 ]; |
| 203 |
} |
| 204 |
ddsBuffer_t; |
| 205 |
|
| 206 |
|
| 207 |
typedef struct ddsColorBlock_s |
| 208 |
{ |
| 209 |
unsigned short colors[ 2 ]; |
| 210 |
unsigned char row[ 4 ]; |
| 211 |
} |
| 212 |
ddsColorBlock_t; |
| 213 |
|
| 214 |
|
| 215 |
typedef struct ddsAlphaBlockExplicit_s |
| 216 |
{ |
| 217 |
unsigned short row[ 4 ]; |
| 218 |
} |
| 219 |
ddsAlphaBlockExplicit_t; |
| 220 |
|
| 221 |
|
| 222 |
typedef struct ddsAlphaBlock3BitLinear_s |
| 223 |
{ |
| 224 |
unsigned char alpha0; |
| 225 |
unsigned char alpha1; |
| 226 |
unsigned char stuff[ 6 ]; |
| 227 |
} |
| 228 |
ddsAlphaBlock3BitLinear_t; |
| 229 |
|
| 230 |
|
| 231 |
typedef struct ddsColor_s |
| 232 |
{ |
| 233 |
unsigned char r, g, b, a; |
| 234 |
} |
| 235 |
ddsColor_t; |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
int DDSGetInfo( ddsBuffer_t *dds, int *width, int *height, ddsPF_t *pf ); |
| 241 |
int DDSDecompress( ddsBuffer_t *dds, unsigned char *pixels ); |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
#ifdef __cplusplus |
| 247 |
} |
| 248 |
#endif |
| 249 |
|
| 250 |
#endif |